作者 yangfu

草稿箱修改

@@ -297,6 +297,7 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest) @@ -297,6 +297,7 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest)
297 forms []*models.AuditForm 297 forms []*models.AuditForm
298 chance *models.Chance 298 chance *models.Chance
299 chanceDraft *models.ChanceDraft 299 chanceDraft *models.ChanceDraft
  300 + formData []*protocol.Form
300 ) 301 )
301 rsp = &protocol.TemplateResponse{} 302 rsp = &protocol.TemplateResponse{}
302 if templates, err = models.GetAuditTemplate(header.CompanyId, request.ChanceTypeId, request.TemplateId); err != nil { 303 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) @@ -337,9 +338,11 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest)
337 if chanceDraft, err = models.GetChanceDraftById(request.ChanceId); err == nil { 338 if chanceDraft, err = models.GetChanceDraftById(request.ChanceId); err == nil {
338 var old []protocol.SelfCheck 339 var old []protocol.SelfCheck
339 utils.JsonUnmarshal(chanceDraft.SelfChecks, &old) 340 utils.JsonUnmarshal(chanceDraft.SelfChecks, &old)
  341 + utils.JsonUnmarshal(chanceDraft.SourceContent, &formData)
340 template.Questions = GetNewestCheckQuestions(chanceDraft.AuditTemplateId, old) 342 template.Questions = GetNewestCheckQuestions(chanceDraft.AuditTemplateId, old)
341 } 343 }
342 } else { //正常机会 344 } else { //正常机会
  345 + utils.JsonUnmarshal(chance.SourceContent, &formData)
343 if template.Questions, err = agg.GetCheckQuestionsByChanceId(header, request.ChanceId); err != nil { 346 if template.Questions, err = agg.GetCheckQuestionsByChanceId(header, request.ChanceId); err != nil {
344 log.Error(err) 347 log.Error(err)
345 return 348 return
@@ -366,6 +369,19 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest) @@ -366,6 +369,19 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest)
366 if len(form.ValueList) > 0 && form.InputType == protocol.InputRadio { 369 if len(form.ValueList) > 0 && form.InputType == protocol.InputRadio {
367 utils.JsonUnmarshal(form.ValueList, &formItem.ValueList) 370 utils.JsonUnmarshal(form.ValueList, &formItem.ValueList)
368 } 371 }
  372 + //填充旧的表单数据
  373 + setOldForm := func() {
  374 + for i := range formData {
  375 + data := formData[i]
  376 + if data.Id == formItem.Id && strings.EqualFold(data.Label, data.Label) {
  377 + formItem.Value = data.Value
  378 + formItem.Data = data.Data
  379 + }
  380 + }
  381 + }
  382 + if request.ChanceId > 0 {
  383 + setOldForm()
  384 + }
369 template.FormList[j] = formItem 385 template.FormList[j] = formItem
370 } 386 }
371 rsp.Template = template 387 rsp.Template = template
@@ -811,6 +827,7 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, @@ -811,6 +827,7 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance,
811 if header.UserId == chance.UserId { 827 if header.UserId == chance.UserId {
812 return 828 return
813 } 829 }
  830 + //机会是审核通过的才有编辑记录!!
814 if chance.ReviewStatus != protocol.ReviewStatusPass { 831 if chance.ReviewStatus != protocol.ReviewStatusPass {
815 return 832 return
816 } 833 }