animeic 1 سال پیش
والد
کامیت
8a5fcbd227
3فایلهای تغییر یافته به همراه28 افزوده شده و 27 حذف شده
  1. BIN
      boxcost/aaa.pdf
  2. 27 27
      boxcost/api/bill-product-excel.go
  3. 1 0
      boxcost/api/utils.go

BIN
boxcost/aaa.pdf


+ 27 - 27
boxcost/api/bill-product-excel.go

@@ -33,16 +33,15 @@ type ProductBillExcel struct {
 func (b *ProductBillExcel) drawTitle() error {
 	b.Row++
 	startCell := fmt.Sprintf("A%d", b.Row)
-	endCell := fmt.Sprintf("H%d", b.Row)
+	endCell := fmt.Sprintf("I%d", b.Row)
 	marginLeft := excelize.PageMarginLeft(0.00)
 	if b.IsPdf == "true" {
-		marginLeft = excelize.PageMarginLeft(0.35)
+		marginLeft = excelize.PageMarginLeft(0.1)
 	}
 
-	b.Excel.SetColWidth(b.SheetName, "A", "A", 18.5)
-	b.Excel.SetColWidth(b.SheetName, "B", "B", 16)
-	b.Excel.SetColWidth(b.SheetName, "C", "G", 12)
-	b.Excel.SetColWidth(b.SheetName, "H", "H", 18.5)
+	b.Excel.SetColWidth(b.SheetName, "A", "A", 16)
+	b.Excel.SetColWidth(b.SheetName, "B", "H", 12)
+	b.Excel.SetColWidth(b.SheetName, "I", "I", 18)
 	b.Excel.SetPageMargins(b.SheetName, marginLeft)
 	err := b.Excel.MergeCell(b.SheetName, startCell, endCell)
 	if err != nil {
@@ -82,7 +81,7 @@ func (b *ProductBillExcel) drawSubTitles() error {
 	drawLeft := func(rowIndex int, value string) error {
 		//左边1
 		left1Cell := fmt.Sprintf("A%d", rowIndex)
-		err = b.Excel.MergeCell(b.SheetName, left1Cell, fmt.Sprintf("F%d", rowIndex))
+		err = b.Excel.MergeCell(b.SheetName, left1Cell, fmt.Sprintf("G%d", rowIndex))
 		if err != nil {
 			return err
 		}
@@ -95,8 +94,8 @@ func (b *ProductBillExcel) drawSubTitles() error {
 	}
 
 	drawRight := func(rowIndex int, value string) error {
-		right1Cell := fmt.Sprintf("G%d", rowIndex)
-		err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("H%d", rowIndex))
+		right1Cell := fmt.Sprintf("H%d", rowIndex)
+		err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("I%d", rowIndex))
 		if err != nil {
 			return err
 		}
@@ -111,7 +110,7 @@ func (b *ProductBillExcel) drawSubTitles() error {
 	drawLall := func(rowIndex int, value string) error {
 		//左边1
 		left1Cell := fmt.Sprintf("A%d", rowIndex)
-		err = b.Excel.MergeCell(b.SheetName, left1Cell, fmt.Sprintf("H%d", rowIndex))
+		err = b.Excel.MergeCell(b.SheetName, left1Cell, fmt.Sprintf("I%d", rowIndex))
 		if err != nil {
 			return err
 		}
@@ -172,12 +171,13 @@ func (b *ProductBillExcel) drawTableTitle() error {
 
 	drawCol("A", "采购项目")
 	drawCol("B", "规格")
-	drawCol("C", "下单数量")
-	drawCol("D", "单位")
-	drawCol("E", "单价")
-	drawCol("F", "预算金额")
-	drawCol("G", "交货时间")
-	drawCol("H", "备注")
+	drawCol("C", "尺寸")
+	drawCol("D", "下单数量")
+	drawCol("E", "单位")
+	drawCol("F", "单价")
+	drawCol("G", "预算金额")
+	drawCol("H", "交货时间")
+	drawCol("I", "备注")
 	return nil
 }
 
@@ -185,7 +185,7 @@ func (b *ProductBillExcel) drawTableContent() error {
 	b.Row += 2
 
 	var DrawRow = func(rowIndex int, values ...string) {
-		charas := []string{"A", "B", "C", "D", "E", "F", "G", "H"}
+		charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I"}
 		for i, c := range charas {
 			v := ""
 			if i < len(values) {
@@ -233,7 +233,7 @@ func (b *ProductBillExcel) drawTableContent() error {
 			price := fmt.Sprintf("%.3f", product.OrderPrice)
 			b.FormatToEmpty(&price)
 
-			DrawRow(b.Row, product.Name, product.Norm, orderCount, product.Unit, price, budgetAmount, deliveryTime, product.Remark)
+			DrawRow(b.Row, product.Name, product.Norm, product.Size, orderCount, product.Unit, price, budgetAmount, deliveryTime, product.Remark)
 
 			b.Row++
 		}
@@ -256,9 +256,9 @@ func (b *ProductBillExcel) drawTableFooter() error {
 	})
 
 	sendToStartCell := fmt.Sprintf("A%d", b.Row)
-	sendToEndCell := fmt.Sprintf("E%d", b.Row)
-	supplierStartCell := fmt.Sprintf("F%d", b.Row)
-	supplierEndCell := fmt.Sprintf("H%d", b.Row)
+	sendToEndCell := fmt.Sprintf("F%d", b.Row)
+	supplierStartCell := fmt.Sprintf("G%d", b.Row)
+	supplierEndCell := fmt.Sprintf("I%d", b.Row)
 
 	b.Excel.MergeCell(b.SheetName, sendToStartCell, sendToEndCell)
 	b.Excel.SetCellStyle(b.SheetName, sendToStartCell, sendToEndCell, styleLeft)
@@ -287,7 +287,7 @@ func (b *ProductBillExcel) drawSupplierRemark() error {
 
 	sendToStartCell := fmt.Sprintf("A%d", b.Row)
 
-	sendToEndCell := fmt.Sprintf("H%d", b.Row)
+	sendToEndCell := fmt.Sprintf("I%d", b.Row)
 
 	b.Excel.MergeCell(b.SheetName, sendToStartCell, sendToEndCell)
 	b.Excel.SetCellStyle(b.SheetName, sendToStartCell, sendToEndCell, styleLeft)
@@ -311,11 +311,11 @@ func (b *ProductBillExcel) drawTableSignature() error {
 	b.Excel.MergeCell(b.SheetName, billUserCellS, billUserCellE)
 	b.Excel.SetCellValue(b.SheetName, billUserCellS, "制单人:"+b.Content.UserName)
 
-	fontNum := "E"
-	image1s := "F"
-	image2s := "H"
-	image1e := "G"
-	image2e := "H"
+	fontNum := "F"
+	image1s := "G"
+	image2s := "I"
+	image1e := "H"
+	image2e := "I"
 
 	fontCell := fmt.Sprintf("%s%d", fontNum, b.Row)
 	fontEndCell := fmt.Sprintf("%s%d", fontNum, b.Row+2)

+ 1 - 0
boxcost/api/utils.go

@@ -141,6 +141,7 @@ func excelToPdf(formBody *bytes.Buffer, pdfHost string) (*http.Response, error)
 	}
 
 	req := gotenberg.NewOfficeRequest(doc)
+
 	req.Landscape(true)
 	return client.Post(req)