Ver Fonte

移动端增加平衡表图 删除接口和表格刷新接口

xyxie há 9 meses atrás
pai
commit
cef3e559b6

+ 3 - 3
controllers/data_manage/chart_common.go

@@ -157,7 +157,7 @@ func (this *ChartInfoController) CommonChartInfoDetailFromUniqueCode() {
 		br.Msg = "获取成功"
 		br.Data = resp
 	case utils.CHART_SOURCE_BALANCE_EXCEL:
-		resp, isOk, msg, errMsg := getBalanceChartInfoDetailFromUniqueCode(chartInfo, isCache, sysUser)
+		resp, isOk, msg, errMsg := getBalanceChartInfoDetailFromUniqueCode(chartInfo, isCache, sysUser, this.Lang)
 		if !isOk {
 			br.Msg = msg
 			br.ErrMsg = errMsg
@@ -174,7 +174,7 @@ func (this *ChartInfoController) CommonChartInfoDetailFromUniqueCode() {
 	}
 }
 
-func getBalanceChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCache bool, sysUser *system.Admin) (resp *data_manage.ChartInfoDetailFromUniqueCodeResp, isOk bool, msg, errMsg string) {
+func getBalanceChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCache bool, sysUser *system.Admin, lang string) (resp *data_manage.ChartInfoDetailFromUniqueCodeResp, isOk bool, msg, errMsg string) {
 	resp = new(data_manage.ChartInfoDetailFromUniqueCodeResp)
 	resp, isOk, msg, errMsg = data.CheckBalanceChartCacheAndPermission(chartInfo, isCache, sysUser)
 	if isOk {
@@ -182,7 +182,7 @@ func getBalanceChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoVie
 	}
 	msg = `获取失败`
 	// 相关联指标
-	mappingListTmp, dataListMap, err, errMsg := excel.GetBalanceExcelChartSingle(chartInfo.ChartInfoId, 0, "")
+	mappingListTmp, dataListMap, err, errMsg := excel.GetBalanceExcelChartSingle(chartInfo.ChartInfoId, 0, lang)
 	if err != nil {
 		errMsg = "获取失败"
 		err = fmt.Errorf(" 获取图表,指标信息失败 Err:%s", err.Error())

+ 219 - 0
controllers/data_manage/excel/balance_table.go

@@ -0,0 +1,219 @@
+package excel
+
+import (
+	"encoding/json"
+	"errors"
+	"eta/eta_mobile/models"
+	"eta/eta_mobile/models/data_manage"
+	"eta/eta_mobile/models/data_manage/excel"
+	"eta/eta_mobile/models/data_manage/excel/request"
+	"eta/eta_mobile/models/data_manage/excel/response"
+	"eta/eta_mobile/services/data"
+	"eta/eta_mobile/services/data/data_manage_permission"
+	excelService "eta/eta_mobile/services/data/excel"
+	"eta/eta_mobile/utils"
+	"fmt"
+	"time"
+)
+
+// DeleteBalanceChart
+// @Title 删除平衡表图表
+// @Description 删除平衡表图表
+// @Param	request	body data_manage.DeleteChartClassifyReq true "type json string"
+// @Success 200 Ret=200 删除成功
+// @router /excel_info/balance/chart_del [post]
+func (c *ExcelInfoController) DeleteBalanceChart() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+
+	sysUser := c.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	var req data_manage.DeleteChartClassifyReq
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.ChartInfoId <= 0 {
+		br.Msg = "参数错误"
+		br.IsSendEmail = false
+		return
+	}
+	//删除图表
+	if req.ChartInfoId > 0 {
+		chartInfo, err := data_manage.GetChartInfoById(req.ChartInfoId)
+		if err != nil {
+			if err.Error() == utils.ErrNoRow() {
+				br.Msg = "图表已删除,请刷新页面"
+				br.ErrMsg = "指标不存在,Err:" + err.Error()
+				return
+			} else {
+				br.Msg = "删除失败"
+				br.ErrMsg = "删除失败,获取指标信息失败,Err:" + err.Error()
+				return
+			}
+		}
+		if chartInfo == nil {
+			br.Msg = "图表已删除,请刷新页面"
+			return
+		}
+
+		// 操作权限校验, 增加协作人判断
+		{
+			// 获取表格信息
+			excelInfo, e := excel.GetExcelInfoByChartInfoId(req.ChartInfoId)
+			if e != nil {
+				br.Msg = "获取ETA表格失败"
+				return
+			}
+			checkExcelInfo := excelInfo
+			if excelInfo.Source == utils.BALANCE_TABLE {
+				checkExcelInfoId := excelInfo.ExcelInfoId
+				if excelInfo.BalanceType == 1 {
+					checkExcelInfoId = excelInfo.RelExcelInfoId
+				} else {
+					if excelInfo.ParentId > 0 {
+						checkExcelInfoId = excelInfo.ParentId
+					}
+				}
+				if checkExcelInfoId != excelInfo.ExcelInfoId {
+					checkExcelInfo, e = excel.GetExcelInfoById(checkExcelInfoId)
+					if e != nil {
+						br.Msg = "获取平衡表格信息失败"
+						br.ErrMsg = "获取平衡表格信息失败,Err:" + e.Error()
+						return
+					}
+				}
+			}
+			// 数据权限
+			haveOperaAuth, e := data_manage_permission.CheckExcelPermissionByExcelInfoId(checkExcelInfo.ExcelInfoId, checkExcelInfo.ExcelClassifyId, checkExcelInfo.IsJoinPermission, c.SysUser.AdminId)
+			if e != nil {
+				br.Msg = "获取ETA表格权限失败"
+				br.ErrMsg = "获取表格权限信息失败,Err" + e.Error()
+				return
+			}
+
+			button := excelService.GetBalanceExcelInfoOpButton(sysUser.AdminId, checkExcelInfo.SysUserId, haveOperaAuth, checkExcelInfo.ExcelInfoId)
+			if !button.OpButton {
+				br.Msg = "无操作权限"
+				br.IsSendEmail = false
+				return
+			}
+		}
+
+		// 获取引用该图表的MyCharts, 用于ES删除
+		var myCond string
+		var myPars []interface{}
+		myCond += ` AND a.chart_info_id = ? `
+		myPars = append(myPars, req.ChartInfoId)
+		myCharts, e := data_manage.GetMyChartListGroupByCharyInfoIdAndAdminIdByCondition(myCond, myPars)
+		if e != nil {
+			br.Msg = "删除失败"
+			br.ErrMsg = "获取引用图表的MyChats失败, Err: " + e.Error()
+			return
+		}
+		myIds := make([]int, 0)
+		for _, m := range myCharts {
+			myIds = append(myIds, m.MyChartId)
+		}
+
+		//删除图表及关联指标
+		e = excel.DeleteBalanceExcelChartInfoAndData(req.ChartInfoId)
+		if e != nil {
+			br.Msg = "删除失败"
+			br.ErrMsg = "删除失败,Err:" + e.Error()
+			return
+		}
+		//删除ES
+		{
+			go data.EsDeleteChartInfo(req.ChartInfoId)
+			// 删除MY ETA 图表 es数据
+			//go data.EsDeleteMyChartInfoByChartInfoId(req.ChartInfoId)
+			go data.EsDeleteMyChartInfoByMyChartIds(myIds)
+		}
+
+		//新增操作日志
+		{
+			chartLog := new(data_manage.ChartInfoLog)
+			chartLog.ChartName = chartInfo.ChartName
+			chartLog.ChartInfoId = req.ChartInfoId
+			chartLog.ChartClassifyId = chartInfo.ChartClassifyId
+			chartLog.SysUserId = sysUser.AdminId
+			chartLog.SysUserRealName = sysUser.RealName
+			chartLog.UniqueCode = chartInfo.UniqueCode
+			chartLog.CreateTime = time.Now()
+			chartLog.Content = string(c.Ctx.Input.RequestBody)
+			chartLog.Status = "删除图表"
+			chartLog.Method = c.Ctx.Input.URI()
+			go data_manage.AddChartInfoLog(chartLog)
+		}
+	}
+	br.Ret = 200
+	br.Msg = "删除成功"
+	br.Success = true
+	br.IsAddLog = true
+}
+
+func refreshBalanceTable(excelDetail response.ExcelInfoDetail, lang string) (err error) {
+	//查询所有子表
+	cCondition := " AND parent_id = ? AND balance_type=0"
+	var cPars []interface{}
+	cPars = append(cPars, excelDetail.ExcelInfoId)
+	childList, e := excel.GetExcelInfoListByCondition(cCondition, cPars)
+	if e != nil {
+		err = fmt.Errorf("获取子表失败 %s", err.Error())
+		return
+	}
+	edbInfoIds := make([]int, 0)
+	edbInfoIdExist := make(map[int]bool)
+	// 遍历
+	for _, child := range childList {
+		var result request.MixedTableReq
+		err = json.Unmarshal([]byte(child.Content), &result)
+		if err != nil {
+			err = errors.New("表格json转结构体失败,Err:" + err.Error())
+			return
+		}
+		newData, tmpErr, _ := excelService.GetMixedTableCellData(result, lang)
+		if tmpErr != nil {
+			err = tmpErr
+			return
+		}
+		if len(newData) > 0 {
+			for _, t := range newData {
+				for _, v := range t {
+					if v.EdbInfoId > 0 && !edbInfoIdExist[v.EdbInfoId] {
+						edbInfoIdExist[v.EdbInfoId] = true
+						edbInfoIds = append(edbInfoIds, v.EdbInfoId)
+					}
+				}
+			}
+		}
+
+		// 清除缓存
+		key := utils.HZ_CHART_LIB_EXCEL_TABLE_DETAIL + ":" + child.UniqueCode
+		if utils.Re == nil {
+			_ = utils.Rc.Delete(key)
+		}
+	}
+
+	if len(edbInfoIds) > 0 {
+		e, _ = data.EdbInfoRefreshAllFromBaseV3(edbInfoIds, false, true, false)
+		if e != nil {
+			err = fmt.Errorf("刷新混合表格数据失败, Err: " + err.Error())
+			return
+		}
+	}
+	return
+}

+ 27 - 2
controllers/data_manage/excel/excel_info.go

@@ -1915,13 +1915,25 @@ func (c *ExcelInfoController) Refresh() {
 	}
 
 	excelInfoId, _ := c.GetInt("ExcelInfoId")
-	if excelInfoId <= 0 {
+	chartInfoId, _ := c.GetInt("ChartInfoId")
+	if excelInfoId <= 0 && chartInfoId <= 0 {
 		br.Msg = "请选择表格"
 		br.ErrMsg = "ExcelInfoId未传"
 		br.IsSendEmail = false
 		return
 	}
 
+	// todo 如果请求入参是chart_info_id,则需要获取excel_info_id
+	if chartInfoId > 0 && excelInfoId == 0 {
+		excelInfo, err := excel3.GetExcelInfoByChartInfoId(chartInfoId)
+		if err != nil {
+			br.Msg = "请选择表格"
+			br.ErrMsg = "未找到对应的表格"
+			br.IsSendEmail = false
+			return
+		}
+		excelInfoId = excelInfo.ExcelInfoId
+	}
 	// 获取数据详情
 	excelDetail, errMsg, err := excel2.GetExcelDetailInfoByExcelInfoId(excelInfoId, c.SysUser.AdminId, c.Lang)
 	if err != nil {
@@ -1932,7 +1944,10 @@ func (c *ExcelInfoController) Refresh() {
 
 	// 操作权限校验
 	{
-		button := excel2.GetExcelInfoOpButton(sysUser, excelDetail.SysUserId, excelDetail.Source, excelDetail.HaveOperaAuth)
+		button := excelDetail.Button
+		if excelDetail.Source != utils.BALANCE_TABLE {
+			button = excel2.GetExcelInfoOpButton(sysUser, excelDetail.SysUserId, excelDetail.Source, excelDetail.HaveOperaAuth)
+		}
 		if !button.RefreshButton {
 			br.Msg = "无操作权限"
 			br.IsSendEmail = false
@@ -1968,6 +1983,7 @@ func (c *ExcelInfoController) Refresh() {
 
 	// 数据刷新-混合表格
 	if excelDetail.Source == utils.MIXED_TABLE {
+		// todo 刷新动态表的所有子表中关联的指标数据
 		jsonByte, e := json.Marshal(excelDetail.TableData)
 		if e != nil {
 			br.Msg = "刷新失败"
@@ -2002,6 +2018,15 @@ func (c *ExcelInfoController) Refresh() {
 		}
 	}
 
+	if excelDetail.Source == utils.BALANCE_TABLE {
+		err = refreshBalanceTable(excelDetail, c.Lang)
+		if err != nil {
+			br.Msg = "刷新失败"
+			br.ErrMsg = "刷新失败,Err:" + err.Error()
+			return
+		}
+	}
+
 	// 清除缓存
 	key := utils.HZ_CHART_LIB_EXCEL_TABLE_DETAIL + ":" + excelDetail.UniqueCode
 	if utils.Re == nil {

+ 23 - 0
models/data_manage/excel/excel_info.go

@@ -267,6 +267,17 @@ func GetExcelInfoByUniqueCode(uniqueCode string) (item *ExcelInfo, err error) {
 	return
 }
 
+func GetExcelInfoListByCondition(condition string, pars []interface{}) (items []*ExcelInfo, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := ` SELECT * FROM excel_info WHERE 1=1 AND is_delete=0 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` ORDER BY sort asc, excel_info_id asc`
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
 // GetFirstExcelInfoByClassifyId 获取当前分类下,且排序数相同 的排序第一条的数据
 func GetFirstExcelInfoByClassifyId(classifyId int) (item *ExcelInfo, err error) {
 	o := orm.NewOrmUsingDB("data")
@@ -629,3 +640,15 @@ func ModifyExcelInfoUserIdByOldUserId(oldUserIdList []int, userId int, userName
 	_, err = o.Raw(sql, userId, userName, oldUserIdList).Exec()
 	return
 }
+
+// ExcelInfoDetailButton 操作按钮
+type ExcelInfoDetailButton struct {
+	RefreshButton    bool `description:"是否可刷新"`
+	CopyButton       bool `description:"是否可另存为"`
+	DownloadButton   bool `description:"是否可下载"`
+	OpButton         bool `description:"是否可编辑"`
+	DeleteButton     bool `description:"是否可删除"`
+	OpEdbButton      bool `description:"是否可生成指标"`
+	RefreshEdbButton bool `description:"是否可刷新指标"`
+	OpWorkerButton   bool `description:"是否修改协作人"`
+}

+ 82 - 0
models/data_manage/excel/excel_worker.go

@@ -0,0 +1,82 @@
+package excel
+
+import (
+	"eta/eta_mobile/utils"
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type ExcelWorker struct {
+	ExcelWorkerId   int       `orm:"column(excel_worker_id);pk"`
+	ExcelInfoId     int       `description:"表格id"`
+	SysUserId       int       `description:"创建人"`
+	SysUserRealName string    `description:"创建人姓名"`
+	ModifyTime      time.Time `description:"修改时间"`
+	CreateTime      time.Time `description:"创建时间"`
+}
+
+func (e *ExcelWorker) TableName() string {
+	return "excel_worker"
+}
+
+// 新增 协作人
+func (e *ExcelWorker) AddWorker(excelInfoId int, addWorkers []*ExcelWorker, notDeleteWorkers []string) (err error) {
+	o, err := orm.NewOrmUsingDB("data").Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err != nil {
+			_ = o.Rollback()
+		} else {
+			_ = o.Commit()
+		}
+	}()
+	if len(notDeleteWorkers) > 0 {
+		sql := `delete from excel_worker where excel_info_id = ? and sys_user_id not in (` + utils.GetOrmInReplace(len(notDeleteWorkers)) + `)`
+		_, err = o.Raw(sql, excelInfoId, notDeleteWorkers).Exec()
+		if err != nil {
+			return
+		}
+	} else if len(notDeleteWorkers) == 0 { // 清空协作人
+		sql := `delete from excel_worker where excel_info_id = ? `
+		_, err = o.Raw(sql, excelInfoId).Exec()
+		if err != nil {
+			return
+		}
+	}
+	if len(addWorkers) > 0 {
+		_, err = o.InsertMulti(len(addWorkers), addWorkers)
+	}
+	return
+}
+
+// 修改
+func (e *ExcelWorker) Update(cols []string) (err error) {
+	o := orm.NewOrmUsingDB("data")
+	_, err = o.Update(e, cols...)
+	return
+}
+
+// 删除
+func (e *ExcelWorker) Delete() (err error) {
+	o := orm.NewOrmUsingDB("data")
+	_, err = o.Delete(e)
+	return
+}
+
+// 查询
+func (e *ExcelWorker) GetByExcelInfoId(excelInfoId int) (items []*ExcelWorker, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := `select * from excel_worker where excel_info_id = ? `
+	_, err = o.Raw(sql, excelInfoId).QueryRows(&items)
+	return
+}
+
+// 查询
+func (e *ExcelWorker) GetBySysUserId(sysUserId int) (items []*ExcelWorker, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := `select * from excel_worker where sys_user_id = ? `
+	_, err = o.Raw(sql, sysUserId).QueryRows(&items)
+	return
+}

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

@@ -56,27 +56,27 @@ type TableDetailResp struct {
 
 // ExcelInfoDetail excel表格详情(前端使用)
 type ExcelInfoDetail struct {
-	ExcelInfoId      int                   `orm:"column(excel_info_id);pk"`
-	Source           int                   `description:"表格来源,1:excel插件的表格,2:自定义表格,默认:1"`
-	ExcelType        int                   `description:"表格类型,1:指标列,2:日期列,默认:1"`
-	ExcelName        string                `description:"表格名称"`
-	UniqueCode       string                `description:"表格唯一编码"`
-	ExcelClassifyId  int                   `description:"表格分类id"`
-	SysUserId        int                   `description:"操作人id"`
-	SysUserRealName  string                `description:"操作人真实姓名"`
-	Content          string                `description:"表格内容"`
-	ExcelImage       string                `description:"表格图片"`
-	FileUrl          string                `description:"表格下载地址"`
-	Sort             int                   `description:"排序字段,数字越小越排前面"`
-	IsDelete         int                   `description:"是否删除,0:未删除,1:已删除"`
-	ModifyTime       time.Time             `description:"最近修改日期"`
-	CreateTime       time.Time             `description:"创建日期"`
-	TableData        interface{}           `description:"表格内容"`
-	Button           ExcelInfoDetailButton `description:"操作权限"`
-	CanEdit          bool                  `description:"是否可编辑"`
-	Editor           string                `description:"编辑人"`
-	IsJoinPermission int                   `description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
-	HaveOperaAuth    bool                  `description:"是否有数据权限"`
+	ExcelInfoId      int                          `orm:"column(excel_info_id);pk"`
+	Source           int                          `description:"表格来源,1:excel插件的表格,2:自定义表格,默认:1"`
+	ExcelType        int                          `description:"表格类型,1:指标列,2:日期列,默认:1"`
+	ExcelName        string                       `description:"表格名称"`
+	UniqueCode       string                       `description:"表格唯一编码"`
+	ExcelClassifyId  int                          `description:"表格分类id"`
+	SysUserId        int                          `description:"操作人id"`
+	SysUserRealName  string                       `description:"操作人真实姓名"`
+	Content          string                       `description:"表格内容"`
+	ExcelImage       string                       `description:"表格图片"`
+	FileUrl          string                       `description:"表格下载地址"`
+	Sort             int                          `description:"排序字段,数字越小越排前面"`
+	IsDelete         int                          `description:"是否删除,0:未删除,1:已删除"`
+	ModifyTime       time.Time                    `description:"最近修改日期"`
+	CreateTime       time.Time                    `description:"创建日期"`
+	TableData        interface{}                  `description:"表格内容"`
+	Button           excel2.ExcelInfoDetailButton `description:"操作权限"`
+	CanEdit          bool                         `description:"是否可编辑"`
+	Editor           string                       `description:"编辑人"`
+	IsJoinPermission int                          `description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
+	HaveOperaAuth    bool                         `description:"是否有数据权限"`
 }
 
 // ExcelInfoDetailButton 操作按钮

+ 17 - 17
models/data_manage/excel/response/sheet.go

@@ -14,21 +14,21 @@ type FindExcelInfoResp struct {
 
 // FindExcelInfo excel的数据详情
 type FindExcelInfo struct {
-	ExcelInfoId     int                   `orm:"column(excel_info_id);pk"`
-	Source          int                   `description:"表格来源,1:excel插件的表格,2:自定义表格,默认:1"`
-	ExcelType       int                   `description:"表格类型,1:指标列,2:日期列,默认:1"`
-	ExcelName       string                `description:"表格名称"`
-	UniqueCode      string                `description:"表格唯一编码"`
-	ExcelClassifyId int                   `description:"表格分类id"`
-	SysUserId       int                   `description:"操作人id"`
-	SysUserRealName string                `description:"操作人真实姓名"`
-	ExcelImage      string                `description:"表格图片"`
-	FileUrl         string                `description:"表格下载地址"`
-	Sort            int                   `description:"排序字段,数字越小越排前面"`
-	ModifyTime      time.Time             `description:"最近修改日期"`
-	CreateTime      time.Time             `description:"创建日期"`
-	Button          ExcelInfoDetailButton `description:"操作权限"`
-	CanEdit         bool                  `description:"是否可编辑"`
-	Editor          string                `description:"编辑人"`
-	HaveOperaAuth   bool                  `description:"是否有数据权限,默认:false"`
+	ExcelInfoId     int                         `orm:"column(excel_info_id);pk"`
+	Source          int                         `description:"表格来源,1:excel插件的表格,2:自定义表格,默认:1"`
+	ExcelType       int                         `description:"表格类型,1:指标列,2:日期列,默认:1"`
+	ExcelName       string                      `description:"表格名称"`
+	UniqueCode      string                      `description:"表格唯一编码"`
+	ExcelClassifyId int                         `description:"表格分类id"`
+	SysUserId       int                         `description:"操作人id"`
+	SysUserRealName string                      `description:"操作人真实姓名"`
+	ExcelImage      string                      `description:"表格图片"`
+	FileUrl         string                      `description:"表格下载地址"`
+	Sort            int                         `description:"排序字段,数字越小越排前面"`
+	ModifyTime      time.Time                   `description:"最近修改日期"`
+	CreateTime      time.Time                   `description:"创建日期"`
+	Button          excel.ExcelInfoDetailButton `description:"操作权限"`
+	CanEdit         bool                        `description:"是否可编辑"`
+	Editor          string                      `description:"编辑人"`
+	HaveOperaAuth   bool                        `description:"是否有数据权限,默认:false"`
 }

+ 62 - 1
services/data/chart_info_excel_balance.go

@@ -191,7 +191,7 @@ func GetBalanceExcelChartDetail(chartInfo *data_manage.ChartInfoView, mappingLis
 	}
 
 	// todo 平衡表图表操作权限平衡表表格的操作权限保持一致,前端未用到该按钮权限,故不处理
-	//chartInfo.IsEdit = CheckOpChartPermission(sysUser, chartInfo.SysUserId, chartInfo.HaveOperaAuth)
+	chartInfo.IsEdit, _ = GetBalanceExcelInfoOpButtonByChartInfoId(sysUser.AdminId, chartInfo.ChartInfoId, chartInfo.HaveOperaAuth)
 	chartInfo.Button = data_manage.ChartViewButton{
 		IsEdit:    chartInfo.IsEdit,
 		IsEnChart: chartInfo.IsEnChart,
@@ -659,3 +659,64 @@ func TransferChartEdbToEdbMappingFormat(chartInfoId, chartType int, mappingListT
 	}
 	return
 }
+
+// GetBalanceExcelInfoOpButtonByChartInfoId 获取图表权限
+func GetBalanceExcelInfoOpButtonByChartInfoId(sysUserId, chartInfoId int, chartHaveOperaAuth bool) (opButton bool, err error) {
+	// 如果没有数据权限,那么直接返回
+	if !chartHaveOperaAuth {
+		return
+	}
+	// 获取表格信息
+	excelInfo, e := excelModel.GetExcelInfoByChartInfoId(chartInfoId)
+	if e != nil {
+		err = fmt.Errorf("获取ETA表格失败 Err %s", e.Error())
+		return
+	}
+	checkExcelInfo := excelInfo
+	if excelInfo.Source == utils.BALANCE_TABLE {
+		checkExcelInfoId := excelInfo.ExcelInfoId
+		if excelInfo.BalanceType == 1 {
+			checkExcelInfoId = excelInfo.RelExcelInfoId
+		} else {
+			if excelInfo.ParentId > 0 {
+				checkExcelInfoId = excelInfo.ParentId
+			}
+		}
+		if checkExcelInfoId != excelInfo.ExcelInfoId {
+			checkExcelInfo, e = excelModel.GetExcelInfoById(checkExcelInfoId)
+			if e != nil {
+				err = fmt.Errorf("获取平衡表格信息失败,Err:" + e.Error())
+				return
+			}
+		}
+	} else {
+		return
+	}
+	// 数据权限
+	haveOperaAuth, e := data_manage_permission.CheckExcelPermissionByExcelInfoId(checkExcelInfo.ExcelInfoId, checkExcelInfo.ExcelClassifyId, checkExcelInfo.IsJoinPermission, sysUserId)
+	if e != nil {
+		err = fmt.Errorf("获取表格权限信息失败,Err" + e.Error())
+		return
+	}
+	// 如果没有数据权限,那么直接返回
+	if !haveOperaAuth {
+		return
+	}
+	//button := GetBalanceExcelInfoOpButton(sysUserId, checkExcelInfo.SysUserId, haveOperaAuth, checkExcelInfo.ExcelInfoId)
+
+	if sysUserId == checkExcelInfo.SysUserId {
+		opButton = true
+	} else {
+		obj := new(excelModel.ExcelWorker)
+		workerList, e := obj.GetByExcelInfoId(checkExcelInfo.ExcelInfoId)
+		if e == nil {
+			for _, v := range workerList {
+				if v.SysUserId == sysUserId {
+					opButton = true
+					break
+				}
+			}
+		}
+	}
+	return
+}

+ 33 - 0
services/data/excel/balance_table.go

@@ -362,3 +362,36 @@ func GetBalanceExcelChartSingle(chartInfoId, ChartEdbId int, lang string) (mappi
 	}
 	return
 }
+
+// GetBalanceExcelInfoOpButton 获取ETA平衡表格的操作权限
+func GetBalanceExcelInfoOpButton(sysUserId, parentSysUserId int, haveOperaAuth bool, parentExcelInfoId int) (button excelModel.ExcelInfoDetailButton) {
+	// 如果没有数据权限,那么直接返回
+	if !haveOperaAuth {
+		return
+	}
+	//非管理员角色查看其他用户创建的表格,可刷新、另存为、下载表格;
+	button.RefreshButton = true
+	button.CopyButton = true
+	button.DownloadButton = true
+
+	if sysUserId == parentSysUserId {
+		button.OpButton = true
+		button.RefreshEdbButton = true
+		button.OpWorkerButton = true
+		button.DeleteButton = true
+	} else {
+		obj := new(excelModel.ExcelWorker)
+		workerList, err := obj.GetByExcelInfoId(parentExcelInfoId)
+		if err == nil {
+			for _, v := range workerList {
+				if v.SysUserId == sysUserId {
+					button.OpButton = true
+					button.RefreshEdbButton = true
+					button.DeleteButton = true
+					break
+				}
+			}
+		}
+	}
+	return
+}

+ 24 - 2
services/data/excel/excel_info.go

@@ -55,8 +55,27 @@ func GetExcelDetailInfoByUnicode(unicode string, sysUserId int, lang string) (ex
 }
 
 func formatExcelInfo2Detail(excelInfo *excel.ExcelInfo, sysUserId int, lang string) (excelDetail response.ExcelInfoDetail, errMsg string, err error) {
+	checkExcelInfo := excelInfo
+	if excelInfo.Source == utils.BALANCE_TABLE {
+		checkExcelInfoId := excelInfo.ExcelInfoId
+		if excelInfo.BalanceType == 1 {
+			checkExcelInfoId = excelInfo.RelExcelInfoId
+		} else {
+			if excelInfo.ParentId > 0 {
+				checkExcelInfoId = excelInfo.ParentId
+			}
+		}
+		if checkExcelInfoId != excelInfo.ExcelInfoId {
+			checkExcelInfo, err = excel.GetExcelInfoById(checkExcelInfoId)
+			if err != nil {
+				errMsg = "获取平衡表格信息失败"
+				err = errors.New("获取平衡表格信息失败,Err:" + err.Error())
+				return
+			}
+		}
+	}
 	// 数据权限
-	haveOperaAuth, err := data_manage_permission.CheckExcelPermissionByExcelInfoId(excelInfo.ExcelInfoId, excelInfo.ExcelClassifyId, excelInfo.IsJoinPermission, sysUserId)
+	haveOperaAuth, err := data_manage_permission.CheckExcelPermissionByExcelInfoId(checkExcelInfo.ExcelInfoId, checkExcelInfo.ExcelClassifyId, checkExcelInfo.IsJoinPermission, sysUserId)
 	if err != nil {
 		err = errors.New("获取表格权限信息失败,Err" + err.Error())
 		return
@@ -153,11 +172,14 @@ func formatExcelInfo2Detail(excelInfo *excel.ExcelInfo, sysUserId int, lang stri
 		result.Data = newData
 		excelDetail.TableData = result
 	}
+	if excelDetail.Source == utils.BALANCE_TABLE {
+		excelDetail.Button = GetBalanceExcelInfoOpButton(sysUserId, checkExcelInfo.SysUserId, excelDetail.HaveOperaAuth, checkExcelInfo.ExcelInfoId)
+	}
 	return
 }
 
 // GetExcelInfoOpButton 获取ETA表格的操作权限
-func GetExcelInfoOpButton(sysUser *system.Admin, belongUserId, source int, haveOperaAuth bool) (button response.ExcelInfoDetailButton) {
+func GetExcelInfoOpButton(sysUser *system.Admin, belongUserId, source int, haveOperaAuth bool) (button excel.ExcelInfoDetailButton) {
 	// 如果没有数据权限,那么直接返回
 	if !haveOperaAuth {
 		return