正在显示
7 个修改的文件
包含
72 行增加
和
37 行删除
| @@ -58,6 +58,11 @@ func (this *TemplateController) TemplateAdd() { | @@ -58,6 +58,11 @@ func (this *TemplateController) TemplateAdd() { | ||
| 58 | msg = protocol.BadRequestParam("10609") | 58 | msg = protocol.BadRequestParam("10609") |
| 59 | return | 59 | return |
| 60 | } | 60 | } |
| 61 | + if !(request.AuditFlowConfig.SelfCheckNeed == models.AuditSelfCheckNeedYes || | ||
| 62 | + request.AuditFlowConfig.SelfCheckNeed == models.AuditSelfCheckNeedNo) { | ||
| 63 | + msg = protocol.BadRequestParam("1") | ||
| 64 | + return | ||
| 65 | + } | ||
| 61 | } | 66 | } |
| 62 | { | 67 | { |
| 63 | if msg = audit.ValidFormList(request.Template.InputList); msg.Errno != 0 { | 68 | if msg = audit.ValidFormList(request.Template.InputList); msg.Errno != 0 { |
| @@ -40,6 +40,33 @@ type AuditFormValueList struct { | @@ -40,6 +40,33 @@ type AuditFormValueList struct { | ||
| 40 | Type string `json:"type"` //输入的数据内容类型 | 40 | Type string `json:"type"` //输入的数据内容类型 |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | +//输入框类型 | ||
| 44 | +const ( | ||
| 45 | + InputTypeText string = "text" //单行文本宽 | ||
| 46 | + InputTypeRadio string = "radio" //单选框 | ||
| 47 | + InputTypeImageVedio string = "image/vedio" // 图片或视频输入 | ||
| 48 | +) | ||
| 49 | + | ||
| 50 | +//输入框输入的数据类型 | ||
| 51 | +const ( | ||
| 52 | + InputDataTypeText string = "text" //单纯文本 | ||
| 53 | + InputDataTypeImage string = "image" //图片的文件url | ||
| 54 | + InputDataTypeVedio string = "vedio" //视频的文件url | ||
| 55 | +) | ||
| 56 | + | ||
| 57 | +var ( | ||
| 58 | + InputDataTypeMap map[string]bool = map[string]bool{ | ||
| 59 | + InputDataTypeText: true, | ||
| 60 | + InputDataTypeImage: true, | ||
| 61 | + InputDataTypeVedio: true, | ||
| 62 | + } | ||
| 63 | + InputTypeMap map[string]bool = map[string]bool{ | ||
| 64 | + InputTypeText: true, | ||
| 65 | + InputTypeRadio: true, | ||
| 66 | + InputTypeImageVedio: true, | ||
| 67 | + } | ||
| 68 | +) | ||
| 69 | + | ||
| 43 | var ( | 70 | var ( |
| 44 | DeleteAuditFormBy = `delete FROM audit_form where audit_template_id=? and company_id=?` | 71 | DeleteAuditFormBy = `delete FROM audit_form where audit_template_id=? and company_id=?` |
| 45 | ) | 72 | ) |
| @@ -4,38 +4,11 @@ import ( | @@ -4,38 +4,11 @@ import ( | ||
| 4 | "sort" | 4 | "sort" |
| 5 | ) | 5 | ) |
| 6 | 6 | ||
| 7 | -//输入框类型 | ||
| 8 | -const ( | ||
| 9 | - InputTypeText string = "text" //单行文本宽 | ||
| 10 | - InputTypeRadio string = "radio" //单选框 | ||
| 11 | - InputImageVedio string = "image/vedio" // 图片或视频输入 | ||
| 12 | -) | ||
| 13 | - | ||
| 14 | -//输入框输入的数据类型 | ||
| 15 | -const ( | ||
| 16 | - InputDataTypeText string = "text" //单纯文本 | ||
| 17 | - InputDataTypeImage string = "image" //图片的文件url | ||
| 18 | - InputDataTypeVedio string = "vedio" //视频的文件url | ||
| 19 | -) | ||
| 20 | - | ||
| 21 | -var ( | ||
| 22 | - InputDataTypeMap map[string]bool = map[string]bool{ | ||
| 23 | - InputDataTypeText: true, | ||
| 24 | - InputDataTypeImage: true, | ||
| 25 | - InputDataTypeVedio: true, | ||
| 26 | - } | ||
| 27 | - InputTypeMap map[string]bool = map[string]bool{ | ||
| 28 | - InputTypeText: true, | ||
| 29 | - InputTypeRadio: true, | ||
| 30 | - InputImageVedio: true, | ||
| 31 | - } | ||
| 32 | -) | ||
| 33 | - | ||
| 34 | type InputElementData struct { | 7 | type InputElementData struct { |
| 35 | Value string `json:"value"` //输入框填写的值 | 8 | Value string `json:"value"` //输入框填写的值 |
| 36 | Type string `json:"type"` //输入数据内容的类型 | 9 | Type string `json:"type"` //输入数据内容的类型 |
| 37 | - Path string `json:"path,omitempy"` | ||
| 38 | - Cover map[string]interface{} `json:"cover,omitempy"` | 10 | + Path string `json:"path,omitempty"` |
| 11 | + Cover map[string]interface{} `json:"cover,omitempty"` | ||
| 39 | } | 12 | } |
| 40 | 13 | ||
| 41 | type InputElementValueList struct { | 14 | type InputElementValueList struct { |
| @@ -52,8 +25,8 @@ type InputElement struct { | @@ -52,8 +25,8 @@ type InputElement struct { | ||
| 52 | Required int `json:"required"` //是否必填 | 25 | Required int `json:"required"` //是否必填 |
| 53 | CurrentValue string `json:"value"` //"当前填写的值" | 26 | CurrentValue string `json:"value"` //"当前填写的值" |
| 54 | SectionType int8 `json:"sectionType"` | 27 | SectionType int8 `json:"sectionType"` |
| 55 | - ValueList []InputElementValueList `json:"valueList,omitempy"` //输入候选值 value_list | ||
| 56 | - Data []InputElementData `json:"data,omitempy"` | 28 | + ValueList []InputElementValueList `json:"valueList,omitempty"` //输入候选值 value_list |
| 29 | + Data []InputElementData `json:"data,omitempty"` | ||
| 57 | } | 30 | } |
| 58 | 31 | ||
| 59 | //自定义表单 | 32 | //自定义表单 |
| @@ -104,7 +77,7 @@ type Template struct { | @@ -104,7 +77,7 @@ type Template struct { | ||
| 104 | type AuditFlowConfig struct { | 77 | type AuditFlowConfig struct { |
| 105 | NoApprover int `json:"noApprover" valid:"Required;"` //审核人为空【1:自动通过】【2:转交给管理员】 | 78 | NoApprover int `json:"noApprover" valid:"Required;"` //审核人为空【1:自动通过】【2:转交给管理员】 |
| 106 | ProcessConfig []ProcessConfig `json:"processConfig"` //创建时 0 | 79 | ProcessConfig []ProcessConfig `json:"processConfig"` //创建时 0 |
| 107 | - SelfCheckNeed int `json:"self_check_need"` //是否需要自查内容【1:需要】【2:不需要】 | 80 | + SelfCheckNeed int8 `json:"self_check_need"` //是否需要自查内容【1:需要】【2:不需要】 |
| 108 | } | 81 | } |
| 109 | type ProcessConfig struct { | 82 | type ProcessConfig struct { |
| 110 | ApproveType int `json:"approveType"` //1.部门长 2 指定成员 3.指定角色 | 83 | ApproveType int `json:"approveType"` //1.部门长 2 指定成员 3.指定角色 |
| @@ -103,6 +103,8 @@ var errmessge ErrorMap = map[string]string{ | @@ -103,6 +103,8 @@ var errmessge ErrorMap = map[string]string{ | ||
| 103 | "10631": "人数不能超过10个", | 103 | "10631": "人数不能超过10个", |
| 104 | "10632": "请选择一个角色", | 104 | "10632": "请选择一个角色", |
| 105 | "10633": "至多添加一个审批人", | 105 | "10633": "至多添加一个审批人", |
| 106 | + "10634": "基础内容和附加内容总共最多可以添加5个“图片/视频”字段", | ||
| 107 | + "10635": "内容的输入类型错误", | ||
| 106 | //公司相关 107xx | 108 | //公司相关 107xx |
| 107 | "10701": "未找到公司信息", | 109 | "10701": "未找到公司信息", |
| 108 | 110 |
| @@ -407,6 +407,16 @@ func GetChanceDetail(chanceid int64, companyid int64) (ResponseChanceInfo, error | @@ -407,6 +407,16 @@ func GetChanceDetail(chanceid int64, companyid int64) (ResponseChanceInfo, error | ||
| 407 | log.Error("解析机会内容失败:%s", err) | 407 | log.Error("解析机会内容失败:%s", err) |
| 408 | } | 408 | } |
| 409 | for i := range chanceContent { | 409 | for i := range chanceContent { |
| 410 | + | ||
| 411 | + if chanceContent[i].InputType == models.InputTypeText { | ||
| 412 | + //兼容旧数据 | ||
| 413 | + chanceContent[i].Data = []protocol.InputElementData{ | ||
| 414 | + protocol.InputElementData{ | ||
| 415 | + Value: chanceContent[i].CurrentValue, | ||
| 416 | + Type: models.InputDataTypeText, | ||
| 417 | + }, | ||
| 418 | + } | ||
| 419 | + } | ||
| 410 | if chanceContent[i].SectionType == 1 { | 420 | if chanceContent[i].SectionType == 1 { |
| 411 | returnData.BaseContent = append(returnData.BaseContent, chanceContent[i]) | 421 | returnData.BaseContent = append(returnData.BaseContent, chanceContent[i]) |
| 412 | } | 422 | } |
| @@ -57,6 +57,7 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs | @@ -57,6 +57,7 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs | ||
| 57 | Videos: jsonAssertMarsh(request.Videos), | 57 | Videos: jsonAssertMarsh(request.Videos), |
| 58 | CreateAt: time.Now(), | 58 | CreateAt: time.Now(), |
| 59 | UpdateAt: time.Now(), | 59 | UpdateAt: time.Now(), |
| 60 | + SelfCheckNeed: request.AuditFlowConfig.SelfCheckNeed, | ||
| 60 | } | 61 | } |
| 61 | if t, e := models.GetAuditTemplateSort(companyId, request.Template.ChanceTypeId); e == nil { | 62 | if t, e := models.GetAuditTemplateSort(companyId, request.Template.ChanceTypeId); e == nil { |
| 62 | template.SortNum = t.SortNum + 1 | 63 | template.SortNum = t.SortNum + 1 |
| @@ -73,6 +74,9 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs | @@ -73,6 +74,9 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs | ||
| 73 | { | 74 | { |
| 74 | for i := range request.Template.InputList { | 75 | for i := range request.Template.InputList { |
| 75 | input := request.Template.InputList[i] | 76 | input := request.Template.InputList[i] |
| 77 | + for ii := range input.ValueList { | ||
| 78 | + input.ValueList[ii].Type = models.InputDataTypeText | ||
| 79 | + } | ||
| 76 | valueList, _ := json.Marshal(input.ValueList) | 80 | valueList, _ := json.Marshal(input.ValueList) |
| 77 | auditForm = &models.AuditForm{ | 81 | auditForm = &models.AuditForm{ |
| 78 | CompanyId: int(companyId), | 82 | CompanyId: int(companyId), |
| @@ -406,6 +410,7 @@ func TemplateUpdate(uid, companyId int64, request *protocol.TemplateUpdateReques | @@ -406,6 +410,7 @@ func TemplateUpdate(uid, companyId int64, request *protocol.TemplateUpdateReques | ||
| 406 | template.Example = request.Example | 410 | template.Example = request.Example |
| 407 | template.Videos = jsonAssertMarsh(request.Videos) | 411 | template.Videos = jsonAssertMarsh(request.Videos) |
| 408 | template.UpdateAt = time.Now() | 412 | template.UpdateAt = time.Now() |
| 413 | + template.SelfCheckNeed = request.AuditFlowConfig.SelfCheckNeed | ||
| 409 | if err = models.UpdateAuditTemplateById(template); err != nil { | 414 | if err = models.UpdateAuditTemplateById(template); err != nil { |
| 410 | log.Error(err.Error()) | 415 | log.Error(err.Error()) |
| 411 | orm.Rollback() | 416 | orm.Rollback() |
| @@ -525,7 +530,6 @@ func insertOrUpdateInput(orm orm2.Ormer, companyId int64, templateId int, input | @@ -525,7 +530,6 @@ func insertOrUpdateInput(orm orm2.Ormer, companyId int64, templateId int, input | ||
| 525 | { | 530 | { |
| 526 | updateMap := map[string]interface{}{ | 531 | updateMap := map[string]interface{}{ |
| 527 | "Label": input.Label, | 532 | "Label": input.Label, |
| 528 | - "InputType": input.InputType, | ||
| 529 | "Required": int8(input.Required), | 533 | "Required": int8(input.Required), |
| 530 | "SortNum": input.Sort, | 534 | "SortNum": input.Sort, |
| 531 | "ValueList": string(valueList), | 535 | "ValueList": string(valueList), |
| @@ -1067,9 +1071,12 @@ func ValidProcessConfig(config *protocol.ProcessConfig) (msg *protocol.ResponseM | @@ -1067,9 +1071,12 @@ func ValidProcessConfig(config *protocol.ProcessConfig) (msg *protocol.ResponseM | ||
| 1067 | //基础表单项不能为空 | 1071 | //基础表单项不能为空 |
| 1068 | func ValidFormList(inputs []*protocol.InputElement) (msg *protocol.ResponseMessage) { | 1072 | func ValidFormList(inputs []*protocol.InputElement) (msg *protocol.ResponseMessage) { |
| 1069 | msg = &protocol.ResponseMessage{} | 1073 | msg = &protocol.ResponseMessage{} |
| 1070 | - var mapCheckRe map[string]string = make(map[string]string) | ||
| 1071 | - var countBasic, countExtral int | ||
| 1072 | - var countBasicRequire int | 1074 | + var ( |
| 1075 | + mapCheckRe map[string]string = make(map[string]string) | ||
| 1076 | + countBasic, countExtral int | ||
| 1077 | + countBasicRequire int | ||
| 1078 | + imageVedioCnt int | ||
| 1079 | + ) | ||
| 1073 | for i := range inputs { | 1080 | for i := range inputs { |
| 1074 | input := inputs[i] | 1081 | input := inputs[i] |
| 1075 | if len([]rune(input.Label)) > 50 { | 1082 | if len([]rune(input.Label)) > 50 { |
| @@ -1092,6 +1099,13 @@ func ValidFormList(inputs []*protocol.InputElement) (msg *protocol.ResponseMessa | @@ -1092,6 +1099,13 @@ func ValidFormList(inputs []*protocol.InputElement) (msg *protocol.ResponseMessa | ||
| 1092 | if input.SectionType == 1 && input.Required == 1 { | 1099 | if input.SectionType == 1 && input.Required == 1 { |
| 1093 | countBasicRequire++ | 1100 | countBasicRequire++ |
| 1094 | } | 1101 | } |
| 1102 | + if input.InputType == models.InputTypeImageVedio { | ||
| 1103 | + imageVedioCnt++ | ||
| 1104 | + } | ||
| 1105 | + if _, ok := models.InputTypeMap[input.InputType]; !ok { | ||
| 1106 | + msg = protocol.BadRequestParam("10635") | ||
| 1107 | + return | ||
| 1108 | + } | ||
| 1095 | } | 1109 | } |
| 1096 | if countBasic == 0 { | 1110 | if countBasic == 0 { |
| 1097 | msg = protocol.BadRequestParam("10625") | 1111 | msg = protocol.BadRequestParam("10625") |
| @@ -1101,5 +1115,9 @@ func ValidFormList(inputs []*protocol.InputElement) (msg *protocol.ResponseMessa | @@ -1101,5 +1115,9 @@ func ValidFormList(inputs []*protocol.InputElement) (msg *protocol.ResponseMessa | ||
| 1101 | msg = protocol.BadRequestParam("10614") | 1115 | msg = protocol.BadRequestParam("10614") |
| 1102 | return | 1116 | return |
| 1103 | } | 1117 | } |
| 1118 | + if imageVedioCnt > 5 { | ||
| 1119 | + msg = protocol.BadRequestParam("10634") | ||
| 1120 | + return | ||
| 1121 | + } | ||
| 1104 | return | 1122 | return |
| 1105 | } | 1123 | } |
-
请 注册 或 登录 后发表评论