Browse Source

fix:修复指标库批量移动指标,,勾选了列表全选,选择的数量有没有超过100也会提示:最多选择100个的bug

Roc 1 week ago
parent
commit
04a8102e91
1 changed files with 42 additions and 4 deletions
  1. 42 4
      controllers/data_manage/edb_info.go

+ 42 - 4
controllers/data_manage/edb_info.go

@@ -6820,18 +6820,56 @@ func (this *EdbInfoController) ModifyEdbList() {
 			br.ErrMsg = "获取已授权分类id数据失败,Err:" + err.Error()
 			return
 		}
-		classifyIdsArr := make([]int, 0)
+
+		// 提交上来的分类id
+		tmpClassifyIdsArr := make([]int, 0)
 		for _, v := range classifyIds {
 			if v != `` {
 				id, _ := strconv.Atoi(v)
-				classifyIdsArr = append(classifyIdsArr, id)
+				tmpClassifyIdsArr = append(tmpClassifyIdsArr, id)
 			}
 		}
 
-		if len(permissionClassifyIdList) > 0 {
-			classifyIdsArr = utils.IntersectInt(permissionClassifyIdList, classifyIdsArr)
+		// 我有权限的分类id
+		classifyIdsArr := make([]int, 0)
+		if len(tmpClassifyIdsArr) > 0 {
+			classifyInfoList, err := data_manage.GetEdbClassifyByIdList(tmpClassifyIdsArr)
+			if err != nil && !utils.IsErrNoRow(err) {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取数据失败,Err:" + err.Error()
+				return
+			}
+
+			permissionClassifyIdMap := make(map[int]bool)
+			for _, classifyId := range permissionClassifyIdList {
+				permissionClassifyIdMap[classifyId] = true
+			}
+			for _, v := range classifyInfoList {
+				// 没有加入指标目录管控,那么就直接加入并进入下个循环
+				if v.IsJoinPermission == 0 {
+					classifyIdsArr = append(classifyIdsArr, v.ClassifyId)
+					continue
+				}
+
+				// 如果加入指标目录管控了,同时自己有权限,那么就加入
+				if _, ok := permissionClassifyIdMap[v.ClassifyId]; ok {
+					classifyIdsArr = append(classifyIdsArr, v.ClassifyId)
+					continue
+				}
+
+			}
 		}
 
+		if len(classifyIds) > 0 && len(classifyIdsArr) <= 0 {
+			br.Msg = `所选中的指标目录没有权限`
+			br.IsSendEmail = false
+			return
+		}
+
+		//if len(permissionClassifyIdList) > 0 {
+		//	classifyIdsArr = utils.IntersectInt(permissionClassifyIdList, classifyIdsArr)
+		//}
+
 		condition += " AND edb_info_type = 0 "
 		if len(classifyIdsArr) > 0 {
 			if !req.SubClassify {