Bläddra i källkod

混合表格合并单元格

hsun 8 månader sedan
förälder
incheckning
7694633a38

+ 11 - 12
controllers/data_manage/excel/excel_info.go

@@ -1330,7 +1330,7 @@ func (c *ExcelInfoController) GetExcelTableData() {
 			br.ErrMsg = "获取最新的数据失败,Err:" + err.Error()
 			return
 		}
-		tableData, err = excel.GetTableDataByMixedTableData(newResult)
+		tableData, err = excel.GetTableDataByMixedTableData(newResult, true)
 		if err != nil {
 			br.Msg = "获取失败"
 			br.ErrMsg = "转换成table失败,Err:" + err.Error()
@@ -1579,9 +1579,9 @@ func (c *ExcelInfoController) GetFirstEdbData() {
 	br.Success = true
 	br.Msg = "获取成功"
 	br.Data = response.TableDataItem{
-		EdbInfoId: edbInfoId,
-		Data:      dataList,
-		ExcelSource: excelSource,
+		EdbInfoId:     edbInfoId,
+		Data:          dataList,
+		ExcelSource:   excelSource,
 		ExcelSourceEn: excelSourceEn,
 	}
 }
@@ -1658,9 +1658,9 @@ func (c *ExcelInfoController) GetOtherEdbData() {
 	br.Success = true
 	br.Msg = "获取成功"
 	br.Data = response.TableDataItem{
-		EdbInfoId: req.EdbInfoId,
-		Data:      dataList,
-		ExcelSource: excelSource,
+		EdbInfoId:     req.EdbInfoId,
+		Data:          dataList,
+		ExcelSource:   excelSource,
 		ExcelSourceEn: excelSourceEn,
 	}
 }
@@ -2189,7 +2189,7 @@ func (c *ExcelInfoController) Download() {
 			br.ErrMsg = "获取最新的数据失败,Err:" + err.Error()
 			return
 		}
-		tableData, err = excel.GetTableDataByMixedTableData(newResult)
+		tableData, err = excel.GetTableDataByMixedTableData(newResult, false)
 		if err != nil {
 			br.Msg = "获取失败"
 			br.ErrMsg = "转换成table失败,Err:" + err.Error()
@@ -2584,7 +2584,6 @@ func (c *ExcelInfoController) GetBatchChartRefreshResult() {
 	br.Success = true
 }
 
-
 // GetBatchChartRefreshResult
 // @Title 获取批量刷新表格结果
 // @Description 获取批量刷新表格结果
@@ -2605,7 +2604,7 @@ func (c *ExcelInfoController) GetEdbSource() {
 		return
 	}
 	edbInfoId, _ := c.GetInt("EdbInfoId")
-	if edbInfoId <= 0  {
+	if edbInfoId <= 0 {
 		br.Msg = "请选择指标"
 		br.ErrMsg = "请选择指标"
 		br.IsSendEmail = false
@@ -2621,7 +2620,7 @@ func (c *ExcelInfoController) GetEdbSource() {
 	excelSourceEn := strings.Join(sourceNameEnList, ",")
 
 	var resp struct {
-		ExcelSource string `description:"表格来源"`
+		ExcelSource   string `description:"表格来源"`
 		ExcelSourceEn string `description:"表格来源(英文)"`
 	}
 
@@ -2631,4 +2630,4 @@ func (c *ExcelInfoController) GetEdbSource() {
 	br.Data = resp
 	br.Ret = 200
 	br.Success = true
-}
+}

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

@@ -45,6 +45,16 @@ type MixedTableCellDataReq struct {
 	Extra           string      `description:"额外参数"`
 	ShowStyle       string      `description:"展示的样式配置"`
 	ShowFormatValue interface{} `description:"样式处理后的值"`
+	MerData         *struct {
+		Type string `json:"type"`
+		Mer  struct {
+			SKey    string `json:"sKey"`
+			Rowspan int    `json:"rowspan"`
+			Colspan int    `json:"colspan"`
+			Row     int    `json:"row"`
+			Col     int    `json:"col"`
+		} `json:"mer"`
+	} `json:"merData" description:"合并单元格"`
 }
 
 // CellRelationConf

+ 18 - 3
services/excel/lucky_sheet.go

@@ -1685,7 +1685,7 @@ func GetTableDataByCustomData(excelType int, data request.TableDataReq) (selfTab
 }
 
 // GetTableDataByMixedTableData 通过混合表格数据获取表格数据
-func GetTableDataByMixedTableData(config [][]request.MixedTableCellDataReq) (selfTableData TableData, err error) {
+func GetTableDataByMixedTableData(config [][]request.MixedTableCellDataReq, hideMerged bool) (selfTableData TableData, err error) {
 	tableDataList := make([][]LuckySheetDataValue, 0)
 	mergeList := make([]TableDataMerge, 0)
 
@@ -1694,11 +1694,26 @@ func GetTableDataByMixedTableData(config [][]request.MixedTableCellDataReq) (sel
 		for _, row := range config {
 			dataCol := make([]LuckySheetDataValue, 0)
 			for _, cell := range row {
-				dataCol = append(dataCol, LuckySheetDataValue{
+				tmp := LuckySheetDataValue{
 					Value:     cell.Value,
 					Monitor:   cell.ShowValue,
 					MergeCell: LuckySheetDataConfigMerge{},
-				})
+				}
+				// 前端需要隐藏被合并的单元格, 混合表格/平衡表通过这个字段判断, 不通过HandleTableCell方法隐藏
+				if cell.MerData != nil {
+					if hideMerged && cell.MerData.Type == "merged" {
+						continue
+					}
+					tmp.MergeCell.Rs = cell.MerData.Mer.Rowspan
+					tmp.MergeCell.Cs = cell.MerData.Mer.Colspan
+					tmp.MergeCell.Row = cell.MerData.Mer.Row
+					tmp.MergeCell.Column = cell.MerData.Mer.Col
+				}
+				if cell.ShowStyle != "" {
+					showFormatValue := fmt.Sprintf("%v", cell.ShowFormatValue)
+					tmp.Monitor = showFormatValue
+				}
+				dataCol = append(dataCol, tmp)
 			}
 			tableDataList = append(tableDataList, dataCol)
 		}