Browse Source

Merge branch 'feature/eta1.8.5_excel_balance' into debug

xyxie 10 months ago
parent
commit
abaf0bde10

+ 32 - 6
controllers/data_manage/excel/excel_classify.go

@@ -67,11 +67,35 @@ func (this *ExcelClassifyController) List() {
 	// 获取二级分类
 	// 获取三级分类
 	// 根据来源获取所有excel表格(无内容)
-	allExcelInfo, err := excel.GetNoContentExcelInfoAll(source, showUserId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取表格信息失败,Err:" + err.Error()
-		return
+	allExcelInfo := make([]*excel.ExcelClassifyItems, 0)
+	if source == utils.BALANCE_TABLE {
+		//找到当前协作人相关的表格ID
+		obj := new(excel.ExcelWorker)
+		existList, err := obj.GetBySysUserId(this.SysUser.AdminId)
+		if err != nil {
+			br.Msg = "获取表格协作人失败!"
+			br.ErrMsg = "获取表格协作人失败,Err:" + err.Error()
+			return
+		}
+		var excelIds []int
+		if len(existList) > 0 {
+			for _, v := range existList {
+				excelIds = append(excelIds, v.ExcelInfoId)
+			}
+		}
+		allExcelInfo, err = excel.GetBalanceNoContentExcelInfoAll(source, excelIds)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取表格信息失败,Err:" + err.Error()
+			return
+		}
+	} else {
+		allExcelInfo, err = excel.GetNoContentExcelInfoAll(source, showUserId)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取表格信息失败,Err:" + err.Error()
+			return
+		}
 	}
 
 	// 获取所有有权限的指标和分类
@@ -88,7 +112,9 @@ func (this *ExcelClassifyController) List() {
 		if classifyInfo, ok := classifyMap[v.ExcelClassifyId]; ok {
 			v.HaveOperaAuth = data_manage_permission.CheckExcelPermissionByPermissionIdList(v.IsJoinPermission, classifyInfo.IsJoinPermission, v.ExcelInfoId, v.ExcelClassifyId, permissionEdbIdList, permissionClassifyIdList)
 		}
-
+		if source == utils.BALANCE_TABLE && isShowMe && !v.HaveOperaAuth { // 过滤我不可编辑的表格
+			continue
+		}
 		ExcelInfoMap[v.ExcelClassifyId] = append(ExcelInfoMap[v.ExcelClassifyId], v)
 	}
 

+ 17 - 2
models/data_manage/excel/excel_info.go

@@ -170,10 +170,25 @@ func GetNoContentExcelInfoAll(source, userId int) (items []*ExcelClassifyItems,
 		sql += ` AND sys_user_id = ? `
 		pars = append(pars, userId)
 	}
+	sql += `  ORDER BY sort asc,excel_info_id desc `
+	_, err = o.Raw(sql, pars...).QueryRows(&items)
+	return
+}
 
-	if source == utils.BALANCE_TABLE { //平衡表的列表只显示动态表的一级表(不显示子表和静态表)
-		sql += " AND parent_id = 0 AND balance_type=0 "
+// GetBalanceNoContentExcelInfoAll 获取不含content的平衡表表格列表 用于分类展示
+func GetBalanceNoContentExcelInfoAll(source int, excelInfoIds []int) (items []*ExcelClassifyItems, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := ` SELECT excel_info_id,excel_classify_id,excel_name AS excel_classify_name,
+             unique_code,sys_user_id,sys_user_real_name,sort,is_join_permission
+            FROM excel_info where is_delete=0 AND source = ?  AND parent_id = 0 AND balance_type=0 `
+
+	pars := []interface{}{source}
+
+	if len(excelInfoIds) > 0 {
+		sql += ` AND excel_info_id in (` + utils.GetOrmInReplace(len(excelInfoIds)) + `)`
+		pars = append(pars, excelInfoIds)
 	}
+
 	sql += `  ORDER BY sort asc,excel_info_id desc `
 	_, err = o.Raw(sql, pars...).QueryRows(&items)
 	return