animeic 1 year ago
parent
commit
299eb648db
4 changed files with 18 additions and 1 deletions
  1. BIN
      boxcost/aaa.pdf
  2. 5 1
      boxcost/api/bill-product-excel.go
  3. 10 0
      boxcost/api/utils.go
  4. 3 0
      boxcost/db/model/bill.go

BIN
boxcost/aaa.pdf


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

@@ -34,7 +34,11 @@ func (b *ProductBillExcel) drawTitle() error {
 	b.Row++
 	startCell := fmt.Sprintf("A%d", b.Row)
 	endCell := fmt.Sprintf("H%d", b.Row)
-	marginLeft := excelize.PageMarginLeft(0.35)
+	marginLeft := excelize.PageMarginLeft(0.00)
+	if b.IsPdf == "true" {
+		marginLeft = excelize.PageMarginLeft(0.35)
+	}
+
 	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)

+ 10 - 0
boxcost/api/utils.go

@@ -123,6 +123,16 @@ func excelToPdf(formBody *bytes.Buffer, pdfHost string) (*http.Response, error)
 		Timeout: time.Duration(15) * time.Second,
 	}
 	client := &gotenberg.Client{Hostname: pdfHost, HTTPClient: httpClient}
+	// 'merge="true"' \
+	// --form 'pdfFormat="PDF/A-1a"' \
+	// formData := url.Values{
+	// 	"merge":     {"true"},
+	// 	"pdfFormat": {"PDF/A-1a"},
+	// }
+
+	// 构建请求体
+	// reqData := bytes.NewBufferString(formData.Encode())
+	// reqData.WriteTo(formBody)
 	doc, err := gotenberg.NewDocumentFromBytes("foo.xlsx", formBody.Bytes())
 
 	if err != nil {

+ 3 - 0
boxcost/db/model/bill.go

@@ -254,6 +254,9 @@ type ProductBillData struct {
 	//规格(质量要求)
 	Norm string `bson:"norm,omitempty" json:"norm"`
 
+	// 尺寸
+	Size string `bson:"size,omitempty" json:"size"`
+
 	//单价 数量
 	Price float64 `bson:"price,omitempty" json:"price"`