作者 yangfu

草稿箱修改

... ... @@ -297,6 +297,7 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest)
forms []*models.AuditForm
chance *models.Chance
chanceDraft *models.ChanceDraft
formData []*protocol.Form
)
rsp = &protocol.TemplateResponse{}
if templates, err = models.GetAuditTemplate(header.CompanyId, request.ChanceTypeId, request.TemplateId); err != nil {
... ... @@ -337,9 +338,11 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest)
if chanceDraft, err = models.GetChanceDraftById(request.ChanceId); err == nil {
var old []protocol.SelfCheck
utils.JsonUnmarshal(chanceDraft.SelfChecks, &old)
utils.JsonUnmarshal(chanceDraft.SourceContent, &formData)
template.Questions = GetNewestCheckQuestions(chanceDraft.AuditTemplateId, old)
}
} else { //正常机会
utils.JsonUnmarshal(chance.SourceContent, &formData)
if template.Questions, err = agg.GetCheckQuestionsByChanceId(header, request.ChanceId); err != nil {
log.Error(err)
return
... ... @@ -366,6 +369,19 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest)
if len(form.ValueList) > 0 && form.InputType == protocol.InputRadio {
utils.JsonUnmarshal(form.ValueList, &formItem.ValueList)
}
//填充旧的表单数据
setOldForm := func() {
for i := range formData {
data := formData[i]
if data.Id == formItem.Id && strings.EqualFold(data.Label, data.Label) {
formItem.Value = data.Value
formItem.Data = data.Data
}
}
}
if request.ChanceId > 0 {
setOldForm()
}
template.FormList[j] = formItem
}
rsp.Template = template
... ... @@ -811,6 +827,7 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance,
if header.UserId == chance.UserId {
return
}
//机会是审核通过的才有编辑记录!!
if chance.ReviewStatus != protocol.ReviewStatusPass {
return
}
... ...