Commit 988a8dc9 by 任晓松

update

parent f533f3f2
......@@ -14,9 +14,20 @@ class FormItemCtl extends CtlBase {
* @param pobj
* @returns {Promise<void>}
*/
// async create(pobj){
//
// }
async create(pobj){
let result = this.formitemSve.createItem(pobj);
return result;
}
/**
* 重写删除
* @param pobj
* @returns {Promise<void>}
*/
async delete(pobj){
let result = this.formitemSve.deleteItem(pobj);
return result;
}
}
module.exports = FormItemCtl;
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
var cacheBaseComp = null;
class FormInfoCtl extends CtlBase {
constructor() {
super("templateinfomag", CtlBase.getServiceName(FormInfoCtl));
this.templatelinkSve = system.getObject('service.template.templatelinkSve');
}
/**
* 重写查询方法
* @param pobj
* @returns {Promise<{msg: string, data: *, bizmsg: string, status: number}>}
*/
async findAndCountAll(pobj) {
let result = await this.templatelinkSve.findAndCountAll(pobj);
return result;
}
/**
* 重写保存方法
* @param pobj
* @returns {Promise<void>}
*/
async create(pobj){
let result = await this.templatelinkSve.createTemplateLink(pobj);
return result;
}
}
module.exports = FormInfoCtl;
......@@ -4,38 +4,25 @@
* @param DataTypes
* @returns {Model|void|*}
*/
const record_status={"1":"未读", "2":"已读", "3":"无效"};
module.exports = (db, DataTypes) => {
return db.define("formsubmitrecord", {
form_id:DataTypes.INTEGER(11),//表单id
template_id:DataTypes.INTEGER(11),//表单id
templatelink_id:DataTypes.INTEGER(11),//表单id
record_status :{//记录状态 1未读 2已读 3无效
type: DataTypes.STRING,
set: function (val) {
this.setDataValue("record_status", val);
this.setDataValue("record_status_name", record_status[val]);
}
},//
record_status_name:DataTypes.STRING(60),//记录状态名称
templatelink_snapshot:DataTypes.JSON,
form_snapshot:DataTypes.JSON,
record_content:DataTypes.JSON,
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updated_at: true,
tableName: 'c_form_submit_record',
validate: {
},
indexes: [
]
return db.define("formsubmitrecord", {
template_id: DataTypes.INTEGER(11),///模板id
templatelink_id: DataTypes.INTEGER(11),//模板链接id
form_id: DataTypes.INTEGER(11),//表单id
record_status: DataTypes.STRING(60),//记录状态 1未读 2已读 3无效
record_status_name: DataTypes.STRING(60),//记录状态名称
templatelink_snapshot:DataTypes.JSON,//模板链接快照
record_content:DataTypes.JSON,//记录内容
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updated_at: true,
tableName: 'c_form_submit_record',
validate: {},
indexes: []
});
}
......@@ -32,14 +32,6 @@ class ForminfoService extends ServiceBase {
if(!pobj.form_describe){
return system.getResult(null,'form_describe can not be empty');
}
let items = '';
// if(!pobj.form_item){
// return 'form_item can not be empty';
// }
const formItem = this.composeItem(items);
if(formItem.status != 0){
return formItem;
}
let code = await this.getBusUid("fm")
let formData = {
name:pobj.name,
......@@ -50,7 +42,7 @@ class ForminfoService extends ServiceBase {
user_name:pobj.username
}
let result = await this.create(formData);
return system.getResul(result);
return system.getResult(result);
}
/**
*
......@@ -58,14 +50,9 @@ class ForminfoService extends ServiceBase {
* @returns {Promise<void>}
*/
async updateForm(pobj) {
return null;
}
//表单项 数据重组
async composeItem(obj){
return system.getResultSuccess();
}
}
module.exports = ForminfoService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class FormitemService extends ServiceBase {
constructor() {
super("configmag", ServiceBase.getDaoName(FormitemService));
this.forminfoSve = system.getObject("service.configmag.forminfoSve");
}
/**
* 创建表单项
* @param pobj
* @returns {Promise<void>}
*/
async createItem(pobj) {
let type_name = await this.getTypeName(pobj.item_type);
let code = await this.getBusUid('it');
pobj.item_type_name = type_name;
pobj.is_enabled = pobj.is_enabled ? 1:0;
pobj.is_required = pobj.is_required ? 1:0;
pobj.code = code;
console.log(pobj)
//获取表单的表单项
let form = await this.forminfoSve.findOne({id:pobj.form_id},['form_items']);
console.log(form)
if(!form){
return system.getResult(null,'获取订单信息失败');
}
let form_items = form.form_items ? form.form_items + "、" + type_name : type_name;
//修改表单项字段
this.forminfoSve.updateByWhere({form_items:form_items},{id:pobj.form_id});
//保存表单项
let result = await this.create(pobj);
return system.getResult(result)
}
/**
* 表单项删除
* @param pobj
* @returns {Promise<void>}
*/
async deleteItem(pobj){
let item = await this.findOne({id:pobj.id},['form_id','item_type_name']);
if(!item){
return system.getResult(null,'获取表单项失败');
}
let form = await this.forminfoSve.findOne({id:item.form_id},['form_items']);
if(!form){
return system.getResult(null,'获取表单失败');
}
let form_items = form.form_items.replace('、'+item.item_type_name,'');
this.forminfoSve.updateByWhere({form_items:form_items},{id:item.form_id});
let result = await this.delete(pobj);
return system.getResult(result);
}
/**
*
* @param pobj
* @returns {Promise<void>}
*/
async updateForm(pobj) {
return null;
}
//根据类型获取类型名称
async getTypeName(type) {
let data = {
"phone": "手机号",
"singleBtn": "单选按钮",
"multipleBtn": "多选按钮",
"downOptions": "下拉选项",
"singleText": "单行文本",
"multipleText": "多行文本",
"dateTime": "日期",
"area": "省市"
}
return data[type];
}
}
module.exports = FormitemService;
\ No newline at end of file
......@@ -3,7 +3,7 @@ const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class ImginfoService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(ImginfoService));
super("configmag", ServiceBase.getDaoName(ImginfoService));
}
async create(pobj){
......
......@@ -4,7 +4,7 @@ const settings = require("../../../../config/settings");
class LaunchchannelService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(LaunchchannelService));
super("configmag", ServiceBase.getDaoName(LaunchchannelService));
}
/**
......
......@@ -3,7 +3,7 @@ const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class MaininfoService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(MaininfoService));
super("configmag", ServiceBase.getDaoName(MaininfoService));
}
async create(pobj){
......
......@@ -3,7 +3,7 @@ const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class PuttypeService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(PuttypeService));
super("configmag", ServiceBase.getDaoName(PuttypeService));
}
async create(pobj){
......
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