Commit 79298d8e by 任晓松

update

parent 4fba17d0
...@@ -5,8 +5,8 @@ const settings = require("../../../../config/settings"); ...@@ -5,8 +5,8 @@ const settings = require("../../../../config/settings");
class ForminfoService extends ServiceBase { class ForminfoService extends ServiceBase {
constructor() { constructor() {
super("configmag", ServiceBase.getDaoName(ForminfoService)); super("configmag", ServiceBase.getDaoName(ForminfoService));
this.formitemSve = system.getObject("service.configmag.formitemSve"); this.formitemDao = system.getObject("db.configmag.formitemDao");
this.templateSve = system.getObject("service.template.templateinfoSve"); this.templateDao = system.getObject("db.template.templateinfoDao");
} }
/** /**
...@@ -46,7 +46,7 @@ class ForminfoService extends ServiceBase { ...@@ -46,7 +46,7 @@ class ForminfoService extends ServiceBase {
is_required:1, is_required:1,
sequence:2 sequence:2
} }
let itRt = await this.formitemSve.create(phoneItem); let itRt = await this.formitemDao.create(phoneItem);
if(!itRt){ if(!itRt){
return system.getResultFail(-1,'创建联系人表单项失败'); return system.getResultFail(-1,'创建联系人表单项失败');
} }
...@@ -62,7 +62,7 @@ class ForminfoService extends ServiceBase { ...@@ -62,7 +62,7 @@ class ForminfoService extends ServiceBase {
is_required:1, is_required:1,
sequence:1 sequence:1
} }
let itRt2 = await this.formitemSve.create(nameItem); let itRt2 = await this.formitemDao.create(nameItem);
this.updateForm(result) this.updateForm(result)
if(!itRt2){ if(!itRt2){
return system.getResultFail(-1,'创建联系方式表单失败'); return system.getResultFail(-1,'创建联系方式表单失败');
...@@ -76,7 +76,7 @@ class ForminfoService extends ServiceBase { ...@@ -76,7 +76,7 @@ class ForminfoService extends ServiceBase {
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async deleteForm(pobj){ async deleteForm(pobj){
let template = await this.templateSve.findOne({form_id:pobj.id},[]); let template = await this.templateDao.findOne({form_id:pobj.id},[]);
if(template && template.is_enabled == 1){ if(template && template.is_enabled == 1){
return system.getResultFail(-1,'表单已投入使用,不能删除') return system.getResultFail(-1,'表单已投入使用,不能删除')
} }
...@@ -95,12 +95,12 @@ class ForminfoService extends ServiceBase { ...@@ -95,12 +95,12 @@ class ForminfoService extends ServiceBase {
name:pobj.name, name:pobj.name,
form_describe: pobj.form_describe form_describe: pobj.form_describe
} }
let template = await this.templateSve.findOne({form_id:pobj.id},[]); let template = await this.templateDao.findOne({form_id:pobj.id},[]);
if(template && template.is_enabled == 1){ if(template && template.is_enabled == 1){
return system.getResultFail(-1,'表单已投入使用,不能修改') return system.getResultFail(-1,'表单已投入使用,不能修改')
} }
//获取相关表单项 //获取相关表单项
let itemData = await this.formitemSve.findAll({form_id:pobj.id},[]); let itemData = await this.formitemDao.findAll({form_id:pobj.id},[]);
let form_items = ''; let form_items = '';
if(itemData.length>0){ if(itemData.length>0){
itemData.forEach(v=>{ itemData.forEach(v=>{
...@@ -122,7 +122,7 @@ class ForminfoService extends ServiceBase { ...@@ -122,7 +122,7 @@ class ForminfoService extends ServiceBase {
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async copy(pobj){ async copy(pobj){
let items = await this.formitemSve.findAll({form_id:pobj.id},[]); let items = await this.formitemDao.findAll({form_id:pobj.id},[]);
delete pobj.id; delete pobj.id;
delete pobj.created_at; delete pobj.created_at;
let code = await this.getBusUid('fm'); let code = await this.getBusUid('fm');
...@@ -135,7 +135,7 @@ class ForminfoService extends ServiceBase { ...@@ -135,7 +135,7 @@ class ForminfoService extends ServiceBase {
let iCode = await this.getBusUid('it'); let iCode = await this.getBusUid('it');
item.code = iCode; item.code = iCode;
item.form_id = saveRt.id item.form_id = saveRt.id
this.formitemSve.create(item.dataValues); this.formitemDao.create(item.dataValues);
}) })
return system.getResult(saveRt); return system.getResult(saveRt);
} }
......
...@@ -5,7 +5,7 @@ const settings = require("../../../../config/settings"); ...@@ -5,7 +5,7 @@ const settings = require("../../../../config/settings");
class FormitemService extends ServiceBase { class FormitemService extends ServiceBase {
constructor() { constructor() {
super("configmag", ServiceBase.getDaoName(FormitemService)); super("configmag", ServiceBase.getDaoName(FormitemService));
this.templateSve = system.getObject('service.template.templateinfoSve'); this.templateDao = system.getObject('db.template.templateinfoDao');
} }
async getFormItemListByFormId(pobj){ async getFormItemListByFormId(pobj){
...@@ -32,14 +32,16 @@ class FormitemService extends ServiceBase { ...@@ -32,14 +32,16 @@ class FormitemService extends ServiceBase {
if(!pobj.sequence){ if(!pobj.sequence){
return system.getResultFail(-1,'排序不能为空') return system.getResultFail(-1,'排序不能为空')
} }
let template = await this.templateSve.findOne({form_id:pobj.form_id},[]); let template = await this.templateDao.findOne({form_id:pobj.form_id},[]);
if(template && template.is_enabled == 1){ if(template && template.is_enabled == 1){
return system.getResultFail(-1,'表单已投入使用,不能新增表单项'); return system.getResultFail(-1,'表单已投入使用,不能新增表单项');
} }
let config_params = await this.packageConfigParams(pobj); let configRet = await this.packageConfigParams(pobj);
if(configRet.status !== 0){
return configRet;
}
let code = await this.getBusUid('it'); let code = await this.getBusUid('it');
pobj.config_params = config_params; pobj.config_params = configRet.data;
pobj.item_type_name = pobj.item_type_name;
pobj.code = code; pobj.code = code;
//保存表单项 //保存表单项
let result = await this.create(pobj); let result = await this.create(pobj);
...@@ -56,7 +58,7 @@ class FormitemService extends ServiceBase { ...@@ -56,7 +58,7 @@ class FormitemService extends ServiceBase {
if(['contact_mobile','contact_name'].includes(itemInfo.code)){ if(['contact_mobile','contact_name'].includes(itemInfo.code)){
return system.getResultFail(-1,'默认表单项,不能删除'); return system.getResultFail(-1,'默认表单项,不能删除');
} }
let template = await this.templateSve.findOne({form_id:pobj.form_id},[]); let template = await this.templateDao.findOne({form_id:itemInfo.form_id},[]);
if(template && template.is_enabled == 1){ if(template && template.is_enabled == 1){
return system.getResultFail(-1,'表单已投入使用,不能删除表单项'); return system.getResultFail(-1,'表单已投入使用,不能删除表单项');
} }
...@@ -80,12 +82,15 @@ class FormitemService extends ServiceBase { ...@@ -80,12 +82,15 @@ class FormitemService extends ServiceBase {
if(['contact_mobile','contact_name'].includes(pobj.code)){ if(['contact_mobile','contact_name'].includes(pobj.code)){
return system.getResultFail(-1,'默认表单项,不能修改'); return system.getResultFail(-1,'默认表单项,不能修改');
} }
let template = await this.templateSve.findOne({form_id:pobj.form_id},[]); let template = await this.templateDao.findOne({form_id:pobj.form_id},[]);
if(template && template.is_enabled == 1){ if(template && template.is_enabled == 1){
return system.getResultFail(-1,'表单已投入使用,不能修改表单项'); return system.getResultFail(-1,'表单已投入使用,不能修改表单项');
} }
let config_params = await this.packageConfigParams(pobj); let configRet = await this.packageConfigParams(pobj);
pobj.config_params = config_params; if(config_params.status !== 0){
return configRet;
}
pobj.config_params = configRet.data;
let upResult = await this.update(pobj); let upResult = await this.update(pobj);
return system.getResult(upResult); return system.getResult(upResult);
} }
...@@ -99,28 +104,40 @@ class FormitemService extends ServiceBase { ...@@ -99,28 +104,40 @@ class FormitemService extends ServiceBase {
let config_params = {}; let config_params = {};
switch (pobj.item_type) { switch (pobj.item_type) {
case "phone": case "phone":
if(!pobj.mobile_input_length){
return system.getResultFail(-1,'手机号位数选择有误');
}
config_params["mobile_input_length"]=pobj.mobile_input_length =="specific" ?1:2; config_params["mobile_input_length"]=pobj.mobile_input_length =="specific" ?1:2;
config_params["verify_sms"]=pobj.verify_sms==true?1:0; config_params["verify_sms"]=pobj.verify_sms==true?1:0;
break; break;
case "singleBtn": case "singleBtn":
case "multipleBtn": case "multipleBtn":
case "downOptions": case "downOptions":
if(!pobj.options){
return system.getResultFail(-1,'选项内容不能为空')
}
config_params["options"] = pobj.options; config_params["options"] = pobj.options;
break; break;
case "singleText": case "singleText":
case "multipleText": case "multipleText":
if(!pobj.input_les || !pobj.input_lar){
return system.getResultFail(-1,'请填写字数限制');
}
if(pobj.input_lar<pobj.input_les){
return system.getResultFail(-1,'字数范围有误');
}
let length = [] let length = []
length.push(pobj.input_les); length.push(pobj.input_les);
length.push(pobj.input_lar); length.push(pobj.input_lar);
config_params["input_length"] = length; config_params["input_length"] = length;
break; break;
case "area": case "area":
config_params["is_show_county"] = pobj.is_show_county; config_params["is_show_county"] = pobj.is_show_county==true?1:0;
break; break;
default: default:
break; break;
} }
return config_params; return system.getResult(config_params);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment