xyxie hace 1 año
padre
commit
b3a4c9fd31
Se han modificado 2 ficheros con 27 adiciones y 13 borrados
  1. 10 10
      models/data_manage/excel/request/mixed_table.go
  2. 17 3
      services/data/excel/mixed_table.go

+ 10 - 10
models/data_manage/excel/request/mixed_table.go

@@ -35,16 +35,16 @@ type MixedTableReq struct {
 
 // MixedTableCellDataReq 混合表格单元格参数
 type MixedTableCellDataReq struct {
-	Uid          string `description:"单元格唯一标识"`
-	DataType     int    `description:"数据类型,1:日期,2:指标,3:自定义文本,4:插值"`
-	DataTime     string `description:"所属日期"`
-	DataTimeType int    `description:"日期类型:0:手动输入日期(固定日期);1:导入系统日期;;3:导入指标日期(指标库的最新日期);"`
-	EdbInfoId    int    `description:"指标id"`
-	ShowValue    string `description:"展示值"`
-	Value        string `description:"实际值和配置"`
-	Extra        string `description:"额外参数"`
-	ShowStyle    string `description:"展示的样式配置"`
-	RealValue    string `description:"实际的值"`
+	Uid             string `description:"单元格唯一标识"`
+	DataType        int    `description:"数据类型,1:日期,2:指标,3:自定义文本,4:插值"`
+	DataTime        string `description:"所属日期"`
+	DataTimeType    int    `description:"日期类型:0:手动输入日期(固定日期);1:导入系统日期;;3:导入指标日期(指标库的最新日期);"`
+	EdbInfoId       int    `description:"指标id"`
+	ShowValue       string `description:"展示值"`
+	Value           string `description:"实际值和配置"`
+	Extra           string `description:"额外参数"`
+	ShowStyle       string `description:"展示的样式配置"`
+	ShowFormatValue string `description:"样式处理后的值"`
 }
 
 // CellRelationConf

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

@@ -153,10 +153,11 @@ func GetMixedTableCellData(mixedTableReq request.MixedTableReq) (newMixedTableCe
 	calculateCellMap := make(map[string]Cell)
 	calculateChainList := make([]string, 0)
 	dateCalculateList := make([]string, 0)
+	showStyleList := make([]string, 0)
+
 	// 处理单元格中的数据类型(除去基础计算,因为这个是依赖于其他)
 	for k, row := range config {
 		for i, cell := range row {
-			cell.RealValue = cell.RealValue
 			switch cell.DataType {
 			case request.DateDT: // 日期类型
 				calculateCellMap[cell.Uid] = Cell{
@@ -411,7 +412,14 @@ func GetMixedTableCellData(mixedTableReq request.MixedTableReq) (newMixedTableCe
 				dateCalculateList = append(dateCalculateList, cell.Uid)
 				// 遍历数组,根据公式进行计算,并将得到的结果放到对应的单元格中
 			}
-
+			if cell.ShowValue != `` {
+				calculateCellMap[cell.Uid] = Cell{
+					Column:   k,
+					Row:      i,
+					CellInfo: cell,
+				}
+				showStyleList = append(showStyleList, cell.Uid)
+			}
 			row[i] = cell
 		}
 		config[k] = row
@@ -455,6 +463,12 @@ func GetMixedTableCellData(mixedTableReq request.MixedTableReq) (newMixedTableCe
 		return
 	}
 
+	// 格式化展示
+	config, err, errMsg = handleMixCellShowStyle(showStyleList, calculateCellMap, config)
+	if err != nil {
+		return
+	}
+
 	newMixedTableCellDataList = config
 
 	return
@@ -1189,7 +1203,7 @@ func handleMixCellShowStyle(showStyleList []string, calculateCellMap map[string]
 			if styleConf.NumberStyle.IsPercent == 1 {
 				val = changeToPercent(cell.ShowStyle)
 			}
-			cell.ShowValue = val
+			cell.ShowFormatValue = val
 			config[cellPosition.Column][cellPosition.Row] = cell
 		}
 	}