Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
bc3ba262
Commit
bc3ba262
authored
Aug 10, 2020
by
庄冰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
formitem
parent
00d0fbdd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
123 additions
and
2 deletions
+123
-2
gsb-marketplat/app/base/api/impl/action/template.js
+4
-0
gsb-marketplat/app/base/db/metadata/app/platform.js
+14
-1
gsb-marketplat/app/base/db/models/marketconfig/formsubmitrecord.js
+14
-1
gsb-marketplat/app/base/service/impl/configmag/formsubmitrecordSve.js
+91
-0
No files found.
gsb-marketplat/app/base/api/impl/action/template.js
View file @
bc3ba262
...
...
@@ -9,6 +9,7 @@ class Template extends APIBase {
super
();
this
.
templateinfoSve
=
system
.
getObject
(
"service.template.templateinfoSve"
);
this
.
templatelinkSve
=
system
.
getObject
(
"service.template.templatelinkSve"
);
this
.
formsubmitrecordSve
=
system
.
getObject
(
"service.configmag.formsubmitrecordSve"
);
}
/**
* 接口跳转-POST请求
...
...
@@ -54,6 +55,9 @@ class Template extends APIBase {
case
"getTemplateAndLinkInfo"
:
//根据链接参数获取模板链接信息
opResult
=
await
this
.
templatelinkSve
.
getTemplateAndLinkInfo
(
pobj
);
break
;
case
"submitFormRecord"
:
//提交表单记录
opResult
=
await
this
.
formsubmitrecordSve
.
submitFormRecord
(
pobj
);
break
;
default
:
opResult
=
system
.
getResult
(
null
,
"action_type参数错误"
);
break
;
...
...
gsb-marketplat/app/base/db/metadata/app/platform.js
View file @
bc3ba262
...
...
@@ -11,7 +11,20 @@ module.exports = {
"sex"
:
{
"male"
:
"男"
,
"female"
:
"女"
},
"logLevel"
:
{
"debug"
:
0
,
"info"
:
1
,
"warn"
:
2
,
"error"
:
3
,
"fatal"
:
4
},
"msgType"
:
{
"sys"
:
"系统"
,
"single"
:
"单点"
,
"multi"
:
"群发"
},
"node_type"
:{
"org"
:
"组织"
,
"arc"
:
"文档"
}
"node_type"
:{
"org"
:
"组织"
,
"arc"
:
"文档"
},
"item_type"
:{
"phone"
:
"手机号"
,
"singleBtn"
:
"单选按钮"
,
"multipleBtn"
:
"多选按钮"
,
"downOptions"
:
"下拉选项"
,
"singleText"
:
"单行文本"
,
"multipleText"
:
"多行文本"
,
"dateTime"
:
"日期"
,
"area"
:
"省市"
},
"record_status"
:{
"1"
:
"未读"
,
"2"
:
"已读"
,
"3"
:
"无效"
}
}
}
}
gsb-marketplat/app/base/db/models/marketconfig/formsubmitrecord.js
View file @
bc3ba262
...
...
@@ -4,11 +4,24 @@
* @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
record_status
:
DataTypes
.
STRING
(
60
),
//记录状态 1未读 2已读 3无效
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
,
...
...
gsb-marketplat/app/base/service/impl/configmag/formsubmitrecordSve.js
View file @
bc3ba262
...
...
@@ -5,6 +5,10 @@ const settings = require("../../../../config/settings");
class
ForminfoService
extends
ServiceBase
{
constructor
()
{
super
(
"configmag"
,
ServiceBase
.
getDaoName
(
ForminfoService
));
this
.
templateinfoDao
=
system
.
getObject
(
"db.template.templateinfoDao"
);
this
.
templatelinkDao
=
system
.
getObject
(
"db.template.templatelinkDao"
);
this
.
forminfoDao
=
system
.
getObject
(
"db.form.forminfoDao"
);
this
.
formitemDao
=
system
.
getObject
(
"db.form.formitemDao"
);
}
/**
...
...
@@ -37,6 +41,92 @@ class ForminfoService extends ServiceBase {
}
return
system
.
getResult
(
resData
);
}
/**
* 提交表单记录
* @param {*} pobj
*/
async
submitFormRecord
(
pobj
){
var
ab
=
pobj
.
actionBody
;
var
xctx
=
pobj
.
xctx
;
if
(
!
ab
){
return
system
.
getResultFail
(
-
100
,
"参数错误"
);
}
if
(
!
ab
.
link_code
){
return
system
.
getResultFail
(
-
101
,
"模板链接编码不能为空"
);
}
if
(
!
ab
.
form_id
){
return
system
.
getResultFail
(
-
102
,
"表单id不能为空"
);
}
//获取模板链接信息
var
linkInfo
=
await
this
.
templatelinkDao
.
model
.
findOne
({
where
:{
code
:
ab
.
link_code
},
raw
:
true
});
if
(
!
linkInfo
||
!
linkInfo
.
id
){
return
system
.
getResultFail
(
-
300
,
"未知模板链接"
)
}
//获取表单信息
var
forminfo
=
await
this
.
forminfoDao
.
model
.
findOne
({
where
:{
id
:
ab
.
form_id
},
raw
:
true
});
if
(
!
forminfo
||
!
forminfo
.
id
){
return
system
.
getResultFail
(
-
400
,
"未知表单"
)
}
//获取表单项
var
formitems
=
await
this
.
formitemDao
.
model
.
findAll
({
where
:{
form_id
:
ab
.
form_id
},
raw
:
true
});
//校验封装参数
var
res
=
await
this
.
checkAndPackageFormItems
(
formitems
,
ab
);
if
(
res
&&
res
.
status
&&
res
.
status
<
0
){
return
res
;
}
var
params
=
res
;
var
addObj
=
{
template_id
:
linkInfo
.
template_id
,
templatelink_id
:
linkInfo
.
id
,
form_id
:
forminfo
.
id
,
record_status
:
1
,
templatelink_snapshot
:
linkInfo
,
form_snapshot
:{
forminfo
:
forminfo
,
formitems
:
formitems
},
record_content
:
params
}
await
this
.
dao
.
create
(
addObj
);
//创建记录
return
system
.
getResultSuccess
();
}
/**
* 参数校验
* @param {*} formitems 表单项
* @param {*} ab 表单提交数据
*/
async
checkAndPackageFormItems
(
formitems
,
ab
){
var
params
=
{};
for
(
var
i
=
0
;
i
<
formitems
.
length
;
i
++
){
var
item
=
formitems
[
i
];
var
itemConfig
=
item
.
config_params
;
if
(
item
&&
item
.
code
&&
item
.
is_enabled
){
//显示状态的表单项
var
value
=
ab
[
item
.
code
];
if
(
item
.
is_required
===
1
){
//必填
if
(
!
ab
[
item
.
code
]){
return
system
.
getResultFail
(
-
100
,
item
.
name
+
"参数不能为空"
);
}
}
if
(
itemConfig
.
mobile_input_length
===
1
){
//手机号 1:限定11位 2:限定7-11位
if
(
value
&&
value
.
length
!=
11
){
return
system
.
getResultFail
(
-
101
,
item
.
name
+
"参数限定11位"
);
}
}
if
(
itemConfig
.
mobile_input_length
===
2
){
//手机号 1:限定11位 2:限定7-11位
if
(
value
&&
(
value
.
length
<
7
||
value
.
length
>
11
)){
return
system
.
getResultFail
(
-
102
,
item
.
name
+
"参数限定7-11位"
);
}
}
if
(
itemConfig
.
input_length
&&
itemConfig
.
input_length
.
length
==
2
){
//输入长度区间
if
(
value
&&
(
value
.
length
<
itemConfig
.
input_length
[
0
]
||
value
.
length
>
itemConfig
.
input_length
[
1
])){
return
system
.
getResultFail
(
-
103
,
item
.
name
+
"参数输入长度为"
+
itemConfig
.
input_length
[
0
]
+
"-"
+
itemConfig
.
input_length
[
1
]
+
"位"
);
}
}
params
[
item
.
code
]
=
value
;
}
}
return
params
;
}
}
module
.
exports
=
ForminfoService
;
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment