...
|
...
|
@@ -43,20 +43,21 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs |
|
|
//模板
|
|
|
{
|
|
|
template = &models.AuditTemplate{
|
|
|
ChanceTypeId: request.Template.ChanceTypeId,
|
|
|
CompanyId: int(companyId),
|
|
|
Name: request.Template.Name,
|
|
|
Doc: request.Template.Doc,
|
|
|
Icon: request.Template.Icon,
|
|
|
Code: request.Template.Code,
|
|
|
NoApprover: int8(request.AuditFlowConfig.NoApprover),
|
|
|
SortNum: 0,
|
|
|
VisibleType: int8(0),
|
|
|
EnableStatus: 1,
|
|
|
Example: request.Example,
|
|
|
Videos: jsonAssertMarsh(request.Videos),
|
|
|
CreateAt: time.Now(),
|
|
|
UpdateAt: time.Now(),
|
|
|
ChanceTypeId: request.Template.ChanceTypeId,
|
|
|
CompanyId: int(companyId),
|
|
|
Name: request.Template.Name,
|
|
|
Doc: request.Template.Doc,
|
|
|
Icon: request.Template.Icon,
|
|
|
Code: request.Template.Code,
|
|
|
NoApprover: int8(request.AuditFlowConfig.NoApprover),
|
|
|
SortNum: 0,
|
|
|
VisibleType: int8(0),
|
|
|
EnableStatus: 1,
|
|
|
Example: request.Example,
|
|
|
Videos: jsonAssertMarsh(request.Videos),
|
|
|
CreateAt: time.Now(),
|
|
|
UpdateAt: time.Now(),
|
|
|
SelfCheckNeed: request.AuditFlowConfig.SelfCheckNeed,
|
|
|
}
|
|
|
if t, e := models.GetAuditTemplateSort(companyId, request.Template.ChanceTypeId); e == nil {
|
|
|
template.SortNum = t.SortNum + 1
|
...
|
...
|
@@ -73,6 +74,9 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs |
|
|
{
|
|
|
for i := range request.Template.InputList {
|
|
|
input := request.Template.InputList[i]
|
|
|
for ii := range input.ValueList {
|
|
|
input.ValueList[ii].Type = models.InputDataTypeText
|
|
|
}
|
|
|
valueList, _ := json.Marshal(input.ValueList)
|
|
|
auditForm = &models.AuditForm{
|
|
|
CompanyId: int(companyId),
|
...
|
...
|
@@ -406,6 +410,7 @@ func TemplateUpdate(uid, companyId int64, request *protocol.TemplateUpdateReques |
|
|
template.Example = request.Example
|
|
|
template.Videos = jsonAssertMarsh(request.Videos)
|
|
|
template.UpdateAt = time.Now()
|
|
|
template.SelfCheckNeed = request.AuditFlowConfig.SelfCheckNeed
|
|
|
if err = models.UpdateAuditTemplateById(template); err != nil {
|
|
|
log.Error(err.Error())
|
|
|
orm.Rollback()
|
...
|
...
|
@@ -525,7 +530,6 @@ func insertOrUpdateInput(orm orm2.Ormer, companyId int64, templateId int, input |
|
|
{
|
|
|
updateMap := map[string]interface{}{
|
|
|
"Label": input.Label,
|
|
|
"InputType": input.InputType,
|
|
|
"Required": int8(input.Required),
|
|
|
"SortNum": input.Sort,
|
|
|
"ValueList": string(valueList),
|
...
|
...
|
@@ -1067,9 +1071,12 @@ func ValidProcessConfig(config *protocol.ProcessConfig) (msg *protocol.ResponseM |
|
|
//基础表单项不能为空
|
|
|
func ValidFormList(inputs []*protocol.InputElement) (msg *protocol.ResponseMessage) {
|
|
|
msg = &protocol.ResponseMessage{}
|
|
|
var mapCheckRe map[string]string = make(map[string]string)
|
|
|
var countBasic, countExtral int
|
|
|
var countBasicRequire int
|
|
|
var (
|
|
|
mapCheckRe map[string]string = make(map[string]string)
|
|
|
countBasic, countExtral int
|
|
|
countBasicRequire int
|
|
|
imageVedioCnt int
|
|
|
)
|
|
|
for i := range inputs {
|
|
|
input := inputs[i]
|
|
|
if len([]rune(input.Label)) > 50 {
|
...
|
...
|
@@ -1092,6 +1099,13 @@ func ValidFormList(inputs []*protocol.InputElement) (msg *protocol.ResponseMessa |
|
|
if input.SectionType == 1 && input.Required == 1 {
|
|
|
countBasicRequire++
|
|
|
}
|
|
|
if input.InputType == models.InputTypeImageVedio {
|
|
|
imageVedioCnt++
|
|
|
}
|
|
|
if _, ok := models.InputTypeMap[input.InputType]; !ok {
|
|
|
msg = protocol.BadRequestParam("10635")
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
if countBasic == 0 {
|
|
|
msg = protocol.BadRequestParam("10625")
|
...
|
...
|
@@ -1101,5 +1115,9 @@ func ValidFormList(inputs []*protocol.InputElement) (msg *protocol.ResponseMessa |
|
|
msg = protocol.BadRequestParam("10614")
|
|
|
return
|
|
|
}
|
|
|
if imageVedioCnt > 5 {
|
|
|
msg = protocol.BadRequestParam("10634")
|
|
|
return
|
|
|
}
|
|
|
return
|
|
|
} |
...
|
...
|
|