作者 tangxvhui

机会模板设置 修改

#app的名称
appname = ability
#运行模式
runmode =${RUN_MODE||test}
runmode =${RUN_MODE||dev}
#是否自动渲染页面
autorender = false
#是否复制请求body
... ...
... ... @@ -58,6 +58,11 @@ func (this *TemplateController) TemplateAdd() {
msg = protocol.BadRequestParam("10609")
return
}
if !(request.AuditFlowConfig.SelfCheckNeed == models.AuditSelfCheckNeedYes ||
request.AuditFlowConfig.SelfCheckNeed == models.AuditSelfCheckNeedNo) {
msg = protocol.BadRequestParam("1")
return
}
}
{
if msg = audit.ValidFormList(request.Template.InputList); msg.Errno != 0 {
... ...
... ... @@ -40,6 +40,33 @@ type AuditFormValueList struct {
Type string `json:"type"` //输入的数据内容类型
}
//输入框类型
const (
InputTypeText string = "text" //单行文本宽
InputTypeRadio string = "radio" //单选框
InputTypeImageVedio string = "image/vedio" // 图片或视频输入
)
//输入框输入的数据类型
const (
InputDataTypeText string = "text" //单纯文本
InputDataTypeImage string = "image" //图片的文件url
InputDataTypeVedio string = "vedio" //视频的文件url
)
var (
InputDataTypeMap map[string]bool = map[string]bool{
InputDataTypeText: true,
InputDataTypeImage: true,
InputDataTypeVedio: true,
}
InputTypeMap map[string]bool = map[string]bool{
InputTypeText: true,
InputTypeRadio: true,
InputTypeImageVedio: true,
}
)
var (
DeleteAuditFormBy = `delete FROM audit_form where audit_template_id=? and company_id=?`
)
... ...
... ... @@ -4,38 +4,11 @@ import (
"sort"
)
//输入框类型
const (
InputTypeText string = "text" //单行文本宽
InputTypeRadio string = "radio" //单选框
InputImageVedio string = "image/vedio" // 图片或视频输入
)
//输入框输入的数据类型
const (
InputDataTypeText string = "text" //单纯文本
InputDataTypeImage string = "image" //图片的文件url
InputDataTypeVedio string = "vedio" //视频的文件url
)
var (
InputDataTypeMap map[string]bool = map[string]bool{
InputDataTypeText: true,
InputDataTypeImage: true,
InputDataTypeVedio: true,
}
InputTypeMap map[string]bool = map[string]bool{
InputTypeText: true,
InputTypeRadio: true,
InputImageVedio: true,
}
)
type InputElementData struct {
Value string `json:"value"` //输入框填写的值
Type string `json:"type"` //输入数据内容的类型
Path string `json:"path,omitempy"`
Cover map[string]interface{} `json:"cover,omitempy"`
Path string `json:"path,omitempty"`
Cover map[string]interface{} `json:"cover,omitempty"`
}
type InputElementValueList struct {
... ... @@ -52,8 +25,8 @@ type InputElement struct {
Required int `json:"required"` //是否必填
CurrentValue string `json:"value"` //"当前填写的值"
SectionType int8 `json:"sectionType"`
ValueList []InputElementValueList `json:"valueList,omitempy"` //输入候选值 value_list
Data []InputElementData `json:"data,omitempy"`
ValueList []InputElementValueList `json:"valueList,omitempty"` //输入候选值 value_list
Data []InputElementData `json:"data,omitempty"`
}
//自定义表单
... ... @@ -104,7 +77,7 @@ type Template struct {
type AuditFlowConfig struct {
NoApprover int `json:"noApprover" valid:"Required;"` //审核人为空【1:自动通过】【2:转交给管理员】
ProcessConfig []ProcessConfig `json:"processConfig"` //创建时 0
SelfCheckNeed int `json:"self_check_need"` //是否需要自查内容【1:需要】【2:不需要】
SelfCheckNeed int8 `json:"self_check_need"` //是否需要自查内容【1:需要】【2:不需要】
}
type ProcessConfig struct {
ApproveType int `json:"approveType"` //1.部门长 2 指定成员 3.指定角色
... ...
... ... @@ -103,6 +103,8 @@ var errmessge ErrorMap = map[string]string{
"10631": "人数不能超过10个",
"10632": "请选择一个角色",
"10633": "至多添加一个审批人",
"10634": "基础内容和附加内容总共最多可以添加5个“图片/视频”字段",
"10635": "内容的输入类型错误",
//公司相关 107xx
"10701": "未找到公司信息",
... ...
... ... @@ -407,6 +407,16 @@ func GetChanceDetail(chanceid int64, companyid int64) (ResponseChanceInfo, error
log.Error("解析机会内容失败:%s", err)
}
for i := range chanceContent {
if chanceContent[i].InputType == models.InputTypeText {
//兼容旧数据
chanceContent[i].Data = []protocol.InputElementData{
protocol.InputElementData{
Value: chanceContent[i].CurrentValue,
Type: models.InputDataTypeText,
},
}
}
if chanceContent[i].SectionType == 1 {
returnData.BaseContent = append(returnData.BaseContent, chanceContent[i])
}
... ...
... ... @@ -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
}
... ...