Commit eb150c5e by 任晓松

表单删除、修改校验,表单项增加,删除,修改校验

parent 24e2f1d4
......@@ -37,6 +37,16 @@ class FormInfoCtl extends CtlBase {
return result;
}
/**
* 删除
* @param pobj
* @returns {Promise<*>}
*/
async delete(pobj){
let result = await this.service.deleteForm(pobj);
return result;
}
}
module.exports = FormInfoCtl;
......@@ -30,6 +30,15 @@ class FormItemCtl extends CtlBase {
return result;
}
/**
* 删除
* @param pobj
* @returns {Promise<*>}
*/
async delete(pobj){
let result = this.service.deleteItem(pobj);
return result;
}
}
module.exports = FormItemCtl;
......@@ -6,6 +6,7 @@ class ForminfoService extends ServiceBase {
constructor() {
super("configmag", ServiceBase.getDaoName(ForminfoService));
this.formitemSve = system.getObject("service.configmag.formitemSve");
this.templateSve = system.getObject("service.template.templateinfoSve");
}
/**
......@@ -25,6 +26,7 @@ class ForminfoService extends ServiceBase {
pobj.code = code;
pobj.user_id = pobj.userid;
pobj.user_name = pobj.username;
pobj.form_items = '单行文本,手机号'
let result = await this.create(pobj);
if(!result){
return system.getResultFail(-1,'创建表单失败');
......@@ -66,6 +68,22 @@ class ForminfoService extends ServiceBase {
}
return system.getResultSuccess();
}
/**
* 表单删除
* @param pobj
* @returns {Promise<void>}
*/
async deleteForm(pobj){
let template = await this.templateSve.findOne({form_id:pobj.id},[]);
if(template && template.is_enabled == 1){
return system.getResultFail(-1,'表单已投入使用,不能删除')
}
let del = await this.delete(pobj);
return system.getResult(del);
}
/**
* 修改方法
* @param pobj
......@@ -76,6 +94,10 @@ class ForminfoService extends ServiceBase {
name:pobj.name,
form_describe: pobj.form_describe
}
let template = await this.templateSve.findOne({form_id:pobj.id},[]);
if(template && template.is_enabled == 1){
return system.getResultFail(-1,'表单已投入使用,不能修改')
}
//获取相关表单项
let itemData = await this.formitemSve.findAll({form_id:pobj.id},[]);
let form_items = '';
......
......@@ -5,6 +5,7 @@ const settings = require("../../../../config/settings");
class FormitemService extends ServiceBase {
constructor() {
super("configmag", ServiceBase.getDaoName(FormitemService));
this.templateSve = system.getObject('service.template.templateinfoSve');
}
async getFormItemListByFormId(pobj){
......@@ -31,6 +32,10 @@ class FormitemService extends ServiceBase {
if(!pobj.sequence){
return system.getResultFail(-1,'排序不能为空')
}
let template = await this.templateSve.findOne({form_id:pobj.form_id},[]);
if(template && template.is_enabled == 1){
return system.getResultFail(-1,'表单已投入使用,不能新增表单项');
}
let config_params = await this.packageConfigParams(pobj);
let code = await this.getBusUid('it');
pobj.config_params = config_params;
......@@ -42,6 +47,24 @@ class FormitemService extends ServiceBase {
}
/**
*
* @param pobj
* @returns {Promise<void>}
*/
async deleteItem(pobj){
let itemInfo = await this.findOne({id:pobj.id},[]);
if(['contact_mobile','contact_name'].includes(itemInfo.code)){
return system.getResultFail(-1,'默认表单项,不能删除');
}
let template = await this.templateSve.findOne({form_id:pobj.form_id},[]);
if(template && template.is_enabled == 1){
return system.getResultFail(-1,'表单已投入使用,不能删除表单项');
}
let delRet = await this.delete(pobj);
return system.getResult(delRet);
}
/**
* 修改表表单项
* @param pobj
* @returns {Promise<void>}
......@@ -51,8 +74,15 @@ class FormitemService extends ServiceBase {
if(!pobj.name){
return system.getResultFail(-1,'表单名称不能为空');
}
if(!pobj.form_describe){
return system.getResultFail(-1,'表单描述不能为空')
if(!pobj.sequence){
return system.getResultFail(-1,'表单排序不能为空')
}
if(['contact_mobile','contact_name'].includes(pobj.code)){
return system.getResultFail(-1,'默认表单项,不能修改');
}
let template = await this.templateSve.findOne({form_id:pobj.form_id},[]);
if(template && template.is_enabled == 1){
return system.getResultFail(-1,'表单已投入使用,不能修改表单项');
}
let config_params = await this.packageConfigParams(pobj);
pobj.config_params = 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