Commit d2cdb5a3 by 钟占达

Merge branch 'gsb-marketplat' of gitlab.gongsibao.com:jiangyong/zhichan into gsb-marketplat

parents 5cfee64c c15061c6
...@@ -59,6 +59,7 @@ class Template extends APIBase { ...@@ -59,6 +59,7 @@ class Template extends APIBase {
opResult = await this.templatelinkSve.getTemplateAndLinkInfo(pobj); opResult = await this.templatelinkSve.getTemplateAndLinkInfo(pobj);
break; break;
case "submitFormRecord"://提交表单记录 case "submitFormRecord"://提交表单记录
var a=0;
opResult = await this.formsubmitrecordSve.submitFormRecord(pobj); opResult = await this.formsubmitrecordSve.submitFormRecord(pobj);
break; break;
default: default:
......
...@@ -4,13 +4,20 @@ ...@@ -4,13 +4,20 @@
* @param DataTypes * @param DataTypes
* @returns {Model|void|*} * @returns {Model|void|*}
*/ */
const record_status = {"1":"未读", "2":"已读", "3":"无效"};
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("formsubmitrecord", { return db.define("formsubmitrecord", {
business_code:DataTypes.STRING(100), business_code:DataTypes.STRING(100),
template_id: DataTypes.INTEGER(11),//模板id template_id: DataTypes.INTEGER(11),//模板id
templatelink_id: DataTypes.INTEGER(11),//模板链接id templatelink_id: DataTypes.INTEGER(11),//模板链接id
form_id: DataTypes.INTEGER(11),//表单id form_id: DataTypes.INTEGER(11),//表单id
record_status: DataTypes.STRING(60),//记录状态 1未读 2已读 3无效 record_status :{//记录状态 1未读 2已读 3无效
type: DataTypes.STRING(60),
set: function (val) {
this.setDataValue("record_status", val);
this.setDataValue("record_status_name",record_status[val]);
}
},
record_status_name: DataTypes.STRING(60),//记录状态名称 record_status_name: DataTypes.STRING(60),//记录状态名称
templatelink_snapshot:DataTypes.JSON,//模板链接快照 templatelink_snapshot:DataTypes.JSON,//模板链接快照
record_content:DataTypes.JSON,//记录内容 record_content:DataTypes.JSON,//记录内容
......
...@@ -156,17 +156,19 @@ class ForminfoService extends ServiceBase { ...@@ -156,17 +156,19 @@ class ForminfoService extends ServiceBase {
let ctls = []; let ctls = [];
if(items.length>0){ if(items.length>0){
items.forEach(item=>{ items.forEach(item=>{
if(item.is_enabled === 1){ if(item.is_enabled == 1){
let ctl = {} let ctl = {}
ctl['type'] = data[item.item_type]; ctl['type'] = data[item.item_type];
ctl['label'] = item.name; ctl['label'] = item.name;
ctl['prop'] = item.code; ctl['prop'] = item.code;
let rules = [];
//单选框 多选框 下拉选项 添加options属性 结构为 a,b,c //单选框 多选框 下拉选项 添加options属性 结构为 a,b,c
if(['singleBtn','multipleBtn','downOptions'].includes(item.item_type) && item.config_params){ if(['singleBtn','multipleBtn','downOptions'].includes(item.item_type) && item.config_params){
ctl['options'] = item.config_params.options ctl['options'] = item.config_params.options
rules = [{ "required": true, "message": ' ', "trigger": 'change' }];
}else{
rules = [{ "required": true, "message": ' ', "trigger": 'blur' }];
} }
//校验
let rules = [{ "required": true, "message": ' ', "trigger": 'blur' }];
//单行文本 多行文本 增加校验项 有最小和最大值 //单行文本 多行文本 增加校验项 有最小和最大值
if(['singleText','multipleText'].includes(item.item_type) && item.config_params){ if(['singleText','multipleText'].includes(item.item_type) && item.config_params){
let rule = { "validator": "validatex", "trigger": "blur","minchars":item.config_params.input_length[0],"maxchars":item.config_params.input_length[1]} let rule = { "validator": "validatex", "trigger": "blur","minchars":item.config_params.input_length[0],"maxchars":item.config_params.input_length[1]}
...@@ -194,7 +196,7 @@ class ForminfoService extends ServiceBase { ...@@ -194,7 +196,7 @@ class ForminfoService extends ServiceBase {
ctl['archName']= 'regionJSON'; ctl['archName']= 'regionJSON';
ctl['rootName'] = '全国区域'; ctl['rootName'] = '全国区域';
} }
if(item.is_required ===1){ if(item.is_required ==1){
ctl['rules'] = rules; ctl['rules'] = rules;
} }
ctls.push(ctl); ctls.push(ctl);
......
...@@ -14,7 +14,7 @@ class FormitemService extends ServiceBase { ...@@ -14,7 +14,7 @@ class FormitemService extends ServiceBase {
} }
var list = await this.dao.model.findAll({ var list = await this.dao.model.findAll({
attributes:[["code","key"],["name","title"]], attributes:[["code","key"],["name","title"]],
where:{form_id:pobj.form_id}, where:{form_id:pobj.form_id,is_enabled:1},
raw:true, raw:true,
order:[["sequence","asc"]] order:[["sequence","asc"]]
}); });
......
...@@ -37,10 +37,10 @@ class FormsubmitrecordService extends ServiceBase { ...@@ -37,10 +37,10 @@ class FormsubmitrecordService extends ServiceBase {
if(!linkInfo.template_id){ if(!linkInfo.template_id){
return system.getResultFail(-301,"链接模板信息错误") return system.getResultFail(-301,"链接模板信息错误")
} }
var templateinfo = await this.templateinfoDao.model.findOne{ var templateinfo = await this.templateinfoDao.model.findOne({
where:{id:linkInfo.template_id},raw:true, where:{id:linkInfo.template_id},raw:true,
attributes:["id","business_code"] attributes:["id","business_code"]
}; });
if(!templateinfo || !templateinfo.id){ if(!templateinfo || !templateinfo.id){
return system.getResultFail(-500,"未知模板信息"); return system.getResultFail(-500,"未知模板信息");
} }
...@@ -53,7 +53,7 @@ class FormsubmitrecordService extends ServiceBase { ...@@ -53,7 +53,7 @@ class FormsubmitrecordService extends ServiceBase {
} }
//获取表单项 //获取表单项
var formitems = await this.formitemDao.model.findAll({ var formitems = await this.formitemDao.model.findAll({
where:{form_id:ab.form_id},raw:true where:{form_id:ab.form_id},raw:true,order:[["sequence","asc"]]
}); });
//校验封装参数 //校验封装参数
var res = await this.checkAndPackageFormItems(formitems,ab); var res = await this.checkAndPackageFormItems(formitems,ab);
...@@ -83,7 +83,7 @@ class FormsubmitrecordService extends ServiceBase { ...@@ -83,7 +83,7 @@ class FormsubmitrecordService extends ServiceBase {
if(item && item.code && item.is_enabled){//显示状态的表单项 if(item && item.code && item.is_enabled){//显示状态的表单项
var value = ab[item.code]; var value = ab[item.code];
if(item.is_required===1){//必填 if(item.is_required===1){//必填
if(!ab[item.code]){ if(!ab[item.code] || ab[item.code].length<1){
return system.getResultFail(-100,item.name+"参数不能为空"); return system.getResultFail(-100,item.name+"参数不能为空");
} }
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
1. [获取表单列表](#getFormList) 1. [获取表单列表](#getFormList)
1. [获取文件上传配置信息](#getOssConfig) 1. [获取文件上传配置信息](#getOssConfig)
1. [根据链接参数获取模板链接信息](#getTemplateAndLinkInfo) 1. [根据链接参数获取模板链接信息](#getTemplateAndLinkInfo)
1. [提交表单记录](#submitFormRecord)
## **<a name="createTemplate"> 创建模板</a>** ## **<a name="createTemplate"> 创建模板</a>**
[返回到目录](#menu) [返回到目录](#menu)
...@@ -513,6 +514,7 @@ ...@@ -513,6 +514,7 @@
} }
``` ```
## **<a name="getTemplateAndLinkInfo"> 根据链接参数获取模板链接信息</a>** ## **<a name="getTemplateAndLinkInfo"> 根据链接参数获取模板链接信息</a>**
[返回到目录](#menu) [返回到目录](#menu)
##### URL ##### URL
...@@ -595,3 +597,36 @@ ...@@ -595,3 +597,36 @@
} }
``` ```
## **<a name="submitFormRecord"> 提交表单记录</a>**
[返回到目录](#menu)
##### URL
[/api/action/template/springBoard]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
#### 渠道执行的类型 actionType:submitFormRecord
``` javascript
{
"actionType": "submitFormRecord",
"actionBody": {
"link_code": "TL202008141607VdD4le",
"form_id": 79,
"contact_mobile": "13075556693",
"contact_name": "1234",
"IT202008171022jen9Ar": "test",
"IT202008171023jxT06N": "10"
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"requestId": "77d3b071053c44a9b5322bb01b0a27aa"
}
```
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