فهرست منبع

Merge branch 'ETA_2.1.6' into debug

# Conflicts:
#	services/data/chart_classify.go
zwxi 6 ماه پیش
والد
کامیت
4d595714a2

+ 1 - 1
controllers/data_manage/chart_classify.go

@@ -1147,7 +1147,7 @@ func (this *ChartClassifyController) ChartClassifyChartListV3() {
 			item.Button.AddButton = false
 			item.Button.OpButton = false
 			item.Button.DeleteButton = false
-			item.Button.MoveButton = false
+			item.Button.MoveButton = true
 		}
 		allNodes[k] = item
 	}

+ 48 - 12
controllers/data_manage/chart_info.go

@@ -4626,14 +4626,32 @@ func (this *ChartInfoController) ChartList() {
 			condition += " AND chart_classify_id IN(" + chartClassifyId + ") "
 			//pars = append(pars, chartClassifyId)
 		} else {
-			chartClassifyId, err := data_manage.GetChartClassifyByIds(chartClassifyIds)
-			if err != nil && err.Error() != utils.ErrNoRow() {
-				br.Msg = "获取图表信息失败"
-				br.ErrMsg = "获取信息失败,GetChartClassify,Err:" + err.Error()
+			//chartClassifyId, err := data_manage.GetChartClassifyByIds(chartClassifyIds)
+			//if err != nil && err.Error() != utils.ErrNoRow() {
+			//	br.Msg = "获取图表信息失败"
+			//	br.ErrMsg = "获取信息失败,GetChartClassify,Err:" + err.Error()
+			//	return
+			//}
+			//condition += " AND chart_classify_id IN(" + chartClassifyId + ") "
+			//pars = append(pars, chartClassifyId)
+
+			list, e := data_manage.GetChartClassifyAllBySource(utils.CHART_SOURCE_DEFAULT)
+			if e != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = fmt.Sprintf("获取图表分类失败, Err: %v", e)
 				return
 			}
-			condition += " AND chart_classify_id IN(" + chartClassifyId + ") "
-			//pars = append(pars, chartClassifyId)
+			finalClassifyIds := make([]int, 0)
+			parents := data.GetChartClassifyChildrenRecursiveByParentIds(list, chartClassifyIds)
+			sort.Slice(parents, func(i, j int) bool {
+				return parents[i].Level < parents[i].Level
+			})
+			for _, v := range parents {
+				finalClassifyIds = append(finalClassifyIds, v.ChartClassifyId)
+			}
+
+			condition += " AND chart_classify_id IN(" + utils.GetOrmInReplace(len(finalClassifyIds)) + ") "
+			pars = append(pars, finalClassifyIds)
 		}
 	}
 	if keyWord != "" {
@@ -4880,14 +4898,32 @@ func (this *ChartInfoController) ModifyChartList() {
 				condition += " AND chart_classify_id IN(" + chartClassifyId + ") "
 				//pars = append(pars, chartClassifyId)
 			} else {
-				chartClassifyId, err := data_manage.GetChartClassifyByIds(chartClassifyIds)
-				if err != nil && err.Error() != utils.ErrNoRow() {
-					br.Msg = "获取图表信息失败"
-					br.ErrMsg = "获取信息失败,GetChartClassify,Err:" + err.Error()
+				//chartClassifyId, err := data_manage.GetChartClassifyByIds(chartClassifyIds)
+				//if err != nil && err.Error() != utils.ErrNoRow() {
+				//	br.Msg = "获取图表信息失败"
+				//	br.ErrMsg = "获取信息失败,GetChartClassify,Err:" + err.Error()
+				//	return
+				//}
+				//condition += " AND chart_classify_id IN(" + chartClassifyId + ") "
+				//pars = append(pars, chartClassifyId)
+
+				list, e := data_manage.GetChartClassifyAllBySource(utils.CHART_SOURCE_DEFAULT)
+				if e != nil {
+					br.Msg = "获取失败"
+					br.ErrMsg = fmt.Sprintf("获取图表分类失败, Err: %v", e)
 					return
 				}
-				condition += " AND chart_classify_id IN(" + chartClassifyId + ") "
-				//pars = append(pars, chartClassifyId)
+				finalClassifyIds := make([]int, 0)
+				parents := data.GetChartClassifyChildrenRecursiveByParentIds(list, chartClassifyIds)
+				sort.Slice(parents, func(i, j int) bool {
+					return parents[i].Level < parents[i].Level
+				})
+				for _, v := range parents {
+					finalClassifyIds = append(finalClassifyIds, v.ChartClassifyId)
+				}
+
+				condition += " AND chart_classify_id IN(" + utils.GetOrmInReplace(len(finalClassifyIds)) + ") "
+				pars = append(pars, finalClassifyIds)
 			}
 		}
 

+ 1 - 1
controllers/data_manage/my_chart.go

@@ -79,7 +79,7 @@ func (this *MyChartController) ChartList() {
 			br.ErrMsg = fmt.Sprintf("获取图表分类失败, Err: %v", e)
 			return
 		}
-		parents := data.GetChartClassifyParentRecursive(list, chartClassifyId)
+		parents := data.GetChartClassifyChildrenRecursive(list, chartClassifyId)
 		sort.Slice(parents, func(i, j int) bool {
 			return parents[i].Level < parents[i].Level
 		})

+ 36 - 0
services/data/chart_classify.go

@@ -1066,6 +1066,7 @@ func EditChartClassifyV2(chartClassifyId, praentId, source int, chartClassifyNam
 
 	return
 }
+
 // RemoveNotChartClassifyItemsMakeTree
 // @Description: 过滤名下没有自己图表的分类,并生成树形结构
 // @author: Roc
@@ -1089,3 +1090,38 @@ func RemoveNotChartClassifyItemsMakeTree(node *data_manage.ChartClassifyItems, s
 
 	return
 }
+
+// GetChartClassifyChildrenRecursive 根据父目录递归子级目录
+func GetChartClassifyChildrenRecursive(list []*data_manage.ChartClassifyItems, parentId int) []*data_manage.ChartClassifyItems {
+	var res []*data_manage.ChartClassifyItems
+
+	for _, v := range list {
+		if v.ParentId == parentId {
+			// 递归调用以获取更深层次的子级
+			children := GetChartClassifyChildrenRecursive(list, v.ChartClassifyId)
+			// 将当前节点和所有子节点添加到结果中
+			res = append(res, v)
+			res = append(res, children...)
+		}
+	}
+	return res
+}
+
+// GetChartClassifyChildrenRecursiveByParentIds 根据父目录递归子级目录
+func GetChartClassifyChildrenRecursiveByParentIds(list []*data_manage.ChartClassifyItems, parentIds []string) []*data_manage.ChartClassifyItems {
+	var res []*data_manage.ChartClassifyItems
+
+	for _, v := range list {
+		for _, id := range parentIds {
+			parentId, _ := strconv.Atoi(id)
+			if v.ParentId == parentId {
+				// 递归调用以获取更深层次的子级
+				children := GetChartClassifyChildrenRecursive(list, v.ChartClassifyId)
+				// 将当前节点和所有子节点添加到结果中
+				res = append(res, v)
+				res = append(res, children...)
+			}
+		}
+	}
+	return res
+}