Переглянути джерело

fix:表格详情兼容字体颜色和背景颜色

zqbao 6 місяців тому
батько
коміт
86496fbf63

+ 4 - 2
models/data_manage/excel/request/mixed_table.go

@@ -133,8 +133,10 @@ type MixDateCalculateTagReq struct {
 
 // MixCellShowStyle 混合表格 单元格样式展示计算
 type MixCellShowStyle struct {
-	Pn int    `description:"小数点位数增加或减少,正数表述增加,负数表示减少" json:"pn"`
-	Nt string `description:"变换类型:number 小数点位数改变,percent百分比," json:"nt"`
+	Pn              int    `description:"小数点位数增加或减少,正数表述增加,负数表示减少" json:"pn"`
+	Nt              string `description:"变换类型:number 小数点位数改变,percent百分比," json:"nt"`
+	Color           string `description:"颜色值,#RRG" json:"color"`
+	BackgroundColor string `description:"背景颜色值,#RRG" json:"background-color"`
 }
 
 type DateDataBeforeAfterReq struct {

+ 3 - 2
services/data/excel/mixed_table.go

@@ -8,12 +8,13 @@ import (
 	"eta/eta_api/services/data"
 	"eta/eta_api/utils"
 	"fmt"
-	"github.com/shopspring/decimal"
-	"github.com/yidane/formula"
 	"sort"
 	"strconv"
 	"strings"
 	"time"
+
+	"github.com/shopspring/decimal"
+	"github.com/yidane/formula"
 )
 
 // BaseCalculate

+ 13 - 2
services/excel/lucky_sheet.go

@@ -6,13 +6,14 @@ import (
 	"eta/eta_api/models/data_manage/excel/request"
 	"eta/eta_api/utils"
 	"fmt"
-	"github.com/tealeg/xlsx"
-	"github.com/xuri/excelize/v2"
 	"os"
 	"reflect"
 	"strconv"
 	"strings"
 	"time"
+
+	"github.com/tealeg/xlsx"
+	"github.com/xuri/excelize/v2"
 )
 
 type LuckySheetDataBak struct {
@@ -1743,8 +1744,18 @@ func GetTableDataByMixedTableData(config [][]request.MixedTableCellDataReq, hide
 					tmp.MergeCell.Column = cell.MerData.Mer.Col
 				}
 				if cell.ShowStyle != "" {
+					var styleConfig request.MixCellShowStyle
+					if err := json.Unmarshal([]byte(cell.ShowStyle), &styleConfig); err != nil {
+						utils.FileLog.Info("表格样式showStyle解析失败", err.Error())
+					}
 					showFormatValue := fmt.Sprintf("%v", cell.ShowFormatValue)
 					tmp.Monitor = showFormatValue
+					if styleConfig.BackgroundColor != "" {
+						tmp.Background = styleConfig.BackgroundColor
+					}
+					if styleConfig.Color != "" {
+						tmp.FontColor = styleConfig.Color
+					}
 				}
 				dataCol = append(dataCol, tmp)
 			}