作者 tangxvhui

机会模板详情中增加自查内容

... ... @@ -142,7 +142,7 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs
return
}
//SetSelfCheckData 机会模板设置-自查内容设置
//addSelfCheckData 机会模板设置-自查内容设置
func addSelfCheckData(templateId int64, data []protocol.TemplateSelfCheck, om orm2.Ormer) error {
var (
addSelfCheck []models.AuditCheck
... ... @@ -189,10 +189,12 @@ func addSelfCheckData(templateId int64, data []protocol.TemplateSelfCheck, om or
return err
}
//editSelfCheckData 机会模板设置-自查内容设置
func editSelfCheckData(templateId int64, data []protocol.TemplateSelfCheck, om orm2.Ormer) error {
var (
err error
)
/**简单做法**/
err = models.DeleteAuditCheckByTempelate(templateId, om)
if err != nil {
log.Error("软删除audit_check数据失败,err;%s", err)
... ... @@ -206,6 +208,40 @@ func editSelfCheckData(templateId int64, data []protocol.TemplateSelfCheck, om o
return nil
}
func getSelfCheckData(templateId int64) []protocol.TemplateSelfCheck {
var (
data []protocol.TemplateSelfCheck
selfCheckData []models.AuditCheck
err error
)
selfCheckData, err = models.GetAuditCheckByTemplate(templateId)
if err != nil {
log.Error("获取audit_check数据失败, err:%s", err)
return data
}
for i := range selfCheckData {
checkdata := protocol.TemplateSelfCheck{
Id: selfCheckData[i].Id,
Pid: selfCheckData[i].Pid,
Title: selfCheckData[i].Title,
}
childdatas := []protocol.TemplateSelfCheck{}
for ii := range selfCheckData {
if selfCheckData[ii].Pid == selfCheckData[i].Id {
child := protocol.TemplateSelfCheck{
Id: selfCheckData[ii].Id,
Pid: selfCheckData[ii].Pid,
Title: selfCheckData[ii].Title,
}
childdatas = append(childdatas, child)
}
}
checkdata.Child = childdatas
data = append(data, checkdata)
}
return data
}
func jsonAssertMarsh(v interface{}) string {
if data, e := json.Marshal(v); e != nil {
log.Error(fmt.Sprintf("%v %v", e.Error(), v))
... ... @@ -583,6 +619,8 @@ func TemplateGet(uid, companyId int64, request *protocol.TemplateGetRequest) (rs
rsp.AuditFlowConfig.ProcessConfig = append(rsp.AuditFlowConfig.ProcessConfig, configItem)
}
}
selfCheckData := getSelfCheckData(template.Id)
rsp.SelfCheck = selfCheckData
return
}
... ...