balance_table.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. package excel
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "eta_gn/eta_api/models/data_manage"
  6. excelModel "eta_gn/eta_api/models/data_manage/excel"
  7. "eta_gn/eta_api/models/data_manage/excel/request"
  8. "eta_gn/eta_api/utils"
  9. "fmt"
  10. "github.com/xuri/excelize/v2"
  11. "strconv"
  12. "time"
  13. )
  14. // GetBalanceExcelData 将表格信息转化成指标数据
  15. func GetBalanceExcelData(excelDetail *excelModel.ExcelInfo, lang string) (newDataMap map[int]map[int]request.MixedTableCellDataReq, allRows, allCols int, err error, errMsg string) {
  16. var result request.MixedTableReq
  17. err = json.Unmarshal([]byte(excelDetail.Content), &result)
  18. if err != nil {
  19. err = errors.New("表格json转结构体失败,Err:" + err.Error())
  20. return
  21. }
  22. newData, tmpErr, tmpErrMsg := GetMixedTableCellData(result, lang)
  23. if tmpErr != nil {
  24. errMsg = "获取失败"
  25. if tmpErrMsg != `` {
  26. errMsg = tmpErrMsg
  27. }
  28. err = errors.New("获取最新的数据失败,Err:" + tmpErr.Error())
  29. return
  30. }
  31. allRows = len(newData)
  32. allCols = 0
  33. newDataMap = make(map[int]map[int]request.MixedTableCellDataReq)
  34. for r, row := range newData {
  35. tmp := len(row)
  36. if tmp > allCols {
  37. allCols = tmp
  38. }
  39. colMap := make(map[int]request.MixedTableCellDataReq)
  40. for c, col := range row {
  41. colMap[c] = col
  42. }
  43. newDataMap[r] = colMap
  44. }
  45. return
  46. }
  47. func GetBalanceExcelChartList(excelInfo *excelModel.ExcelInfo, lang string) (list []*data_manage.ChartInfoView, mappingListMap map[int][]*excelModel.ExcelChartEdb, dataListMap map[int][]*data_manage.EdbDataList, err error, errMsg string) {
  48. dataListMap = make(map[int][]*data_manage.EdbDataList)
  49. // 相关联指标
  50. mappingListTmp, err := excelModel.GetExcelChartEdbMappingByExcelInfoId(excelInfo.ExcelInfoId)
  51. if err != nil {
  52. errMsg = "获取失败"
  53. err = fmt.Errorf(" 获取图表,指标信息失败 Err:%s", err.Error())
  54. return
  55. }
  56. charInfoIds := make([]int, 0)
  57. mappingListMap = make(map[int][]*excelModel.ExcelChartEdb, 0)
  58. if excelInfo.BalanceType == 1 {
  59. for _, mapping := range mappingListTmp {
  60. mappingListMap[mapping.ChartInfoId] = append(mappingListMap[mapping.ChartInfoId], mapping)
  61. }
  62. //查询库里是否有值
  63. chartDataList, e := excelModel.GetExcelChartDataByExcelInfoId(excelInfo.ExcelInfoId)
  64. if e != nil {
  65. err = fmt.Errorf(" 获取图表,指标信息失败 Err:%s", e.Error())
  66. return
  67. }
  68. if len(chartDataList) > 0 {
  69. for _, v := range chartDataList {
  70. tmp := &data_manage.EdbDataList{
  71. EdbDataId: v.ExcelChartDataId,
  72. EdbInfoId: v.ExcelChartEdbId,
  73. DataTime: v.DataTime,
  74. DataTimestamp: v.DataTimestamp,
  75. Value: v.Value,
  76. }
  77. dataListMap[v.ExcelChartEdbId] = append(dataListMap[v.ExcelChartEdbId], tmp)
  78. }
  79. }
  80. } else {
  81. newExcelDataMap, excelAllRows, excelAllCols, e, msg := GetBalanceExcelData(excelInfo, lang)
  82. if e != nil {
  83. err = e
  84. errMsg = msg
  85. return
  86. }
  87. for _, mapping := range mappingListTmp {
  88. mappingListMap[mapping.ChartInfoId] = append(mappingListMap[mapping.ChartInfoId], mapping)
  89. er, ms := GetBalanceExcelEdbData(mapping, newExcelDataMap, dataListMap, excelAllRows, excelAllCols)
  90. if er != nil {
  91. utils.FileLog.Info(fmt.Sprintf(" 获取图表,指标信息失败 Err:%s, %s", er.Error(), ms))
  92. continue
  93. }
  94. }
  95. }
  96. for k, _ := range mappingListMap {
  97. charInfoIds = append(charInfoIds, k)
  98. }
  99. list = make([]*data_manage.ChartInfoView, 0)
  100. if len(charInfoIds) > 0 {
  101. chartInfoList, e := data_manage.GetChartInfoViewByIdList(charInfoIds)
  102. if e != nil {
  103. errMsg = "获取失败"
  104. err = fmt.Errorf(" 获取图表,指标信息失败 Err:%s", e.Error())
  105. return
  106. }
  107. list = chartInfoList
  108. }
  109. return
  110. }
  111. // GetBalanceExcelEdbData 将表格信息转化成指标数据
  112. func GetBalanceExcelEdbData(excelEdbMappingItem *excelModel.ExcelChartEdb, newMixedTableCellDataListMap map[int]map[int]request.MixedTableCellDataReq, dataListMap map[int][]*data_manage.EdbDataList, allRows, allCols int) (err error, errMsg string) {
  113. var dateList, dataList []string
  114. // 日期序列
  115. {
  116. _, startColumnName, endColumnName, startNum, endNum, isAll, isRow, isColumn, tmpErr, tmpErrMsg := GetSheetStr(excelEdbMappingItem.DateSequence)
  117. if tmpErr != nil {
  118. errMsg = tmpErrMsg
  119. err = tmpErr
  120. return
  121. }
  122. startNum = startNum - 1
  123. endNum = endNum - 1
  124. // 选择行的数据
  125. if isRow {
  126. // 因为是选择一行的数据,所以开始行和结束行时一样的
  127. //endNum = startNum - 1
  128. // 开始列名、结束列
  129. var startColumn, endColumn int
  130. if isAll {
  131. // 结束列(其实也就是整列的个数)
  132. endColumn = allCols - 1
  133. } else {
  134. tmpStartColumn, tmpErr := excelize.ColumnNameToNumber(startColumnName)
  135. if tmpErr != nil {
  136. errMsg = "列名异常:" + startColumnName
  137. err = errors.New(errMsg)
  138. return
  139. }
  140. tmpEndColumn, tmpErr := excelize.ColumnNameToNumber(endColumnName)
  141. if tmpErr != nil {
  142. errMsg = "列名异常:" + endColumnName
  143. err = errors.New(errMsg)
  144. return
  145. }
  146. startColumn = tmpStartColumn - 1
  147. endColumn = tmpEndColumn - 1
  148. }
  149. // 最大列数,如果设置的超过了最大列数,那么结束列就是最大列数
  150. maxCol := allCols
  151. if endColumn > maxCol {
  152. endColumn = maxCol - 1
  153. }
  154. // 长度固定,避免一直申请内存空间
  155. //dateList = make([]string, endColumn-startColumn+1)
  156. dateList = make([]string, 0)
  157. i := 0
  158. for currColumn := startColumn; currColumn <= endColumn; currColumn++ {
  159. currCell, ok := newMixedTableCellDataListMap[startNum][currColumn]
  160. if !ok {
  161. errMsg = fmt.Sprintf("第%d列,第%d行数据异常", currColumn, startNum)
  162. err = errors.New(errMsg)
  163. return
  164. }
  165. dateList = append(dateList, currCell.ShowValue)
  166. //dateList[i] = currCell.ShowValue
  167. i++
  168. }
  169. } else if isColumn { // 选择列的数据
  170. if isAll {
  171. // 选择一整列的话,结束行得根据实际情况调整(其实也就是整个sheet有多少行)
  172. endNum = allRows - 1
  173. }
  174. startColumn, tmpErr := excelize.ColumnNameToNumber(startColumnName)
  175. if tmpErr != nil {
  176. errMsg = "列名异常:" + startColumnName
  177. err = errors.New(errMsg)
  178. return
  179. }
  180. startColumn = startColumn - 1
  181. // 最大行数,如果设置的超过了最大行数,那么结束行就是最大行数
  182. maxRow := allRows
  183. if endNum > maxRow {
  184. endNum = maxRow - 1
  185. }
  186. // 长度固定,避免一直申请内存空间
  187. //dateList = make([]string, endNum-startNum+1)
  188. fmt.Println("startNum:", startNum, "endNum:", endNum)
  189. dateList = make([]string, 0)
  190. i := 0
  191. for currRow := startNum; currRow <= endNum; currRow++ {
  192. currCell, ok := newMixedTableCellDataListMap[currRow][startColumn]
  193. if !ok {
  194. errMsg = fmt.Sprintf("第%d列,第%d行数据异常", currRow, startColumn)
  195. err = errors.New(errMsg)
  196. return
  197. }
  198. dateList = append(dateList, currCell.ShowValue)
  199. //dateList[i] = currCell.ShowValue
  200. i++
  201. }
  202. }
  203. }
  204. // 数据序列
  205. {
  206. _, startColumnName, endColumnName, startNum, endNum, isAll, isRow, isColumn, tmpErr, tmpErrMsg := GetSheetStr(excelEdbMappingItem.DataSequence)
  207. if tmpErr != nil {
  208. errMsg = tmpErrMsg
  209. err = tmpErr
  210. return
  211. }
  212. startNum = startNum - 1
  213. endNum = endNum - 1
  214. // 选择行的数据
  215. if isRow {
  216. // 开始列名、结束列
  217. var startColumn, endColumn int
  218. if isAll {
  219. // 结束列(其实也就是整列的个数)
  220. endColumn = allCols - 1
  221. } else {
  222. tmpStartColumn, tmpErr := excelize.ColumnNameToNumber(startColumnName)
  223. if tmpErr != nil {
  224. errMsg = "列名异常:" + startColumnName
  225. err = errors.New(errMsg)
  226. return
  227. }
  228. tmpEndColumn, tmpErr := excelize.ColumnNameToNumber(endColumnName)
  229. if tmpErr != nil {
  230. errMsg = "列名异常:" + endColumnName
  231. err = errors.New(errMsg)
  232. return
  233. }
  234. startColumn = tmpStartColumn - 1
  235. endColumn = tmpEndColumn - 1
  236. }
  237. // 最大列数,如果设置的超过了最大列数,那么结束列就是最大列数
  238. maxCol := allCols
  239. if endColumn > maxCol {
  240. endColumn = maxCol - 1
  241. }
  242. // 长度固定,避免一直申请内存空间
  243. //dataList = make([]string, endColumn-startColumn+1)
  244. dataList = make([]string, 0)
  245. i := 0
  246. for currColumn := startColumn; currColumn <= endColumn; currColumn++ {
  247. currCell, ok := newMixedTableCellDataListMap[startNum][currColumn]
  248. if !ok {
  249. errMsg = fmt.Sprintf("第%d列,第%d行数据异常", startColumn, currColumn)
  250. err = errors.New(errMsg)
  251. return
  252. }
  253. dataList = append(dataList, currCell.ShowValue)
  254. //dataList[i] = currCell.ShowValue
  255. i++
  256. }
  257. } else if isColumn { // 选择列的数据
  258. if isAll {
  259. // 选择一整列的话,结束行得根据实际情况调整(其实也就是整个sheet有多少行)
  260. endNum = allRows - 1
  261. }
  262. startColumn, tmpErr := excelize.ColumnNameToNumber(startColumnName)
  263. if tmpErr != nil {
  264. errMsg = "列名异常:" + startColumnName
  265. err = errors.New(errMsg)
  266. return
  267. }
  268. startColumn = startColumn - 1
  269. // 最大行数,如果设置的超过了最大行数,那么结束行就是最大行数
  270. maxRow := allRows
  271. if endNum > maxRow {
  272. endNum = maxRow - 1
  273. }
  274. // 长度固定,避免一直申请内存空间
  275. //dataList = make([]string, endNum-startNum+1)
  276. dataList = make([]string, 0)
  277. i := 0
  278. for currRow := startNum; currRow <= endNum; currRow++ {
  279. currCell, ok := newMixedTableCellDataListMap[currRow][startColumn]
  280. if !ok {
  281. errMsg = fmt.Sprintf("第%d列,第%d行数据异常", currRow, startColumn)
  282. err = errors.New(errMsg)
  283. return
  284. }
  285. dataList = append(dataList, currCell.ShowValue)
  286. //dataList[i] = currCell.ShowValue
  287. i++
  288. }
  289. }
  290. }
  291. //fmt.Println(dateList, dataList)
  292. //fmt.Println("日期序列结束")
  293. // 将excel中的日期、数据系列处理
  294. //newDateList, newDataList, err, errMsg := excel2.HandleEdbSequenceVal(dateList, dataList)
  295. newDateList, newDataList := dateList, dataList
  296. if err != nil {
  297. err = fmt.Errorf(" 处理日期和数据系列失败 %s", err.Error())
  298. return
  299. }
  300. newDataMap := make(map[int]float64, len(newDataList))
  301. for i, v := range newDataList {
  302. if v != "" {
  303. val, e := strconv.ParseFloat(v, 64)
  304. if e != nil {
  305. err = fmt.Errorf(" 处理日期和数据系列失败 %s", e.Error())
  306. return
  307. }
  308. newDataMap[i] = val
  309. }
  310. }
  311. //组装成excelEdbData
  312. list := make([]*data_manage.EdbDataList, 0)
  313. for i, v := range newDateList {
  314. val, ok := newDataMap[i]
  315. if !ok {
  316. continue
  317. }
  318. // todo 处理DataTimestamp
  319. dataTime, e := time.ParseInLocation(utils.FormatDate, v, time.Local)
  320. if e != nil {
  321. err = errors.New("time.Parse Err:" + e.Error())
  322. return
  323. }
  324. timestamp := dataTime.UnixNano() / 1e6
  325. tmp := &data_manage.EdbDataList{
  326. EdbDataId: i,
  327. EdbInfoId: excelEdbMappingItem.ExcelChartEdbId,
  328. DataTime: v,
  329. DataTimestamp: timestamp,
  330. Value: val,
  331. }
  332. list = append(list, tmp)
  333. }
  334. dataListMap[excelEdbMappingItem.ExcelChartEdbId] = list
  335. return
  336. }
  337. // 根据chartInfoId获取单个图表信息
  338. func GetBalanceExcelChartSingle(chartInfoId, ChartEdbId int, lang string) (mappingListTmp []*excelModel.ExcelChartEdb, dataListMap map[int][]*data_manage.EdbDataList, err error, errMsg string) {
  339. // 相关联指标
  340. if chartInfoId == 0 && ChartEdbId == 0 {
  341. err = fmt.Errorf(" 获取图表,指标信息失败 Err:chartInfoId和ChartEdbId不能同时为空")
  342. return
  343. }
  344. if chartInfoId == 0 {
  345. chartEdb, e := excelModel.GetExcelChartEdbById(ChartEdbId)
  346. if e != nil {
  347. err = fmt.Errorf(" 获取图表,指标信息失败 Err:%s", e.Error())
  348. return
  349. }
  350. chartInfoId = chartEdb.ChartInfoId
  351. }
  352. mappingListTmp, err = excelModel.GetExcelChartEdbMappingByChartInfoId(chartInfoId)
  353. if err != nil {
  354. errMsg = "获取失败"
  355. err = fmt.Errorf(" 获取图表,指标信息失败 Err:%s", err.Error())
  356. return
  357. }
  358. if len(mappingListTmp) <= 0 {
  359. errMsg = "获取失败"
  360. err = fmt.Errorf(" 获取图表,指标信息失败 Err:%s", err.Error())
  361. return
  362. }
  363. // 查询所有子表
  364. excelInfoId := mappingListTmp[0].ExcelInfoId
  365. excelInfo, err := excelModel.GetExcelInfoById(excelInfoId)
  366. if err != nil {
  367. if utils.IsErrNoRow(err) {
  368. errMsg = "表格不存在"
  369. err = fmt.Errorf(errMsg)
  370. return
  371. }
  372. errMsg = "查询子表失败"
  373. err = fmt.Errorf(" 查询子表失败图表,指标信息失败 Err:%s", err.Error())
  374. return
  375. }
  376. dataListMap = make(map[int][]*data_manage.EdbDataList)
  377. if excelInfo.BalanceType == 1 {
  378. //查询库里是否有值
  379. chartDataList, e := excelModel.GetExcelChartDataByChartInfoId(chartInfoId)
  380. if e != nil {
  381. err = fmt.Errorf(" 获取图表,指标信息失败 Err:%s", e.Error())
  382. return
  383. }
  384. if len(chartDataList) == 0 {
  385. err = fmt.Errorf(" 获取图表,指标数据不存在")
  386. return
  387. }
  388. for _, v := range chartDataList {
  389. tmp := &data_manage.EdbDataList{
  390. EdbDataId: v.ExcelChartDataId,
  391. EdbInfoId: v.ExcelChartEdbId,
  392. DataTime: v.DataTime,
  393. DataTimestamp: v.DataTimestamp,
  394. Value: v.Value,
  395. }
  396. dataListMap[v.ExcelChartEdbId] = append(dataListMap[v.ExcelChartEdbId], tmp)
  397. }
  398. return
  399. }
  400. // 获取图表详情
  401. newExcelDataMap, excelAllRows, excelAllCols, err, errMsg := GetBalanceExcelData(excelInfo, lang)
  402. if err != nil {
  403. return
  404. }
  405. for _, mapping := range mappingListTmp {
  406. er, msg := GetBalanceExcelEdbData(mapping, newExcelDataMap, dataListMap, excelAllRows, excelAllCols)
  407. if er != nil {
  408. utils.FileLog.Info(fmt.Sprintf(" 获取图表,指标信息失败 Err:%s, %s", er.Error(), msg))
  409. continue
  410. }
  411. }
  412. return
  413. }
  414. // TransferBalanceExcelContentToStatic 将平衡表动态表的内容转换为静态表的格式
  415. func TransferBalanceExcelContentToStatic(excelDetail *excelModel.ExcelInfo, lang string) (newContent string, err error) {
  416. var mixedTableReq request.MixedTableReq
  417. err = json.Unmarshal([]byte(excelDetail.Content), &mixedTableReq)
  418. if err != nil {
  419. err = errors.New("表格json转结构体失败,Err:" + err.Error())
  420. return
  421. }
  422. cellRelationConf := mixedTableReq.CellRelation
  423. //config := mixedTableReq.Data
  424. // 单元格关系配置x信息
  425. cellRelationConfMap := make(map[string]request.CellRelationConf)
  426. cellRelationConfList := make([]request.CellRelationConf, 0)
  427. cellRelationConfNewList := make([]request.CellRelationConf, 0)
  428. if cellRelationConf != `` {
  429. err = json.Unmarshal([]byte(cellRelationConf), &cellRelationConfList)
  430. if err != nil {
  431. return
  432. }
  433. for _, v := range cellRelationConfList {
  434. if v.Type == request.EdbDT || v.Type == request.InsertDataDT || v.Type == request.PopInsertDataDT || v.Type == request.InsertEdbCalculateDataDT || v.Type == request.DateCalculateDataDT {
  435. } else {
  436. cellRelationConfNewList = append(cellRelationConfNewList, v)
  437. }
  438. }
  439. }
  440. cellRelationConfByte, err := json.Marshal(cellRelationConfNewList)
  441. if err != nil {
  442. err = fmt.Errorf("cellRelationConf json转结构体失败,Err:%s", err.Error())
  443. return
  444. }
  445. cellRelationConf = string(cellRelationConfByte)
  446. newData, tmpErr, tmpErrMsg := GetMixedTableCellData(mixedTableReq, lang)
  447. if tmpErr != nil {
  448. err = errors.New(tmpErrMsg + "获取最新的数据失败 ,Err:" + tmpErr.Error())
  449. return
  450. }
  451. for r, row := range newData {
  452. for c, cell := range row {
  453. // todo 系统日期类型,原先是不可编辑,转成静态表之后是否变成可编辑
  454. cell.EdbInfoId = 0
  455. if cell.DataType != request.FormulateCalculateDataDT { //除了公式计算,其他类型都转成自定义类型
  456. cell.DataType = request.CustomTextDT //除了计算公式的关联关系被保留,其余绑定关系都删除
  457. if _, ok := cellRelationConfMap[cell.Uid]; ok {
  458. delete(cellRelationConfMap, cell.Uid)
  459. }
  460. }
  461. if cell.DataTime != "" {
  462. cell.DataTimeType = request.CustomDateT
  463. }
  464. cell.Value = cell.ShowValue
  465. row[c] = cell
  466. }
  467. newData[r] = row
  468. }
  469. var newMixedTableReq request.MixedTableReq
  470. newMixedTableReq.CellRelation = cellRelationConf
  471. newMixedTableReq.Data = newData
  472. newMixedTableByte, err := json.Marshal(newMixedTableReq)
  473. if err != nil {
  474. err = fmt.Errorf("newData json转结构体失败,Err:%s", err.Error())
  475. return
  476. }
  477. newContent = string(newMixedTableByte)
  478. return
  479. }
  480. func SyncBalanceEdbData(excelInfo *excelModel.ExcelInfo, balanceTableData [][]request.MixedTableCellDataReq) (err error) {
  481. tmpMappingList, e := excelModel.GetExcelChartEdbMappingByExcelInfoId(excelInfo.ExcelInfoId)
  482. if e != nil {
  483. err = fmt.Errorf(" 获取图表,指标信息失败 Err:%s", err.Error())
  484. return
  485. }
  486. if len(tmpMappingList) == 0 {
  487. return
  488. }
  489. excelDataMap := make(map[int][]*data_manage.EdbDataList)
  490. excelEdbMap := make(map[int]*excelModel.ExcelChartEdb)
  491. excelAllRows := len(balanceTableData)
  492. excelAllCols := 0
  493. newExcelDataMap := make(map[int]map[int]request.MixedTableCellDataReq)
  494. for r, row := range balanceTableData {
  495. tmp := len(row)
  496. if tmp > excelAllCols {
  497. excelAllCols = tmp
  498. }
  499. colMap := make(map[int]request.MixedTableCellDataReq)
  500. for c, col := range row {
  501. colMap[c] = col
  502. }
  503. newExcelDataMap[r] = colMap
  504. }
  505. for _, mapping := range tmpMappingList {
  506. excelEdbMap[mapping.ExcelChartEdbId] = mapping
  507. er, msg := GetBalanceExcelEdbData(mapping, newExcelDataMap, excelDataMap, excelAllRows, excelAllCols)
  508. if er != nil {
  509. utils.FileLog.Info(fmt.Sprintf(" 获取图表,指标信息失败 Err:%s, %s", msg, er.Error()))
  510. continue
  511. }
  512. }
  513. // 批量更新图表数据
  514. err = excelModel.BatchUpdateChartEdbData(excelInfo.ExcelInfoId, excelEdbMap, excelDataMap)
  515. if err != nil {
  516. err = fmt.Errorf(" 批量更新图表数据失败 Err:%s", err.Error())
  517. return
  518. }
  519. return
  520. }
  521. // GetBalanceExcelInfoOpButton 获取ETA平衡表格的操作权限
  522. func GetBalanceExcelInfoOpButton(sysUserId, parentSysUserId int, haveOperaAuth bool, parentExcelInfoId int) (button excelModel.ExcelInfoDetailButton) {
  523. // 如果没有数据权限,那么直接返回
  524. if !haveOperaAuth {
  525. return
  526. }
  527. //非管理员角色查看其他用户创建的表格,可刷新、另存为、下载表格;
  528. button.RefreshButton = true
  529. button.CopyButton = true
  530. button.DownloadButton = true
  531. if sysUserId == parentSysUserId {
  532. button.OpButton = true
  533. button.RefreshEdbButton = true
  534. button.OpWorkerButton = true
  535. button.DeleteButton = true
  536. } else {
  537. obj := new(excelModel.ExcelWorker)
  538. workerList, err := obj.GetByExcelInfoId(parentExcelInfoId)
  539. if err == nil {
  540. for _, v := range workerList {
  541. if v.SysUserId == sysUserId {
  542. button.OpButton = true
  543. button.RefreshEdbButton = true
  544. button.DeleteButton = true
  545. break
  546. }
  547. }
  548. }
  549. }
  550. return
  551. }