소스 검색

add:添加excel表格默认尺寸

zqbao 3 달 전
부모
커밋
0211fa85e1
3개의 변경된 파일23개의 추가작업 그리고 3개의 파일을 삭제
  1. 1 0
      models/data_manage/excel/request/mixed_table.go
  2. 15 0
      services/data/excel/excel_info.go
  3. 7 3
      services/data/excel/mixed_table.go

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

@@ -137,6 +137,7 @@ type MixCellShowStyle struct {
 	Nt              string      `description:"变换类型:number 小数点位数改变,percent百分比," json:"nt"`
 	GlObj           interface{} `description:"公式对象:1:数值,2:百分比,3:文本" json:"glObj"`
 	Width           float64     `description:"单元格宽度" json:"width"`
+	Height          float64     `description:"单元格高度" json:"height"`
 	Decimal         *int        `description:"小数点位数" json:"decimal"`
 	Last            string      `description:"起始操作:nt|decimal" json:"last"`
 	Color           string      `description:"颜色值,#RRG" json:"color"`

+ 15 - 0
services/data/excel/excel_info.go

@@ -158,6 +158,7 @@ func formatExcelInfo2Detail(excelInfo *excel.ExcelInfo, sysUserId int, lang stri
 					result.Data[i].HaveOperaAuth = data_manage_permission.CheckEdbPermissionByPermissionIdList(v.IsJoinPermission, currClassify.IsJoinPermission, v.EdbInfoId, v.ClassifyId, permissionEdbIdList, permissionClassifyIdList)
 				}
 			}
+			setTextCellDefaultSize(result.TextRowData)
 		}
 
 		excelDetail.TableData = result
@@ -186,6 +187,20 @@ func formatExcelInfo2Detail(excelInfo *excel.ExcelInfo, sysUserId int, lang stri
 	return
 }
 
+// 设置默认的文本单元格大小
+func setTextCellDefaultSize(textRowData [][]request.ManualDataReq) {
+	for i := range textRowData {
+		for j := range textRowData[i] {
+			if textRowData[i][j].Width == 0 {
+				textRowData[i][j].Width = 140
+			}
+			if textRowData[i][j].Height == 0 {
+				textRowData[i][j].Height = 35
+			}
+		}
+	}
+}
+
 // SetExcelByDecimalConfig 设置表格的小数位
 func SetExcelByDecimalConfig(tableData request.TableDataReq, config []request.DecimalConfig) request.TableDataReq {
 	excelData := tableData.Data

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

@@ -465,21 +465,22 @@ func GetMixedTableCellData(mixedTableReq request.MixedTableReq, lang string) (ne
 	if err != nil {
 		return
 	}
-	config = setDefaultCellWidth(config)
+	config = setDefaultCellSize(config)
 
 	newMixedTableCellDataList = config
 
 	return
 }
 
-func setDefaultCellWidth(config [][]request.MixedTableCellDataReq) (newConfig [][]request.MixedTableCellDataReq) {
+func setDefaultCellSize(config [][]request.MixedTableCellDataReq) (newConfig [][]request.MixedTableCellDataReq) {
 	newConfig = config
 	for i, row := range config {
 		for j, cell := range row {
 			var styleConf request.MixCellShowStyle
 			if cell.ShowStyle == `` {
 				styleConf = request.MixCellShowStyle{
-					Width: 140,
+					Width:  140,
+					Height: 35,
 				}
 			} else {
 				err := json.Unmarshal([]byte(cell.ShowStyle), &styleConf)
@@ -489,6 +490,9 @@ func setDefaultCellWidth(config [][]request.MixedTableCellDataReq) (newConfig []
 				if styleConf.Width == 0 {
 					styleConf.Width = 140
 				}
+				if styleConf.Height == 0 {
+					styleConf.Height = 35
+				}
 			}
 			tmpStyleConf, err := json.Marshal(styleConf)
 			if err == nil {