Browse Source

fix:继承报告时,需要继承自由布局的内容

Roc 4 ngày trước cách đây
mục cha
commit
3e5c22a3dd
1 tập tin đã thay đổi với 9 bổ sung7 xóa
  1. 9 7
      services/report_v2.go

+ 9 - 7
services/report_v2.go

@@ -535,20 +535,22 @@ func getAddChapter(reportInfo *models.Report, minClassifyId, inheritReportId int
 		// 继承的报告章节内容
 		for i := 0; i < len(inheritReportChapters); i++ {
 			customChapter := inheritReportChapters[i]
+			// 继承的报告章节ID
+			inheritReportChapterId := customChapter.ReportChapterId
 
 			// 授权用户列表
-			tmpGrantList, ok := grantListMap[customChapter.ReportChapterId]
+			tmpGrantList, ok := grantListMap[inheritReportChapterId]
 			if !ok {
 				tmpGrantList = make([]*report.ReportChapterGrant, 0)
 			}
-			oldChapterIdGrantListMap[customChapter.ReportChapterId] = tmpGrantList
+			oldChapterIdGrantListMap[inheritReportChapterId] = tmpGrantList
 
 			// 关联品种列表
-			chapterPermissionList, ok := chapterPermissionListMap[customChapter.ReportChapterId]
+			chapterPermissionList, ok := chapterPermissionListMap[inheritReportChapterId]
 			if !ok {
 				chapterPermissionList = make([]*report.ReportChapterPermissionMapping, 0)
 			}
-			oldChapterPermissionListMap[customChapter.ReportChapterId] = chapterPermissionList
+			oldChapterPermissionListMap[inheritReportChapterId] = chapterPermissionList
 
 			// 判断该章节是否是系统章节,如果是的话,那就是需要额外创建的
 			if customChapter.TypeId > 0 {
@@ -573,7 +575,7 @@ func getAddChapter(reportInfo *models.Report, minClassifyId, inheritReportId int
 				ReportChapter:          customChapter,
 				GrantList:              tmpGrantList,
 				GrantPermissionList:    chapterPermissionList,
-				InheritReportChapterId: customChapter.ReportChapterId,
+				InheritReportChapterId: inheritReportChapterId,
 			}
 			customAddChapterList = append(customAddChapterList, customAddChapter)
 		}
@@ -754,7 +756,7 @@ func getAddChapter(reportInfo *models.Report, minClassifyId, inheritReportId int
 		chapterList = append(chapterList, addChapterItem)
 	}
 
-	for _, chapterItem := range chapterList {
+	for k, chapterItem := range chapterList {
 		reportFreeLayoutList, ok := chapterFreeLayoutListMap[chapterItem.InheritReportChapterId]
 		if ok {
 			tmpReportFreeLayoutList := make([]*report.ReportFreeLayout, 0)
@@ -771,7 +773,7 @@ func getAddChapter(reportInfo *models.Report, minClassifyId, inheritReportId int
 					ModifyTime:      time.Now(),
 				})
 			}
-			chapterItem.ReportChapterFreeLayoutList = tmpReportFreeLayoutList
+			chapterList[k].ReportChapterFreeLayoutList = tmpReportFreeLayoutList
 		}
 	}