浏览代码

解决冲突

kobe6258 1 月之前
父节点
当前提交
3f2dca32d9
共有 4 个文件被更改,包括 92 次插入35 次删除
  1. 52 25
      controllers/data_manage/chart_classify.go
  2. 21 10
      models/data_manage/excel/excel_info.go
  3. 18 0
      services/data/chart_classify.go
  4. 1 0
      utils/date_util.go

+ 52 - 25
controllers/data_manage/chart_classify.go

@@ -13,6 +13,12 @@ import (
 	"time"
 )
 
+const (
+	CHART_CLASSIFY_ADD_OR_EDIT = "chartLib:classifyOpt:add"
+	CHART_CLASSIFY_DELETE      = "chartLib:classifyOpt:delete"
+	CHART_CLASSIFY_MOVE        = "chartLib:classifyOpt:move"
+)
+
 // 数据管理-分类模块
 type ChartClassifyController struct {
 	controllers.BaseAuthController
@@ -1104,7 +1110,7 @@ func (this *ChartClassifyController) ChartClassifyChartListV3() {
 			noPermissionChartIdMap[v.ChartInfoId] = true
 		}
 	}
-
+	var allNodes []*data_manage.ChartClassifyItems
 	isShowMe, _ := this.GetBool("IsShowMe")
 	if isShowMe {
 		allChartInfo, err := data_manage.GetChartClassifyAndInfoByParentIdForMe(chartClassifyId, sysUser.AdminId)
@@ -1114,41 +1120,62 @@ func (this *ChartClassifyController) ChartClassifyChartListV3() {
 			return
 		}
 		// 移除没有权限的图表
-		allNodes := data.HandleNoPermissionChart(allChartInfo, noPermissionChartIdMap, this.SysUser.AdminId)
+		allNodes = data.HandleNoPermissionChart(allChartInfo, noPermissionChartIdMap, this.SysUser.AdminId)
 		allNodes, err = data.GetChartClassifyByIsMe(sysUser.AdminId, chartClassifyId, utils.CHART_SOURCE_DEFAULT, allNodes)
 		if err != nil {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
 			return
 		}
-		resp.AllNodes = allNodes
-
-		br.Ret = 200
-		br.Success = true
-		br.Msg = "获取成功"
-		br.Data = resp
-		fmt.Println("source my classify")
-		return
+		//resp.AllNodes = allNodes
+		//
+		//br.Ret = 200
+		//br.Success = true
+		//br.Msg = "获取成功"
+		//br.Data = resp
+		//fmt.Println("source my classify")
+		//return
+	} else {
+		allChartInfo, err := data_manage.GetChartClassifyAndInfoByParentId(chartClassifyId)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取数据失败,Err:" + err.Error()
+			return
+		}
+		//allChartInfo, err := data_manage.GetChartInfoAllByClassifyId(utils.CHART_SOURCE_DEFAULT, chartClassifyId)
+		//if err != nil && err.Error() != utils.ErrNoRow() {
+		//	br.Msg = "获取失败"
+		//	br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
+		//	return
+		//}
+		// 移除没有权限的图表
+		allNodes = data.HandleNoPermissionChart(allChartInfo, noPermissionChartIdMap, this.SysUser.AdminId)
 	}
-
-	allChartInfo, err := data_manage.GetChartClassifyAndInfoByParentId(chartClassifyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	menulist, e := system.GetMenuButtonsByRoleId(this.SysUser.RoleId)
+	if e != nil {
 		br.Msg = "获取失败"
-		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		br.ErrMsg = "获取角色按钮权限失败, Err: " + e.Error()
 		return
 	}
-
-	//allChartInfo, err := data_manage.GetChartInfoAllByClassifyId(utils.CHART_SOURCE_DEFAULT, chartClassifyId)
-	//if err != nil && err.Error() != utils.ErrNoRow() {
-	//	br.Msg = "获取失败"
-	//	br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
-	//	return
-	//}
-	// 移除没有权限的图表
-	allNodes := data.HandleNoPermissionChart(allChartInfo, noPermissionChartIdMap, this.SysUser.AdminId)
-
+	buttonList := make(map[string]int, 0)
+	for _, item := range menulist {
+		if item.MenuType == 1 {
+			buttonList[item.ButtonCode] = 1
+		}
+	}
+	var addOrEditRight, deleteRight, moveRight bool
+	if _, ok := buttonList[CHART_CLASSIFY_ADD_OR_EDIT]; ok {
+		addOrEditRight = true
+	}
+	if _, ok := buttonList[CHART_CLASSIFY_DELETE]; ok {
+		deleteRight = true
+	}
+	if _, ok := buttonList[CHART_CLASSIFY_MOVE]; ok {
+		moveRight = true
+	}
 	for k, item := range allNodes {
-		item.Button = data.GetChartOpButton(this.SysUser, item.SysUserId, item.HaveOperaAuth)
+		//item.Button = data.GetChartOpButton(this.SysUser, item.SysUserId, item.HaveOperaAuth)
+		item.Button = data.GetChartOpButtonV2(item.HaveOperaAuth, addOrEditRight, deleteRight, moveRight)
 		if item.ChartInfoId > 0 {
 			item.Button.AddButton = false
 			item.Button.OpButton = false

+ 21 - 10
models/data_manage/excel/excel_info.go

@@ -34,7 +34,8 @@ type ExcelInfo struct {
 	RelExcelInfoId     int       `description:"平衡表里静态表关联的动态表excel id"`
 	VersionName        string    `description:"静态表版本名称"`
 	SourcesFrom        string    `description:"图表来源"`
-	ExtraConfig        string    `description:"额外配置"`
+	//ExtraConfig        string    `description:"额外配置"`
+	ExtraConfig string `description:"额外配置:如多空分析、相关性表格参数"`
 }
 
 // Update 更新 excel表格基础信息
@@ -817,6 +818,16 @@ func UpdateExcelInfoClassifyIdByIds(classifyId int, excelIds []int) (err error)
 	return
 }
 
+// SearchExcelInfo 表格搜索
+type SearchExcelInfo struct {
+	ExcelInfo
+	SearchText    string                `description:"搜索结果(含高亮)"`
+	HaveOperaAuth bool                  `description:"是否有数据权限"`
+	Button        ExcelInfoDetailButton `description:"操作权限"`
+	CanEdit       bool                  `description:"是否可编辑"`
+	Editor        string                `description:"编辑人"`
+}
+
 func (m *ExcelInfo) Create() (err error) {
 	o := orm.NewOrmUsingDB("data")
 	id, err := o.Insert(m)
@@ -834,15 +845,15 @@ func (m *ExcelInfo) GetCountByCondition(condition string, pars []interface{}) (c
 	return
 }
 
-// SearchExcelInfo 表格搜索
-type SearchExcelInfo struct {
-	ExcelInfo
-	SearchText    string                `description:"搜索结果(含高亮)"`
-	HaveOperaAuth bool                  `description:"是否有数据权限"`
-	Button        ExcelInfoDetailButton `description:"操作权限"`
-	CanEdit       bool                  `description:"是否可编辑"`
-	Editor        string                `description:"编辑人"`
-}
+//// SearchExcelInfo 表格搜索
+//type SearchExcelInfo struct {
+//	ExcelInfo
+//	SearchText    string                `description:"搜索结果(含高亮)"`
+//	HaveOperaAuth bool                  `description:"是否有数据权限"`
+//	Button        ExcelInfoDetailButton `description:"操作权限"`
+//	CanEdit       bool                  `description:"是否可编辑"`
+//	Editor        string                `description:"编辑人"`
+//}
 
 // ExcelCommonExtraConfig 表格额外配置
 type ExcelCommonExtraConfig struct {

+ 18 - 0
services/data/chart_classify.go

@@ -171,6 +171,24 @@ func GetChartOpButton(sysUser *system.Admin, belongUserId int, haveOperaAuth boo
 
 	return
 }
+func GetChartOpButtonV2(haveOperaAuth, addOrEdit, delete, move bool) (button data_manage.ChartClassifyItemsButton) {
+	// 数据权限判断
+	if !haveOperaAuth {
+		return
+	}
+	//预测指标的添加人对该预测指标有全部操作权限,ficc管理员、超管对所有预测指标有全部操作权限;
+	if addOrEdit {
+		button.AddButton = true
+		button.OpButton = true
+	}
+	if delete {
+		button.DeleteButton = true
+	}
+	if move {
+		button.MoveButton = true
+	}
+	return
+}
 
 // HandleNoPermissionChart 图表列表返回,将没有权限的图表移除
 func HandleNoPermissionChart(allNodes []*data_manage.ChartClassifyItems, noPermissionChartIdMap map[int]bool, sysUserId int) (newAllNodes []*data_manage.ChartClassifyItems) {

+ 1 - 0
utils/date_util.go

@@ -43,6 +43,7 @@ func GetNextDay(date string) string {
 // GetNextDayN 获取 yyyy-MM-dd 类型的时间的下n天
 func GetNextDayN(date string, n int) string {
 	t, _ := time.ParseInLocation("2006-01-02", date, time.Local)
+	//t, _ := time.Parse("2006-01-02", date)
 	nextDay := t.AddDate(0, 0, n)
 	return nextDay.Format("2006-01-02")
 }