|
@@ -290,13 +290,14 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest) |
|
@@ -290,13 +290,14 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest) |
290
|
templates *models.AuditTemplate
|
290
|
templates *models.AuditTemplate
|
291
|
forms []*models.AuditForm
|
291
|
forms []*models.AuditForm
|
292
|
chance *models.Chance
|
292
|
chance *models.Chance
|
|
|
293
|
+ chanceDraft *models.ChanceDraft
|
293
|
)
|
294
|
)
|
294
|
rsp = &protocol.TemplateResponse{}
|
295
|
rsp = &protocol.TemplateResponse{}
|
295
|
if templates, err = models.GetAuditTemplate(header.CompanyId, request.ChanceTypeId, request.TemplateId); err != nil {
|
296
|
if templates, err = models.GetAuditTemplate(header.CompanyId, request.ChanceTypeId, request.TemplateId); err != nil {
|
296
|
log.Error(fmt.Sprintf("公司:%v chance_type_id:%v id:%v无模板 ", header.CompanyId, request.ChanceTypeId, request.TemplateId), err)
|
297
|
log.Error(fmt.Sprintf("公司:%v chance_type_id:%v id:%v无模板 ", header.CompanyId, request.ChanceTypeId, request.TemplateId), err)
|
297
|
return
|
298
|
return
|
298
|
}
|
299
|
}
|
299
|
- if request.ChanceId > 0 {
|
300
|
+ if request.ChanceId > 0 && !request.IsDraft {
|
300
|
if chance, err = models.GetChanceById(request.ChanceId); err == nil {
|
301
|
if chance, err = models.GetChanceById(request.ChanceId); err == nil {
|
301
|
if chance.EnableStatus == 0 {
|
302
|
if chance.EnableStatus == 0 {
|
302
|
err = protocol.NewErrWithMessage(5101)
|
303
|
err = protocol.NewErrWithMessage(5101)
|
|
@@ -326,10 +327,18 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest) |
|
@@ -326,10 +327,18 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest) |
326
|
template.Link = fmt.Sprintf("%v/#/ability/opportunity?id=%v", beego.AppConfig.String("h5_host"), item.Id)
|
327
|
template.Link = fmt.Sprintf("%v/#/ability/opportunity?id=%v", beego.AppConfig.String("h5_host"), item.Id)
|
327
|
}
|
328
|
}
|
328
|
if request.ChanceId > 0 {
|
329
|
if request.ChanceId > 0 {
|
|
|
330
|
+ if request.IsDraft { //是否是机会草稿
|
|
|
331
|
+ if chanceDraft, err = models.GetChanceDraftById(request.ChanceId); err == nil {
|
|
|
332
|
+ var old []protocol.SelfCheck
|
|
|
333
|
+ utils.JsonUnmarshal(chanceDraft.SelfChecks, &old)
|
|
|
334
|
+ template.Questions = GetNewestCheckQuestions(chanceDraft.AuditTemplateId, old)
|
|
|
335
|
+ }
|
|
|
336
|
+ } else { //正常机会
|
329
|
if template.Questions, err = agg.GetCheckQuestionsByChanceId(header, request.ChanceId); err != nil {
|
337
|
if template.Questions, err = agg.GetCheckQuestionsByChanceId(header, request.ChanceId); err != nil {
|
330
|
log.Error(err)
|
338
|
log.Error(err)
|
331
|
return
|
339
|
return
|
332
|
}
|
340
|
}
|
|
|
341
|
+ }
|
333
|
} else {
|
342
|
} else {
|
334
|
if template.Questions, err = agg.GetCheckQuestionsByTemplateId(templates.Id); err != nil {
|
343
|
if template.Questions, err = agg.GetCheckQuestionsByTemplateId(templates.Id); err != nil {
|
335
|
log.Error(err)
|
344
|
log.Error(err)
|
|
@@ -2043,6 +2052,60 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail |
|
@@ -2043,6 +2052,60 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail |
2043
|
return
|
2052
|
return
|
2044
|
}
|
2053
|
}
|
2045
|
|
2054
|
|
|
|
2055
|
+func ChanceDraftDetail(header *protocol.RequestHeader, request *protocol.ChanceDetailRequest) (rsp *protocol.ChanceDetailResponse, err error) {
|
|
|
2056
|
+ var (
|
|
|
2057
|
+ chance *models.ChanceDraft
|
|
|
2058
|
+ chanceData *models.ChanceData
|
|
|
2059
|
+ provider *protocol.BaseUserInfo
|
|
|
2060
|
+ )
|
|
|
2061
|
+ rsp = &protocol.ChanceDetailResponse{}
|
|
|
2062
|
+ if chance, err = models.GetChanceDraftById(request.Id); err != nil {
|
|
|
2063
|
+ if err == orm.ErrNoRows {
|
|
|
2064
|
+ err = protocol.NewErrWithMessage(5101)
|
|
|
2065
|
+ return
|
|
|
2066
|
+ }
|
|
|
2067
|
+ log.Error(err)
|
|
|
2068
|
+ return
|
|
|
2069
|
+ }
|
|
|
2070
|
+ //用户信息
|
|
|
2071
|
+ if provider, err = agg.GetUserBaseInfo(chance.UserId, header.CompanyId); err != nil {
|
|
|
2072
|
+ log.Error(err)
|
|
|
2073
|
+ return
|
|
|
2074
|
+ }
|
|
|
2075
|
+ if template, e := models.GetAuditTemplateById(chance.AuditTemplateId); e == nil {
|
|
|
2076
|
+ rsp.ChanceTemplate = protocol.NameItem{
|
|
|
2077
|
+ Id: int(template.Id),
|
|
|
2078
|
+ Name: template.Name,
|
|
|
2079
|
+ }
|
|
|
2080
|
+ }
|
|
|
2081
|
+ if chanceType, e := models.GetChanceTypeById(chance.ChanceTypeId); e == nil {
|
|
|
2082
|
+ rsp.ChanceType = protocol.NameItem{
|
|
|
2083
|
+ Id: int(chanceType.Id),
|
|
|
2084
|
+ Name: chanceType.Name,
|
|
|
2085
|
+ }
|
|
|
2086
|
+ }
|
|
|
2087
|
+ item := protocol.ChanceItem{
|
|
|
2088
|
+ Id: chance.Id,
|
|
|
2089
|
+ Provider: provider,
|
|
|
2090
|
+ CreateTime: chance.CreateAt.Unix() * 1000,
|
|
|
2091
|
+ UpdateTime: chance.UpdateAt.Unix() * 1000,
|
|
|
2092
|
+ }
|
|
|
2093
|
+ jsonUnmarshal(chance.SourceContent, &item.FormList)
|
|
|
2094
|
+ jsonUnmarshal(chance.SelfChecks, &item.SelfChecks)
|
|
|
2095
|
+ item.FormList = clearEmptyForm(item.FormList)
|
|
|
2096
|
+
|
|
|
2097
|
+ if chanceData, err = models.GetChanceDataByChanceId(chance.Id); err == nil {
|
|
|
2098
|
+ if len(chanceData.Videos) > 0 {
|
|
|
2099
|
+ chanceData.Videos = strings.ReplaceAll(chanceData.Videos, "https", "http")
|
|
|
2100
|
+ }
|
|
|
2101
|
+ jsonUnmarshal(chanceData.Images, &item.Pictures)
|
|
|
2102
|
+ jsonUnmarshal(chanceData.Speechs, &item.Speechs)
|
|
|
2103
|
+ jsonUnmarshal(chanceData.Videos, &item.Videos)
|
|
|
2104
|
+ }
|
|
|
2105
|
+ rsp.ChanceDetail = item
|
|
|
2106
|
+ return
|
|
|
2107
|
+}
|
|
|
2108
|
+
|
2046
|
//机会删除
|
2109
|
//机会删除
|
2047
|
func ChanceDelete(header *protocol.RequestHeader, request *protocol.ChanceDeleteRequest) (rsp *protocol.ChanceDeleteResponse, err error) {
|
2110
|
func ChanceDelete(header *protocol.RequestHeader, request *protocol.ChanceDeleteRequest) (rsp *protocol.ChanceDeleteResponse, err error) {
|
2048
|
var (
|
2111
|
var (
|
|
@@ -2408,11 +2471,11 @@ func DraftByChance(header *protocol.RequestHeader, request *protocol.DraftByChan |
|
@@ -2408,11 +2471,11 @@ func DraftByChance(header *protocol.RequestHeader, request *protocol.DraftByChan |
2408
|
commItem.Chance.RelatedDepartmentInfo = agg.GetDepartment(ormItem.DepartmentId)
|
2471
|
commItem.Chance.RelatedDepartmentInfo = agg.GetDepartment(ormItem.DepartmentId)
|
2409
|
commItem.Chance.ApproveTime = 0
|
2472
|
commItem.Chance.ApproveTime = 0
|
2410
|
|
2473
|
|
2411
|
- commItem.Chance.FormList = GetNewestFormList(header, ormItem.ChanceTypeId, ormItem.TemplateId, commItem.Chance.FormList)
|
2474
|
+ //commItem.Chance.FormList = GetNewestFormList(header, ormItem.ChanceTypeId, ormItem.TemplateId, commItem.Chance.FormList)
|
2412
|
if len(ormItem.SelfChecks) > 0 {
|
2475
|
if len(ormItem.SelfChecks) > 0 {
|
2413
|
utils.JsonUnmarshal(ormItem.SelfChecks, &commItem.Chance.SelfChecks)
|
2476
|
utils.JsonUnmarshal(ormItem.SelfChecks, &commItem.Chance.SelfChecks)
|
2414
|
}
|
2477
|
}
|
2415
|
- commItem.Chance.SelfChecks = GetNewestSelfChecks(int64(ormItem.TemplateId), commItem.Chance.SelfChecks)
|
2478
|
+ //commItem.Questions = GetNewestCheckQuestions(int64(ormItem.TemplateId), commItem.Chance.SelfChecks)
|
2416
|
rsp.List = append(rsp.List, commItem)
|
2479
|
rsp.List = append(rsp.List, commItem)
|
2417
|
}
|
2480
|
}
|
2418
|
return
|
2481
|
return
|
|
@@ -2445,31 +2508,20 @@ func getNewestFormList(new []*protocol.Form, old []*protocol.Form) []*protocol.F |
|
@@ -2445,31 +2508,20 @@ func getNewestFormList(new []*protocol.Form, old []*protocol.Form) []*protocol.F |
2445
|
}
|
2508
|
}
|
2446
|
|
2509
|
|
2447
|
//获取最新的自查列表
|
2510
|
//获取最新的自查列表
|
2448
|
-func GetNewestSelfChecks(tpId int64, old []protocol.SelfCheck) protocol.SelfChecks {
|
|
|
2449
|
- var new []protocol.SelfCheck = make([]protocol.SelfCheck, 0)
|
2511
|
+func GetNewestCheckQuestions(tpId int64, old []protocol.SelfCheck) []*protocol.CheckQuestion {
|
|
|
2512
|
+ var rsp = []*protocol.CheckQuestion{}
|
2450
|
if questions, err := agg.GetCheckQuestionsByTemplateId(tpId); err != nil {
|
2513
|
if questions, err := agg.GetCheckQuestionsByTemplateId(tpId); err != nil {
|
2451
|
log.Error(err)
|
2514
|
log.Error(err)
|
2452
|
- return old
|
2515
|
+ return rsp
|
2453
|
} else {
|
2516
|
} else {
|
2454
|
- for i := range questions {
|
|
|
2455
|
- q := questions[i]
|
|
|
2456
|
- new = append(new, protocol.SelfCheck{
|
|
|
2457
|
- Id: q.Id,
|
|
|
2458
|
- ParentId: q.ParentId,
|
|
|
2459
|
- CheckItem: q.CheckItem,
|
|
|
2460
|
- GroupId: q.GroupId,
|
|
|
2461
|
- Answer: q.Answer,
|
|
|
2462
|
- Reason: q.Reason,
|
|
|
2463
|
- })
|
|
|
2464
|
- }
|
2517
|
+ getNewestSelfChecks(questions, old)
|
|
|
2518
|
+ rsp = questions
|
2465
|
}
|
2519
|
}
|
2466
|
- new = getNewestSelfChecks(new, old)
|
|
|
2467
|
- protocol.SelfChecks(new).SetSelfChecksLevel1ByRule()
|
|
|
2468
|
- return new
|
2520
|
+ return rsp
|
2469
|
}
|
2521
|
}
|
2470
|
-func getNewestSelfChecks(new []protocol.SelfCheck, old []protocol.SelfCheck) []protocol.SelfCheck {
|
2522
|
+func getNewestSelfChecks(new []*protocol.CheckQuestion, old []protocol.SelfCheck) {
|
2471
|
if len(new) == 0 {
|
2523
|
if len(new) == 0 {
|
2472
|
- return old
|
2524
|
+ return
|
2473
|
}
|
2525
|
}
|
2474
|
for i := 0; i < len(new); i++ {
|
2526
|
for i := 0; i < len(new); i++ {
|
2475
|
itemNew := new[i]
|
2527
|
itemNew := new[i]
|
|
@@ -2482,5 +2534,5 @@ func getNewestSelfChecks(new []protocol.SelfCheck, old []protocol.SelfCheck) []p |
|
@@ -2482,5 +2534,5 @@ func getNewestSelfChecks(new []protocol.SelfCheck, old []protocol.SelfCheck) []p |
2482
|
}
|
2534
|
}
|
2483
|
}
|
2535
|
}
|
2484
|
}
|
2536
|
}
|
2485
|
- return new
|
2537
|
+ return
|
2486
|
} |
2538
|
} |