...
|
...
|
@@ -73,6 +73,7 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs |
|
|
{
|
|
|
for i := range request.Template.InputList {
|
|
|
input := request.Template.InputList[i]
|
|
|
valueList, _ := json.Marshal(input.ValueList)
|
|
|
auditForm = &models.AuditForm{
|
|
|
CompanyId: int(companyId),
|
|
|
AuditTemplateId: int(templateId),
|
...
|
...
|
@@ -83,6 +84,7 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs |
|
|
Required: int8(input.Required),
|
|
|
CreateAt: time.Now(),
|
|
|
EnableStatus: 1,
|
|
|
ValueList: string(valueList),
|
|
|
}
|
|
|
if _, err = orm.Insert(auditForm); err != nil {
|
|
|
log.Error(err.Error())
|
...
|
...
|
@@ -489,11 +491,14 @@ func TemplateUpdate(uid, companyId int64, request *protocol.TemplateUpdateReques |
|
|
}
|
|
|
|
|
|
//更新 或 插入表单
|
|
|
//TODO 检查表单项类型是否被篡改
|
|
|
func insertOrUpdateInput(orm orm2.Ormer, companyId int64, templateId int, input *protocol.InputElement) (err error) {
|
|
|
var (
|
|
|
auditForm *models.AuditForm
|
|
|
)
|
|
|
valueList, _ := json.Marshal(input.ValueList)
|
|
|
if input.Id == 0 {
|
|
|
|
|
|
auditForm = &models.AuditForm{
|
|
|
CompanyId: int(companyId),
|
|
|
AuditTemplateId: int(templateId),
|
...
|
...
|
@@ -504,6 +509,7 @@ func insertOrUpdateInput(orm orm2.Ormer, companyId int64, templateId int, input |
|
|
Required: int8(input.Required),
|
|
|
CreateAt: time.Now(),
|
|
|
EnableStatus: 1,
|
|
|
ValueList: string(valueList),
|
|
|
}
|
|
|
if _, err = orm.Insert(auditForm); err != nil {
|
|
|
log.Error(err.Error())
|
...
|
...
|
@@ -522,6 +528,7 @@ func insertOrUpdateInput(orm orm2.Ormer, companyId int64, templateId int, input |
|
|
"InputType": input.InputType,
|
|
|
"Required": int8(input.Required),
|
|
|
"SortNum": input.Sort,
|
|
|
"ValueList": string(valueList),
|
|
|
}
|
|
|
if err = utils.UpdateTableByMapWithOrmer(orm, auditForm, updateMap); err != nil {
|
|
|
return
|
...
|
...
|
@@ -701,15 +708,25 @@ func TemplateGet(uid, companyId int64, request *protocol.TemplateGetRequest) (rs |
|
|
rsp.Template.InputList = make([]*protocol.InputElement, 0)
|
|
|
for i := range auditForm {
|
|
|
input := auditForm[i]
|
|
|
rsp.Template.InputList = append(rsp.Template.InputList, &protocol.InputElement{
|
|
|
var valuelist []models.AuditFormValueList
|
|
|
json.Unmarshal([]byte(input.ValueList), &valuelist)
|
|
|
inElement := &protocol.InputElement{
|
|
|
Id: input.Id,
|
|
|
Sort: input.SortNum,
|
|
|
Label: input.Label,
|
|
|
Required: int(input.Required),
|
|
|
SectionType: input.Section,
|
|
|
InputType: input.InputType,
|
|
|
}
|
|
|
for _, inputValue := range valuelist {
|
|
|
inElement.ValueList = append(inElement.ValueList, protocol.InputElementValueList{
|
|
|
Value: inputValue.Value,
|
|
|
Type: inputValue.Type,
|
|
|
})
|
|
|
}
|
|
|
rsp.Template.InputList = append(rsp.Template.InputList, inElement)
|
|
|
|
|
|
}
|
|
|
if configs, err = models.GetAuditFlowConfig(template.Id); err != nil {
|
|
|
log.Error("template:%v %v", template.Id, err.Error())
|
|
|
err = nil
|
...
|
...
|
|