animeic 1 jaar geleden
bovenliggende
commit
e33e8cc1e4
2 gewijzigde bestanden met toevoegingen van 13 en 2 verwijderingen
  1. 12 1
      boxcost/api/bill-product-excel.go
  2. 1 1
      boxcost/api/utils.go

+ 12 - 1
boxcost/api/bill-product-excel.go

@@ -225,8 +225,10 @@ func (b *ProductBillExcel) drawTableTitle() error {
 func (b *ProductBillExcel) drawTableContent() error {
 	b.Row += 2
 
-	var DrawRow = func(rowIndex int, values ...string) {
+	var DrawRow = func(rowIndex int, values ...string) float64 {
 		charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I"}
+		// 获取改行最大行高
+		max := getRowHeight(values[0], b.getRangeWidth(charas[0]))
 		for i, c := range charas {
 			v := ""
 			if i < len(values) {
@@ -248,8 +250,12 @@ func (b *ProductBillExcel) drawTableContent() error {
 			// 	}
 			// }
 			// b.Excel.SetRowHeight(b.SheetName, rowIndex, 21*magN)
+			if getRowHeight(v, b.getRangeWidth(c)) > max {
+				max = getRowHeight(v, b.getRangeWidth(c))
+			}
 			b.Excel.SetRowHeight(b.SheetName, rowIndex, 50)
 		}
+		return max
 	}
 	products := b.Content.Products
 	if len(products) > 0 {
@@ -275,6 +281,9 @@ func (b *ProductBillExcel) drawTableContent() error {
 			b.FormatToEmpty(&price)
 
 			DrawRow(b.Row, product.Name, product.Norm, product.Size, orderCount, product.Unit, price, budgetAmount, deliveryTime, product.Remark)
+			// rowMaxHeight := DrawRow(b.Row, product.Name, product.Norm, product.Size, orderCount, product.Unit, price, budgetAmount, deliveryTime, product.Remark)
+			// 设置行高
+			// b.RowsHeightArray = append(b.RowsHeightArray, map[int]float64{b.Row: rowMaxHeight})
 
 			b.Row++
 		}
@@ -305,6 +314,8 @@ func (b *ProductBillExcel) drawTableFooter() error {
 	b.Excel.SetCellStyle(b.SheetName, sendToStartCell, sendToEndCell, styleLeft)
 	b.Excel.SetCellValue(b.SheetName, sendToStartCell, "送货地址:"+b.Content.SendTo)
 	b.Excel.MergeCell(b.SheetName, supplierStartCell, supplierEndCell)
+	// 设置行高
+	// b.RowsHeightArray = append(b.RowsHeightArray, map[int]float64{b.Row: getRowHeight("送货地址:"+b.Content.SendTo, b.getRangeWidth("A:F"))})
 	b.Excel.SetCellStyle(b.SheetName, supplierStartCell, supplierEndCell, styleLeft)
 	b.Excel.SetCellValue(b.SheetName, supplierStartCell, " 供应商签字:")
 	b.Excel.SetRowHeight(b.SheetName, b.Row, 32)

+ 1 - 1
boxcost/api/utils.go

@@ -23,7 +23,7 @@ var SignatureDir string = "https://www.3dqueen.cloud/box/v1/boxcost/public/"
 // func getRowHeight(content string, width float64,lineHeight float64) float64 {
 // 第一个参数为 行宽 第二个参数为 行高
 func getRowHeight(content string, params ...float64) float64 {
-	var perHeight float64 = 15
+	var perHeight float64 = 16
 	if len(params) == 2 {
 		perHeight = params[1]
 	}