animeic 2 years ago
parent
commit
d88f833317
4 changed files with 621 additions and 573 deletions
  1. 257 226
      boxcost/api/bill-produce-excel.go
  2. 255 240
      boxcost/api/bill-product-excel.go
  3. 104 104
      boxcost/api/bill-purchase-excel.go
  4. 5 3
      boxcost/db/model/bill.go

+ 257 - 226
boxcost/api/bill-produce-excel.go

@@ -27,41 +27,41 @@ type ProduceBillExcel struct {
 
 func (b *ProduceBillExcel) drawTitle() error {
 	b.Row++
-	marginLeft := excelize.PageMarginLeft(0.15)
-	startCell := fmt.Sprintf("A%d", b.Row)
-	endCell := fmt.Sprintf("L%d", b.Row)
+	// marginLeft := excelize.PageMarginLeft(0.15)
+	// startCell := fmt.Sprintf("A%d", b.Row)
+	// endCell := fmt.Sprintf("L%d", b.Row)
 
 	// !isPrint
-	if !b.Content.IsPrint {
-		endCell = fmt.Sprintf("I%d", b.Row)
-		marginLeft = excelize.PageMarginLeft(0.4)
-		b.Excel.SetColWidth(b.SheetName, "A", "B", 16)
-		b.Excel.SetColWidth(b.SheetName, "C", "H", 10.5)
-		b.Excel.SetColWidth(b.SheetName, "I", "I", 16)
-	}
+	// if !b.Content.IsPrint {
+	// 	endCell = fmt.Sprintf("I%d", b.Row)
+	// 	marginLeft = excelize.PageMarginLeft(0.4)
+	// 	b.Excel.SetColWidth(b.SheetName, "A", "B", 16)
+	// 	b.Excel.SetColWidth(b.SheetName, "C", "H", 10.5)
+	// 	b.Excel.SetColWidth(b.SheetName, "I", "I", 16)
+	// }
 
 	// !!isPdf
-	if b.IsPdf == "true" {
-		marginLeft = excelize.PageMarginLeft(0.18)
-		startCell = fmt.Sprintf("A%d", b.Row)
-		endCell = fmt.Sprintf("J%d", b.Row)
-		b.Excel.SetColWidth(b.SheetName, "A", "A", 16)
-		b.Excel.SetColWidth(b.SheetName, "B", "C", 14)
-		b.Excel.SetColWidth(b.SheetName, "C", "H", 10)
-		b.Excel.SetColWidth(b.SheetName, "I", "I", 12)
-		b.Excel.SetColWidth(b.SheetName, "J", "J", 14)
-
-		// !isPrint
-		if !b.Content.IsPrint {
-			endCell = fmt.Sprintf("G%d", b.Row)
-			marginLeft = excelize.PageMarginLeft(0.6)
-			b.Excel.SetColWidth(b.SheetName, "A", "B", 20)
-			b.Excel.SetColWidth(b.SheetName, "C", "F", 12)
-			b.Excel.SetColWidth(b.SheetName, "G", "G", 20)
-		}
+	// if b.IsPdf == "true" {
+	marginLeft := excelize.PageMarginLeft(0.18)
+	startCell := fmt.Sprintf("A%d", b.Row)
+	endCell := fmt.Sprintf("J%d", b.Row)
+	b.Excel.SetColWidth(b.SheetName, "A", "A", 16)
+	b.Excel.SetColWidth(b.SheetName, "B", "C", 14)
+	b.Excel.SetColWidth(b.SheetName, "C", "H", 10)
+	b.Excel.SetColWidth(b.SheetName, "I", "I", 12)
+	b.Excel.SetColWidth(b.SheetName, "J", "J", 14)
 
+	// !isPrint
+	if !b.Content.IsPrint {
+		endCell = fmt.Sprintf("G%d", b.Row)
+		marginLeft = excelize.PageMarginLeft(0.6)
+		b.Excel.SetColWidth(b.SheetName, "A", "B", 20)
+		b.Excel.SetColWidth(b.SheetName, "C", "F", 12)
+		b.Excel.SetColWidth(b.SheetName, "G", "G", 20)
 	}
 
+	// }
+
 	b.Excel.SetPageMargins(b.SheetName, marginLeft)
 
 	err := b.Excel.MergeCell(b.SheetName, startCell, endCell)
@@ -99,10 +99,75 @@ func (b *ProduceBillExcel) drawSubTitles() error {
 		return err
 	}
 
-	var drawLeft = func(rowIndex int, value string) error {
+	// var 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))
+	// 	if err != nil {
+	// 		return err
+	// 	}
+	// 	err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left1Cell, styleLeft)
+	// 	if err != nil {
+	// 		return err
+	// 	}
+	// 	b.Excel.SetCellValue(b.SheetName, left1Cell, value)
+	// 	return nil
+	// }
+
+	// var drawRight = func(rowIndex int, value string) error {
+	// 	right1Cell := fmt.Sprintf("G%d", rowIndex)
+	// 	err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("L%d", rowIndex))
+	// 	if err != nil {
+	// 		return err
+	// 	}
+	// 	err = b.Excel.SetCellStyle(b.SheetName, right1Cell, right1Cell, styleRight)
+	// 	if err != nil {
+	// 		return err
+	// 	}
+	// 	b.Excel.SetCellValue(b.SheetName, right1Cell, value)
+	// 	return nil
+	// }
+
+	// !isPrint
+	// if !b.Content.IsPrint {
+
+	// 	drawLeft = func(rowIndex int, value string) error {
+	// 		//左边1
+	// 		left1Cell := fmt.Sprintf("A%d", rowIndex)
+	// 		err = b.Excel.MergeCell(b.SheetName, left1Cell, fmt.Sprintf("E%d", rowIndex))
+	// 		if err != nil {
+	// 			return err
+	// 		}
+	// 		err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left1Cell, styleLeft)
+	// 		if err != nil {
+	// 			return err
+	// 		}
+	// 		b.Excel.SetCellValue(b.SheetName, left1Cell, value)
+	// 		return nil
+	// 	}
+
+	// 	drawRight = func(rowIndex int, value string) error {
+	// 		right1Cell := fmt.Sprintf("F%d", rowIndex)
+	// 		err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("I%d", rowIndex))
+	// 		if err != nil {
+	// 			return err
+	// 		}
+	// 		err = b.Excel.SetCellStyle(b.SheetName, right1Cell, right1Cell, styleRight)
+	// 		if err != nil {
+	// 			return err
+	// 		}
+	// 		b.Excel.SetCellValue(b.SheetName, right1Cell, value)
+	// 		return nil
+	// 	}
+
+	// }
+
+	// !!isPdf
+	// if b.IsPdf == "true" {
+	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
 		}
@@ -114,9 +179,9 @@ func (b *ProduceBillExcel) drawSubTitles() error {
 		return nil
 	}
 
-	var drawRight = func(rowIndex int, value string) error {
-		right1Cell := fmt.Sprintf("G%d", rowIndex)
-		err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("L%d", rowIndex))
+	drawRight := func(rowIndex int, value string) error {
+		right1Cell := fmt.Sprintf("H%d", rowIndex)
+		err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("J%d", rowIndex))
 		if err != nil {
 			return err
 		}
@@ -130,7 +195,6 @@ func (b *ProduceBillExcel) drawSubTitles() error {
 
 	// !isPrint
 	if !b.Content.IsPrint {
-
 		drawLeft = func(rowIndex int, value string) error {
 			//左边1
 			left1Cell := fmt.Sprintf("A%d", rowIndex)
@@ -148,7 +212,7 @@ func (b *ProduceBillExcel) drawSubTitles() error {
 
 		drawRight = func(rowIndex int, value string) error {
 			right1Cell := fmt.Sprintf("F%d", rowIndex)
-			err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("I%d", rowIndex))
+			err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("G%d", rowIndex))
 			if err != nil {
 				return err
 			}
@@ -159,73 +223,9 @@ func (b *ProduceBillExcel) drawSubTitles() error {
 			b.Excel.SetCellValue(b.SheetName, right1Cell, value)
 			return nil
 		}
-
 	}
 
-	// !!isPdf
-	if b.IsPdf == "true" {
-		drawLeft = func(rowIndex int, value string) error {
-			//左边1
-			left1Cell := fmt.Sprintf("A%d", rowIndex)
-			err = b.Excel.MergeCell(b.SheetName, left1Cell, fmt.Sprintf("E%d", rowIndex))
-			if err != nil {
-				return err
-			}
-			err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left1Cell, styleLeft)
-			if err != nil {
-				return err
-			}
-			b.Excel.SetCellValue(b.SheetName, left1Cell, value)
-			return nil
-		}
-
-		drawRight = func(rowIndex int, value string) error {
-			right1Cell := fmt.Sprintf("F%d", rowIndex)
-			err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("J%d", rowIndex))
-			if err != nil {
-				return err
-			}
-			err = b.Excel.SetCellStyle(b.SheetName, right1Cell, right1Cell, styleRight)
-			if err != nil {
-				return err
-			}
-			b.Excel.SetCellValue(b.SheetName, right1Cell, value)
-			return nil
-		}
-
-		// !isPrint
-		if !b.Content.IsPrint {
-			drawLeft = func(rowIndex int, value string) error {
-				//左边1
-				left1Cell := fmt.Sprintf("A%d", rowIndex)
-				err = b.Excel.MergeCell(b.SheetName, left1Cell, fmt.Sprintf("B%d", rowIndex))
-				if err != nil {
-					return err
-				}
-				err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left1Cell, styleLeft)
-				if err != nil {
-					return err
-				}
-				b.Excel.SetCellValue(b.SheetName, left1Cell, value)
-				return nil
-			}
-
-			drawRight = func(rowIndex int, value string) error {
-				right1Cell := fmt.Sprintf("C%d", rowIndex)
-				err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("G%d", rowIndex))
-				if err != nil {
-					return err
-				}
-				err = b.Excel.SetCellStyle(b.SheetName, right1Cell, right1Cell, styleRight)
-				if err != nil {
-					return err
-				}
-				b.Excel.SetCellValue(b.SheetName, right1Cell, value)
-				return nil
-			}
-		}
-
-	}
+	// }
 
 	//第一行
 	drawLeft(b.Row, "类别:"+b.Content.Type)
@@ -284,82 +284,106 @@ func (b *ProduceBillExcel) drawTableTitle() error {
 		return nil
 	}
 
-	// !isPrint
-	if !b.Content.IsPrint {
-		// !!isPdf
-		if b.IsPdf == "true" {
-			drawCol("A", "加工项目")
-			drawCol("B", "规格")
-			drawCol("C", "下单数量")
-			drawCol2("D", "单价", "元/张")
-			drawCol("E", "预算金额")
-			drawCol("F", "交货时间")
-			drawCol("G", "备注")
-		} else {
-			drawCol("A", "加工项目")
-			drawCol("B", "规格")
-			drawCol("C", "下单数量")
-			drawCol("D", "完成数量")
-			drawCol2("E", "单价", "元/张")
-			drawCol("F", "预算金额")
-			drawCol("G", "实际金额")
-			drawCol("H", "交货时间")
-			drawCol("I", "备注")
-		}
+	if b.Content.IsPrint {
+		drawCol("A", "加工项目")
+		drawCol("B", "规格")
+		drawCol("C", "纸张")
+		drawCol("D", "来纸尺寸")
+		drawCol("E", "印刷尺寸")
+		drawCol("F", "下单数量")
+		drawCol2("G", "单价", "元/张")
+		drawCol("H", "预算金额")
+		drawCol("I", "交货时间")
+		drawCol("J", "备注")
 
 	} else {
-		// !!isPdf
-		if b.IsPdf == "true" {
-			drawCol("A", "加工项目")
-			drawCol("B", "规格")
-			drawCol("C", "纸张")
-			drawCol("D", "来纸尺寸")
-			drawCol("E", "印刷尺寸")
-			drawCol("F", "下单数量")
-			drawCol2("G", "单价", "元/张")
-			drawCol("H", "预算金额")
-			drawCol("I", "交货时间")
-			drawCol("J", "备注")
-
-		} else {
-			drawCol("A", "加工项目")
-			drawCol("B", "规格")
-			drawCol("C", "纸张")
-			drawCol("D", "来纸尺寸")
-			drawCol("E", "印刷尺寸")
-			drawCol("F", "下单数量")
-			drawCol("G", "完成数量")
-			drawCol2("H", "单价", "元/张")
-			drawCol("I", "预算金额")
-			drawCol("J", "实际金额")
-			drawCol("K", "交货时间")
-			drawCol("L", "备注")
-
-		}
+		drawCol("A", "加工项目")
+		drawCol("B", "规格")
+		drawCol("C", "下单数量")
+		drawCol2("D", "单价", "元/张")
+		drawCol("E", "预算金额")
+		drawCol("F", "交货时间")
+		drawCol("G", "备注")
 
 	}
 
+	// // !isPrint
+	// if !b.Content.IsPrint {
+
+	// 	// !!isPdf
+	// 	if b.IsPdf == "true" {
+	// 		drawCol("A", "加工项目")
+	// 		drawCol("B", "规格")
+	// 		drawCol("C", "下单数量")
+	// 		drawCol2("D", "单价", "元/张")
+	// 		drawCol("E", "预算金额")
+	// 		drawCol("F", "交货时间")
+	// 		drawCol("G", "备注")
+	// 	} else {
+	// 		drawCol("A", "加工项目")
+	// 		drawCol("B", "规格")
+	// 		drawCol("C", "下单数量")
+	// 		drawCol("D", "完成数量")
+	// 		drawCol2("E", "单价", "元/张")
+	// 		drawCol("F", "预算金额")
+	// 		drawCol("G", "实际金额")
+	// 		drawCol("H", "交货时间")
+	// 		drawCol("I", "备注")
+	// 	}
+
+	// } else {
+	// 	// !!isPdf
+	// 	if b.IsPdf == "true" {
+	// 		drawCol("A", "加工项目")
+	// 		drawCol("B", "规格")
+	// 		drawCol("C", "纸张")
+	// 		drawCol("D", "来纸尺寸")
+	// 		drawCol("E", "印刷尺寸")
+	// 		drawCol("F", "下单数量")
+	// 		drawCol2("G", "单价", "元/张")
+	// 		drawCol("H", "预算金额")
+	// 		drawCol("I", "交货时间")
+	// 		drawCol("J", "备注")
+
+	// 	} else {
+	// 		drawCol("A", "加工项目")
+	// 		drawCol("B", "规格")
+	// 		drawCol("C", "纸张")
+	// 		drawCol("D", "来纸尺寸")
+	// 		drawCol("E", "印刷尺寸")
+	// 		drawCol("F", "下单数量")
+	// 		drawCol("G", "完成数量")
+	// 		drawCol2("H", "单价", "元/张")
+	// 		drawCol("I", "预算金额")
+	// 		drawCol("J", "实际金额")
+	// 		drawCol("K", "交货时间")
+	// 		drawCol("L", "备注")
+
+	// 	}
+
+	// }
+
 	return nil
 }
 
 func (b *ProduceBillExcel) drawTableContent() error {
 	b.Row += 2
 	var DrawRow = func(rowIndex int, values ...string) {
-		charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"}
+		// charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"}
+		// // !isPrint
+		// if !b.Content.IsPrint {
+		// 	charas = []string{"A", "B", "C", "D", "E", "F", "G", "H", "I"}
+		// }
+
+		// !!isPdf
+		// if b.IsPdf == "true" {
+		charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"}
 		// !isPrint
 		if !b.Content.IsPrint {
-			charas = []string{"A", "B", "C", "D", "E", "F", "G", "H", "I"}
+			charas = []string{"A", "B", "C", "D", "E", "F", "G"}
 		}
 
-		// !!isPdf
-		if b.IsPdf == "true" {
-			charas = []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"}
-			// !isPrint
-			if !b.Content.IsPrint {
-				charas = []string{"A", "B", "C", "D", "E", "F", "G"}
-			}
-
-		}
+		// }
 		for i, c := range charas {
 			v := ""
 			if i < len(values) {
@@ -393,27 +417,34 @@ func (b *ProduceBillExcel) drawTableContent() error {
 
 			deliveryTime := produce.DeliveryTime.Local().Format("2006-01-02")
 
+			if b.Content.IsPrint {
+				DrawRow(b.Row, produce.Name, produce.Norm, produce.Paper, produce.PaperSize, produce.PrintSize, fmt.Sprintf("%d", produce.OrderCount), priceStr, budgetAmount, deliveryTime, produce.Remark)
+
+			} else {
+				DrawRow(b.Row, produce.Name, produce.Norm, fmt.Sprintf("%d", produce.OrderCount), priceStr, budgetAmount, deliveryTime, produce.Remark)
+
+			}
 			// !isPrint
-			if !b.Content.IsPrint {
-				// !!isPdf
-				if b.IsPdf == "true" {
-					DrawRow(b.Row, produce.Name, produce.Norm, fmt.Sprintf("%d", produce.OrderCount), priceStr, budgetAmount, deliveryTime, produce.Remark)
+			// if !b.Content.IsPrint {
+			// 	// !!isPdf
+			// 	if b.IsPdf == "true" {
+			// 		DrawRow(b.Row, produce.Name, produce.Norm, fmt.Sprintf("%d", produce.OrderCount), priceStr, budgetAmount, deliveryTime, produce.Remark)
 
-				} else {
-					DrawRow(b.Row, produce.Name, produce.Norm, fmt.Sprintf("%d", produce.OrderCount), realCount, priceStr, budgetAmount, realPrice, deliveryTime, produce.Remark)
+			// 	} else {
+			// 		DrawRow(b.Row, produce.Name, produce.Norm, fmt.Sprintf("%d", produce.OrderCount), realCount, priceStr, budgetAmount, realPrice, deliveryTime, produce.Remark)
 
-				}
+			// 	}
 
-			} else {
-				// !!isPdf
-				if b.IsPdf == "true" {
-					DrawRow(b.Row, produce.Name, produce.Norm, produce.Paper, produce.PaperSize, produce.PrintSize, fmt.Sprintf("%d", produce.OrderCount), priceStr, budgetAmount, deliveryTime, produce.Remark)
-				} else {
-					DrawRow(b.Row, produce.Name, produce.Norm, produce.Paper, produce.PaperSize, produce.PrintSize, fmt.Sprintf("%d", produce.OrderCount), realCount, priceStr, budgetAmount, realPrice, deliveryTime, produce.Remark)
+			// } else {
+			// 	// !!isPdf
+			// 	if b.IsPdf == "true" {
+			// 		DrawRow(b.Row, produce.Name, produce.Norm, produce.Paper, produce.PaperSize, produce.PrintSize, fmt.Sprintf("%d", produce.OrderCount), priceStr, budgetAmount, deliveryTime, produce.Remark)
+			// 	} else {
+			// 		DrawRow(b.Row, produce.Name, produce.Norm, produce.Paper, produce.PaperSize, produce.PrintSize, fmt.Sprintf("%d", produce.OrderCount), realCount, priceStr, budgetAmount, realPrice, deliveryTime, produce.Remark)
 
-				}
+			// 	}
 
-			}
+			// }
 			b.Row++
 		}
 	}
@@ -435,30 +466,30 @@ func (b *ProduceBillExcel) drawTableFooter() error {
 	})
 
 	sendToStartCell := fmt.Sprintf("A%d", b.Row)
-	sendToEndCell := fmt.Sprintf("G%d", b.Row)
-	supplierStartCell := fmt.Sprintf("H%d", b.Row)
-	supplierEndCell := fmt.Sprintf("L%d", b.Row)
+	// sendToEndCell := fmt.Sprintf("G%d", b.Row)
+	// supplierStartCell := fmt.Sprintf("H%d", b.Row)
+	// supplierEndCell := fmt.Sprintf("L%d", b.Row)
 
+	// // !isPrint
+	// if !b.Content.IsPrint {
+	// 	sendToEndCell = fmt.Sprintf("F%d", b.Row)
+	// 	supplierStartCell = fmt.Sprintf("G%d", b.Row)
+	// 	supplierEndCell = fmt.Sprintf("I%d", b.Row)
+	// }
+
+	// !!isPdf
+	// if b.IsPdf == "true" {
+	sendToEndCell := fmt.Sprintf("E%d", b.Row)
+	supplierStartCell := fmt.Sprintf("F%d", b.Row)
+	supplierEndCell := fmt.Sprintf("J%d", b.Row)
 	// !isPrint
 	if !b.Content.IsPrint {
-		sendToEndCell = fmt.Sprintf("F%d", b.Row)
-		supplierStartCell = fmt.Sprintf("G%d", b.Row)
-		supplierEndCell = fmt.Sprintf("I%d", b.Row)
+		sendToEndCell = fmt.Sprintf("D%d", b.Row)
+		supplierStartCell = fmt.Sprintf("E%d", b.Row)
+		supplierEndCell = fmt.Sprintf("G%d", b.Row)
 	}
 
-	// !!isPdf
-	if b.IsPdf == "true" {
-		sendToEndCell = fmt.Sprintf("E%d", b.Row)
-		supplierStartCell = fmt.Sprintf("F%d", b.Row)
-		supplierEndCell = fmt.Sprintf("J%d", b.Row)
-		// !isPrint
-		if !b.Content.IsPrint {
-			sendToEndCell = fmt.Sprintf("D%d", b.Row)
-			supplierStartCell = fmt.Sprintf("E%d", b.Row)
-			supplierEndCell = fmt.Sprintf("G%d", b.Row)
-		}
-
-	}
+	// }
 
 	b.Excel.MergeCell(b.SheetName, sendToStartCell, sendToEndCell)
 	b.Excel.SetCellStyle(b.SheetName, sendToStartCell, sendToEndCell, styleLeft)
@@ -485,39 +516,39 @@ func (b *ProduceBillExcel) drawTableSignature() error {
 	b.Excel.MergeCell(b.SheetName, billUserCellS, billUserCellE)
 	b.Excel.SetCellValue(b.SheetName, billUserCellS, "制单人:"+b.Content.UserName)
 
-	fontNum := "H"
-	image1s := "I"
-	image2s := "K"
-	image1e := "J"
-	image2e := "L"
+	// fontNum := "H"
+	// image1s := "I"
+	// image2s := "K"
+	// image1e := "J"
+	// image2e := "L"
 
-	// !isPrint
-	if !b.Content.IsPrint {
-		fontNum = "E"
-		image1s = "F"
-		image2s = "H"
-		image1e = "G"
-		image2e = "I"
+	// // !isPrint
+	// if !b.Content.IsPrint {
+	// 	fontNum = "E"
+	// 	image1s = "F"
+	// 	image2s = "H"
+	// 	image1e = "G"
+	// 	image2e = "I"
 
-	}
+	// }
 
 	// !!isPdf
-	if b.IsPdf == "true" {
-		fontNum = "F"
-		image1s = "G"
-		image2s = "I"
-		image1e = "H"
-		image2e = "J"
-		if !b.Content.IsPrint {
-			fontNum = "D"
-			image1s = "E"
-			image2s = "G"
-			image1e = "F"
-			image2e = "G"
-		}
-
+	// if b.IsPdf == "true" {
+	fontNum := "F"
+	image1s := "G"
+	image2s := "I"
+	image1e := "H"
+	image2e := "J"
+	if !b.Content.IsPrint {
+		fontNum = "D"
+		image1s = "E"
+		image2s = "G"
+		image1e = "F"
+		image2e = "G"
 	}
 
+	// }
+
 	fontCell := fmt.Sprintf("%s%d", fontNum, b.Row)
 	fontEndCell := fmt.Sprintf("%s%d", fontNum, b.Row+2)
 
@@ -589,10 +620,10 @@ func NewProduceBill(f *excelize.File) *ProduceBillExcel {
 		Signatures:       make([]*model.Signature, 0),
 	}
 
-	f.SetColWidth(b.SheetName, "A", "A", 12)
-	f.SetColWidth(b.SheetName, "B", "K", 9.5)
-	// f.SetColWidth(b.SheetName, "I", "J", 8)
-	f.SetColWidth(b.SheetName, "L", "L", 10)
+	// f.SetColWidth(b.SheetName, "A", "A", 12)
+	// f.SetColWidth(b.SheetName, "B", "K", 9.5)
+	// // f.SetColWidth(b.SheetName, "I", "J", 8)
+	// f.SetColWidth(b.SheetName, "L", "L", 10)
 	f.SetPageMargins(b.SheetName, excelize.PageMarginTop(0), excelize.PageMarginLeft(0), excelize.PageMarginRight(0))
 
 	return b

+ 255 - 240
boxcost/api/bill-product-excel.go

@@ -3,7 +3,6 @@ package api
 import (
 	"box-cost/db/model"
 	"fmt"
-	"regexp"
 
 	_ "image/gif"
 	_ "image/jpeg"
@@ -34,17 +33,17 @@ type ProductBillExcel struct {
 func (b *ProductBillExcel) drawTitle() error {
 	b.Row++
 	startCell := fmt.Sprintf("A%d", b.Row)
-	endCell := fmt.Sprintf("J%d", b.Row)
-	marginLeft := excelize.PageMarginLeft(0.2)
+	// endCell := fmt.Sprintf("J%d", b.Row)
+	// marginLeft := excelize.PageMarginLeft(0.2)
 	// !!isPdf
-	if b.IsPdf == "true" {
-		endCell = fmt.Sprintf("H%d", b.Row)
-		marginLeft = excelize.PageMarginLeft(0.6)
-		b.Excel.SetColWidth(b.SheetName, "A", "A", 18)
-		b.Excel.SetColWidth(b.SheetName, "B", "B", 14)
-		b.Excel.SetColWidth(b.SheetName, "C", "G", 12)
-		b.Excel.SetColWidth(b.SheetName, "H", "H", 18)
-	}
+	// if b.IsPdf == "true" {
+	endCell := fmt.Sprintf("H%d", b.Row)
+	marginLeft := excelize.PageMarginLeft(0.35)
+	b.Excel.SetColWidth(b.SheetName, "A", "A", 17)
+	b.Excel.SetColWidth(b.SheetName, "B", "B", 14)
+	b.Excel.SetColWidth(b.SheetName, "C", "G", 12)
+	b.Excel.SetColWidth(b.SheetName, "H", "H", 22)
+	// }
 	b.Excel.SetPageMargins(b.SheetName, marginLeft)
 	err := b.Excel.MergeCell(b.SheetName, startCell, endCell)
 	if err != nil {
@@ -81,7 +80,39 @@ func (b *ProductBillExcel) drawSubTitles() error {
 		return err
 	}
 
-	var drawLeft = func(rowIndex int, value string) error {
+	// var 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))
+	// 	if err != nil {
+	// 		return err
+	// 	}
+	// 	err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left1Cell, styleLeft)
+	// 	if err != nil {
+	// 		return err
+	// 	}
+	// 	b.Excel.SetCellValue(b.SheetName, left1Cell, value)
+	// 	return nil
+	// }
+
+	// var drawRight = func(rowIndex int, value string) error {
+	// 	right1Cell := fmt.Sprintf("G%d", rowIndex)
+	// 	err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("J%d", rowIndex))
+	// 	if err != nil {
+	// 		return err
+	// 	}
+	// 	err = b.Excel.SetCellStyle(b.SheetName, right1Cell, right1Cell, styleRight)
+	// 	if err != nil {
+	// 		return err
+	// 	}
+	// 	b.Excel.SetCellValue(b.SheetName, right1Cell, value)
+	// 	return nil
+	// }
+
+	// !!isPdf
+	// if b.IsPdf == "true" {
+
+	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))
@@ -96,9 +127,9 @@ func (b *ProductBillExcel) drawSubTitles() error {
 		return nil
 	}
 
-	var drawRight = func(rowIndex int, value string) error {
+	drawRight := func(rowIndex int, value string) error {
 		right1Cell := fmt.Sprintf("G%d", rowIndex)
-		err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("J%d", rowIndex))
+		err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("H%d", rowIndex))
 		if err != nil {
 			return err
 		}
@@ -110,46 +141,14 @@ func (b *ProductBillExcel) drawSubTitles() error {
 		return nil
 	}
 
-	// !!isPdf
-	if b.IsPdf == "true" {
-
-		drawLeft = func(rowIndex int, value string) error {
-			//左边1
-			left1Cell := fmt.Sprintf("A%d", rowIndex)
-			err = b.Excel.MergeCell(b.SheetName, left1Cell, fmt.Sprintf("D%d", rowIndex))
-			if err != nil {
-				return err
-			}
-			err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left1Cell, styleLeft)
-			if err != nil {
-				return err
-			}
-			b.Excel.SetCellValue(b.SheetName, left1Cell, value)
-			return nil
-		}
-
-		drawRight = func(rowIndex int, value string) error {
-			right1Cell := fmt.Sprintf("E%d", rowIndex)
-			err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("H%d", rowIndex))
-			if err != nil {
-				return err
-			}
-			err = b.Excel.SetCellStyle(b.SheetName, right1Cell, right1Cell, styleRight)
-			if err != nil {
-				return err
-			}
-			b.Excel.SetCellValue(b.SheetName, right1Cell, value)
-			return nil
-		}
-
-	}
+	// }
 	//第一行
-	drawLeft(b.Row, "需求方(甲方):"+b.Title+"订单")
+	drawLeft(b.Row, "类别:"+b.Content.Type)
 	drawRight(b.Row, "单号:"+b.Content.SerialNumber)
 	b.Excel.SetRowHeight(b.SheetName, b.Row, 21)
 
 	//第二行
-	drawLeft(b.Row+1, "供应方(乙方):"+b.Content.Supplier)
+	drawLeft(b.Row+1, "供应商名称:"+b.Content.Supplier)
 	timeformat := b.Content.CreateTime.Local().Format("2006年01月02号 15:04:05")
 	drawRight(b.Row+1, "下单时间:"+timeformat)
 	b.Excel.SetRowHeight(b.SheetName, b.Row+1, 21)
@@ -189,27 +188,27 @@ func (b *ProductBillExcel) drawTableTitle() error {
 	}
 
 	// !!isPdf
-	if b.IsPdf == "true" {
-		drawCol("A", "采购项目")
-		drawCol("B", "规格")
-		drawCol("C", "下单数量")
-		drawCol("D", "单位")
-		drawCol("E", "单价")
-		drawCol("F", "预算金额")
-		drawCol("G", "交货时间")
-		drawCol("H", "备注")
-	} else {
-		drawCol("A", "采购项目")
-		drawCol("B", "规格")
-		drawCol("C", "下单数量")
-		drawCol("D", "单位")
-		drawCol("E", "完成数量")
-		drawCol("F", "单价")
-		drawCol("G", "预算金额")
-		drawCol("H", "实际金额")
-		drawCol("I", "交货时间")
-		drawCol("J", "备注")
-	}
+	// if b.IsPdf == "true" {
+	drawCol("A", "采购项目")
+	drawCol("B", "规格")
+	drawCol("C", "下单数量")
+	drawCol("D", "单位")
+	drawCol("E", "单价")
+	drawCol("F", "预算金额")
+	drawCol("G", "交货时间")
+	drawCol("H", "备注")
+	// } else {
+	// 	drawCol("A", "采购项目")
+	// 	drawCol("B", "规格")
+	// 	drawCol("C", "下单数量")
+	// 	drawCol("D", "单位")
+	// 	drawCol("E", "完成数量")
+	// 	drawCol("F", "单价")
+	// 	drawCol("G", "预算金额")
+	// 	drawCol("H", "实际金额")
+	// 	drawCol("I", "交货时间")
+	// 	drawCol("J", "备注")
+	// }
 
 	return nil
 }
@@ -218,11 +217,11 @@ 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", "I", "J"}
+		// charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"}
 		// !!isPdf
-		if b.IsPdf == "true" {
-			charas = []string{"A", "B", "C", "D", "E", "F", "G", "H"}
-		}
+		// if b.IsPdf == "true" {
+		charas := []string{"A", "B", "C", "D", "E", "F", "G", "H"}
+		// }
 		for i, c := range charas {
 			v := ""
 			if i < len(values) {
@@ -259,11 +258,11 @@ func (b *ProductBillExcel) drawTableContent() error {
 			b.FormatToEmpty(&price)
 
 			// !!isPdf
-			if b.IsPdf == "true" {
-				DrawRow(b.Row, product.Name, product.Norm, orderCount, product.Unit, price, budgetAmount, deliveryTime, product.Remark)
-			} else {
-				DrawRow(b.Row, product.Name, product.Norm, orderCount, product.Unit, realCount, price, budgetAmount, realPrice, deliveryTime, product.Remark)
-			}
+			// if b.IsPdf == "true" {
+			DrawRow(b.Row, product.Name, product.Norm, orderCount, product.Unit, price, budgetAmount, deliveryTime, product.Remark)
+			// } else {
+			// 	DrawRow(b.Row, product.Name, product.Norm, orderCount, product.Unit, realCount, price, budgetAmount, realPrice, deliveryTime, product.Remark)
+			// }
 
 			b.Row++
 		}
@@ -286,199 +285,215 @@ func (b *ProductBillExcel) drawTableFooter() error {
 	})
 
 	sendToStartCell := fmt.Sprintf("A%d", b.Row)
-	sendToEndCell := fmt.Sprintf("G%d", b.Row)
-	supplierStartCell := fmt.Sprintf("H%d", b.Row)
-	supplierEndCell := fmt.Sprintf("J%d", b.Row)
+	// sendToEndCell := fmt.Sprintf("G%d", b.Row)
+	// supplierStartCell := fmt.Sprintf("H%d", b.Row)
+	// supplierEndCell := fmt.Sprintf("J%d", b.Row)
 
 	// !!isPdf
-	if b.IsPdf == "true" {
-		sendToEndCell = fmt.Sprintf("E%d", b.Row)
-		supplierStartCell = fmt.Sprintf("F%d", b.Row)
-		supplierEndCell = fmt.Sprintf("H%d", b.Row)
+	// if b.IsPdf == "true" {
+	sendToEndCell := fmt.Sprintf("E%d", b.Row)
+	supplierStartCell := fmt.Sprintf("F%d", b.Row)
+	supplierEndCell := fmt.Sprintf("H%d", b.Row)
 
-	}
+	// }
 
 	b.Excel.MergeCell(b.SheetName, sendToStartCell, sendToEndCell)
 	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.Excel.SetCellStyle(b.SheetName, supplierStartCell, supplierEndCell, styleLeft)
-	b.Excel.SetCellValue(b.SheetName, supplierStartCell, " 收货人:")
+	b.Excel.SetCellValue(b.SheetName, supplierStartCell, " 供应商签字:")
 	b.Excel.SetRowHeight(b.SheetName, b.Row, 21)
 
 	return nil
 }
 
-func (b *ProductBillExcel) drawRemark() error {
-	// 填备注
-	b.Row++
-	remarkTitleCell := fmt.Sprintf("A%d", b.Row)
-	b.Excel.SetCellValue(b.SheetName, remarkTitleCell, "备注:")
-	b.Row++
+// func (b *ProductBillExcel) drawRemark() error {
+// 	// 填备注
+// 	b.Row++
+// 	remarkTitleCell := fmt.Sprintf("A%d", b.Row)
+// 	b.Excel.SetCellValue(b.SheetName, remarkTitleCell, "备注:")
+// 	b.Row++
+
+// 	remarkContentScell := fmt.Sprintf("A%d", b.Row)
+// 	// 预留五行备注内容
+// 	reg := regexp.MustCompile(`\n`)
+// 	remarkRowNum := len(reg.FindAllString(b.Content.Remark, -1)) + 1
+// 	b.Row += remarkRowNum
+// 	// remarkContentEcell := fmt.Sprintf("J%d", b.Row)
+// 	// // !!isPdf
+// 	// if b.IsPdf == "true" {
+// 	remarkContentEcell := fmt.Sprintf("H%d", b.Row)
+// 	// }
+// 	b.Excel.MergeCell(b.SheetName, remarkContentScell, remarkContentEcell)
+// 	b.Excel.SetCellValue(b.SheetName, remarkContentScell, b.Content.Remark)
+
+// 	// 签字位置
+// 	b.Row += 2
+// 	styleLeft, err := b.Excel.NewStyle(&excelize.Style{
+// 		Alignment: &excelize.Alignment{Horizontal: "left", Vertical: "center"},
+// 		Font:      &excelize.Font{Size: 11}})
+// 	if err != nil {
+// 		return err
+// 	}
+// 	// var drawLeft = func(rowIndex int, value string) error {
+// 	// 	//左边1
+// 	// 	left1Cell := fmt.Sprintf("A%d", rowIndex)
+// 	// 	err := b.Excel.MergeCell(b.SheetName, left1Cell, fmt.Sprintf("E%d", rowIndex))
+// 	// 	if err != nil {
+// 	// 		return err
+// 	// 	}
+// 	// 	err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left1Cell, styleLeft)
+// 	// 	if err != nil {
+// 	// 		return err
+// 	// 	}
+// 	// 	b.Excel.SetCellValue(b.SheetName, left1Cell, value)
+// 	// 	return nil
+// 	// }
+
+// 	// var drawRight = func(rowIndex int, value string) error {
+// 	// 	right1Cell := fmt.Sprintf("F%d", rowIndex)
+// 	// 	err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("J%d", rowIndex))
+// 	// 	if err != nil {
+// 	// 		return err
+// 	// 	}
+// 	// 	err = b.Excel.SetCellStyle(b.SheetName, right1Cell, right1Cell, styleLeft)
+// 	// 	if err != nil {
+// 	// 		return err
+// 	// 	}
+// 	// 	b.Excel.SetCellValue(b.SheetName, right1Cell, value)
+// 	// 	return nil
+// 	// }
+
+// 	// !!isPdf
+// 	// if b.IsPdf == "true" {
+// 	drawLeft := func(rowIndex int, value string) error {
+// 		//左边1
+// 		left1Cell := fmt.Sprintf("A%d", rowIndex)
+// 		err := b.Excel.MergeCell(b.SheetName, left1Cell, fmt.Sprintf("E%d", rowIndex))
+// 		if err != nil {
+// 			return err
+// 		}
+// 		err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left1Cell, styleLeft)
+// 		if err != nil {
+// 			return err
+// 		}
+// 		b.Excel.SetCellValue(b.SheetName, left1Cell, value)
+// 		return nil
+// 	}
 
-	remarkContentScell := fmt.Sprintf("A%d", b.Row)
-	// 预留五行备注内容
-	reg := regexp.MustCompile(`\n`)
-	remarkRowNum := len(reg.FindAllString(b.Content.Remark, -1)) + 1
-	b.Row += remarkRowNum
-	remarkContentEcell := fmt.Sprintf("J%d", b.Row)
-	// !!isPdf
-	if b.IsPdf == "true" {
-		remarkContentEcell = fmt.Sprintf("H%d", b.Row)
-	}
-	b.Excel.MergeCell(b.SheetName, remarkContentScell, remarkContentEcell)
-	b.Excel.SetCellValue(b.SheetName, remarkContentScell, b.Content.Remark)
+// 	drawRight := func(rowIndex int, value string) error {
+// 		right1Cell := fmt.Sprintf("F%d", rowIndex)
+// 		err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("H%d", rowIndex))
+// 		if err != nil {
+// 			return err
+// 		}
+// 		err = b.Excel.SetCellStyle(b.SheetName, right1Cell, right1Cell, styleLeft)
+// 		if err != nil {
+// 			return err
+// 		}
+// 		b.Excel.SetCellValue(b.SheetName, right1Cell, value)
+// 		return nil
+// 	}
+// 	// }
+
+// 	//第一行
+// 	drawLeft(b.Row, "甲方:"+b.Title)
+// 	drawRight(b.Row, "乙方:"+b.Content.Supplier)
+// 	b.Excel.SetRowHeight(b.SheetName, b.Row, 21)
+
+// 	//第二行
+// 	drawLeft(b.Row+1, "联系人:")
+// 	timeformat := b.Content.CreateTime.Local().Format("2006年01月02号")
+// 	drawRight(b.Row+1, "联系人:")
+// 	b.Excel.SetRowHeight(b.SheetName, b.Row+1, 21)
+
+// 	//第三行
+// 	drawLeft(b.Row+2, "时间:"+timeformat)
+// 	drawRight(b.Row+2, "时间:"+timeformat)
+// 	b.Excel.SetRowHeight(b.SheetName, b.Row+2, 21)
+// 	b.Row += 2
+
+// 	return nil
 
-	// 签字位置
+// }
+
+func (b *ProductBillExcel) drawTableSignature() error {
 	b.Row += 2
-	styleLeft, err := b.Excel.NewStyle(&excelize.Style{
-		Alignment: &excelize.Alignment{Horizontal: "left", Vertical: "center"},
-		Font:      &excelize.Font{Size: 11}})
-	if err != nil {
-		return err
-	}
-	var drawLeft = func(rowIndex int, value string) error {
-		//左边1
-		left1Cell := fmt.Sprintf("A%d", rowIndex)
-		err := b.Excel.MergeCell(b.SheetName, left1Cell, fmt.Sprintf("E%d", rowIndex))
-		if err != nil {
-			return err
-		}
-		err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left1Cell, styleLeft)
-		if err != nil {
-			return err
-		}
-		b.Excel.SetCellValue(b.SheetName, left1Cell, value)
-		return nil
-	}
+	// row := b.Row
 
-	var drawRight = func(rowIndex int, value string) error {
-		right1Cell := fmt.Sprintf("F%d", rowIndex)
-		err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("J%d", rowIndex))
-		if err != nil {
-			return err
-		}
-		err = b.Excel.SetCellStyle(b.SheetName, right1Cell, right1Cell, styleLeft)
-		if err != nil {
-			return err
-		}
-		b.Excel.SetCellValue(b.SheetName, right1Cell, value)
-		return nil
-	}
+	style1, _ := b.Excel.NewStyle(&excelize.Style{
+		Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
+	})
+
+	// 制单人
+	billUserCellS := fmt.Sprintf("A%d", b.Row+1)
+	billUserCellE := fmt.Sprintf("B%d", b.Row+1)
+	b.Excel.MergeCell(b.SheetName, billUserCellS, billUserCellE)
+	b.Excel.SetCellValue(b.SheetName, billUserCellS, "制单人:"+b.Content.UserName)
+
+	// fontNum := "H"
+	// image1s := "I"
+	// image2s := "K"
+	// image1e := "J"
+	// image2e := "L"
 
 	// !!isPdf
-	if b.IsPdf == "true" {
-		drawLeft = func(rowIndex int, value string) error {
-			//左边1
-			left1Cell := fmt.Sprintf("A%d", rowIndex)
-			err := b.Excel.MergeCell(b.SheetName, left1Cell, fmt.Sprintf("E%d", rowIndex))
-			if err != nil {
-				return err
-			}
-			err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left1Cell, styleLeft)
-			if err != nil {
-				return err
-			}
-			b.Excel.SetCellValue(b.SheetName, left1Cell, value)
-			return nil
-		}
+	// if b.IsPdf == "true" {
+	fontNum := "E"
+	image1s := "F"
+	image2s := "H"
+	image1e := "G"
+	image2e := "H"
+
+	// }
+
+	fontCell := fmt.Sprintf("%s%d", fontNum, b.Row)
+	fontEndCell := fmt.Sprintf("%s%d", fontNum, b.Row+2)
+
+	imageCell1 := fmt.Sprintf("%s%d", image1s, b.Row)
+	imageEndCell1 := fmt.Sprintf("%s%d", image1e, b.Row+2)
+
+	imageCell2 := fmt.Sprintf("%s%d", image2s, b.Row)
+	imageEndCell2 := fmt.Sprintf("%s%d", image2e, b.Row+2)
+
+	b.Excel.MergeCell(b.SheetName, fontCell, fontEndCell)
+	b.Excel.SetCellStyle(b.SheetName, fontCell, fontCell, style1)
+	b.Excel.SetCellValue(b.SheetName, fontCell, "审核签字:")
+
+	// 签字图片1 I10-J12
+	b.Excel.MergeCell(b.SheetName, imageCell1, imageEndCell1)
+	b.Excel.SetCellStyle(b.SheetName, imageCell1, imageCell1, style1)
+	b.Excel.SetCellValue(b.SheetName, imageCell1, "")
+
+	// 签字图片2 K10-L12
+	b.Excel.MergeCell(b.SheetName, imageCell2, imageEndCell2)
+	b.Excel.SetCellStyle(b.SheetName, imageCell2, imageCell1, style1)
+	b.Excel.SetCellValue(b.SheetName, imageCell2, "")
+
+	if b.Content.Reviewed == 1 {
+		imageCells := []string{imageCell1, imageCell2}
+		if len(b.Signatures) > 0 {
+			for k, sign := range b.Signatures {
+				b.Excel.AddPicture(b.SheetName, imageCells[k], sign.Path, sign.Format)
 
-		drawRight = func(rowIndex int, value string) error {
-			right1Cell := fmt.Sprintf("F%d", rowIndex)
-			err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("H%d", rowIndex))
-			if err != nil {
-				return err
-			}
-			err = b.Excel.SetCellStyle(b.SheetName, right1Cell, right1Cell, styleLeft)
-			if err != nil {
-				return err
 			}
-			b.Excel.SetCellValue(b.SheetName, right1Cell, value)
-			return nil
 		}
 	}
 
-	//第一行
-	drawLeft(b.Row, "甲方:"+b.Title)
-	drawRight(b.Row, "乙方:"+b.Content.Supplier)
 	b.Excel.SetRowHeight(b.SheetName, b.Row, 21)
 
-	//第二行
-	drawLeft(b.Row+1, "联系人:")
-	timeformat := b.Content.CreateTime.Local().Format("2006年01月02号")
-	drawRight(b.Row+1, "联系人:")
-	b.Excel.SetRowHeight(b.SheetName, b.Row+1, 21)
-
-	//第三行
-	drawLeft(b.Row+2, "时间:"+timeformat)
-	drawRight(b.Row+2, "时间:"+timeformat)
-	b.Excel.SetRowHeight(b.SheetName, b.Row+2, 21)
-	b.Row += 2
-
 	return nil
-
 }
 
-// func (b *ProductBillExcel) drawTableSignature() error {
-// 	b.Row += 2
-// 	style1, _ := b.Excel.NewStyle(&excelize.Style{
-// 		Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
-// 		// Border:    border,
-// 	})
-
-// 	// 制单人
-// 	billUserCell := fmt.Sprintf("A%d", b.Row+1)
-// 	b.Excel.SetCellValue(b.SheetName, billUserCell, "制单人:"+b.Content.UserName)
-// 	// billUservCell := fmt.Sprintf("B%d", b.Row+1)
-// 	// b.Excel.SetCellValue(b.SheetName, billUservCell, b.Content.UserName)
-
-// 	fontCell := fmt.Sprintf("F%d", b.Row)
-// 	imageCell1 := fmt.Sprintf("G%d", b.Row)
-// 	imageCell2 := fmt.Sprintf("I%d", b.Row)
-// 	eRow := b.Row + 2
-// 	b.Excel.MergeCell(b.SheetName, fontCell, fmt.Sprintf("F%d", eRow))
-// 	b.Excel.SetCellStyle(b.SheetName, fontCell, fontCell, style1)
-// 	b.Excel.SetCellValue(b.SheetName, fontCell, "审核签字:")
-
-// 	b.Excel.MergeCell(b.SheetName, imageCell1, fmt.Sprintf("H%d", eRow))
-// 	b.Excel.SetCellStyle(b.SheetName, imageCell1, imageCell1, style1)
-// 	b.Excel.SetCellValue(b.SheetName, imageCell1, "")
-
-// 	b.Excel.MergeCell(b.SheetName, imageCell2, fmt.Sprintf("J%d", eRow))
-// 	b.Excel.SetCellStyle(b.SheetName, imageCell2, imageCell1, style1)
-// 	b.Excel.SetCellValue(b.SheetName, imageCell2, "")
-
-// 	// 状态为已审核时,签字
-// 	// `{
-// 	// 	"x_scale": 0.12,
-// 	// 	"y_scale": 0.12,
-// 	// 	"x_offset": 30,
-// 	// 	"print_obj": true,
-// 	// 	"lock_aspect_ratio": false,
-// 	// 	"locked": false,
-// 	// 	"positioning": "oncell"
-// 	// }`
-// 	if b.Content.Reviewed == 1 {
-// 		imageCells := []string{imageCell1, imageCell2}
-// 		if len(b.Signatures) > 0 {
-// 			for k, sign := range b.Signatures {
-// 				b.Excel.AddPicture(b.SheetName, imageCells[k], sign.Path, sign.Format)
-
-// 			}
-// 		}
-// 	}
-
-// 	return nil
-// }
-
 func (b *ProductBillExcel) Draws() {
 	b.drawTitle()
 	b.drawSubTitles()
 	b.drawTableTitle()
 	b.drawTableContent()
 	b.drawTableFooter()
-	b.drawRemark()
-	// b.drawTableSignature()
+	// b.drawRemark()
+	b.drawTableSignature()
 }
 
 func NewProductBill(f *excelize.File) *ProductBillExcel {
@@ -505,10 +520,10 @@ func NewProductBill(f *excelize.File) *ProductBillExcel {
 		Signatures:       make([]*model.Signature, 0),
 	}
 
-	f.SetColWidth(b.SheetName, "A", "A", 17)
-	f.SetColWidth(b.SheetName, "B", "B", 12)
-	f.SetColWidth(b.SheetName, "C", "H", 10.5)
-	f.SetColWidth(b.SheetName, "I", "J", 12)
+	// f.SetColWidth(b.SheetName, "A", "A", 17)
+	// f.SetColWidth(b.SheetName, "B", "B", 12)
+	// f.SetColWidth(b.SheetName, "C", "H", 10.5)
+	// f.SetColWidth(b.SheetName, "I", "J", 12)
 	f.SetPageMargins(b.SheetName, excelize.PageMarginTop(1), excelize.PageMarginLeft(0.25), excelize.PageMarginRight(0))
 	return b
 }

+ 104 - 104
boxcost/api/bill-purchase-excel.go

@@ -31,19 +31,19 @@ type PurchaseBillExcel struct {
 }
 
 func (b *PurchaseBillExcel) drawTitle() error {
-	marginLeft := excelize.PageMarginLeft(0.15)
+	// marginLeft := excelize.PageMarginLeft(0.15)
 
 	b.Row++
 	startCell := fmt.Sprintf("A%d", b.Row)
-	endCell := fmt.Sprintf("L%d", b.Row)
-	// !!isPdf
-	if b.IsPdf == "true" {
-		endCell = fmt.Sprintf("J%d", b.Row)
-		marginLeft = excelize.PageMarginLeft(0.2)
-		b.Excel.SetColWidth(b.SheetName, "A", "B", 14)
-		b.Excel.SetColWidth(b.SheetName, "C", "I", 10.5)
-		b.Excel.SetColWidth(b.SheetName, "J", "J", 14)
-	}
+	// endCell := fmt.Sprintf("L%d", b.Row)
+	// // !!isPdf
+	// if b.IsPdf == "true" {
+	endCell := fmt.Sprintf("J%d", b.Row)
+	marginLeft := excelize.PageMarginLeft(0.2)
+	b.Excel.SetColWidth(b.SheetName, "A", "B", 14)
+	b.Excel.SetColWidth(b.SheetName, "C", "I", 10.5)
+	b.Excel.SetColWidth(b.SheetName, "J", "J", 14)
+	// }
 	b.Excel.SetPageMargins(b.SheetName, marginLeft)
 	err := b.Excel.MergeCell(b.SheetName, startCell, endCell)
 	if err != nil {
@@ -80,10 +80,42 @@ func (b *PurchaseBillExcel) drawSubTitles() error {
 		return err
 	}
 
-	var drawLeft = func(rowIndex int, value string) error {
+	// var 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))
+	// 	if err != nil {
+	// 		return err
+	// 	}
+	// 	err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left1Cell, styleLeft)
+	// 	if err != nil {
+	// 		return err
+	// 	}
+	// 	b.Excel.SetCellValue(b.SheetName, left1Cell, value)
+	// 	return nil
+	// }
+
+	// var drawRight = func(rowIndex int, value string) error {
+	// 	right1Cell := fmt.Sprintf("G%d", rowIndex)
+	// 	err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("L%d", rowIndex))
+	// 	if err != nil {
+	// 		return err
+	// 	}
+	// 	err = b.Excel.SetCellStyle(b.SheetName, right1Cell, right1Cell, styleRight)
+	// 	if err != nil {
+	// 		return err
+	// 	}
+	// 	b.Excel.SetCellValue(b.SheetName, right1Cell, value)
+	// 	return nil
+	// }
+
+	// !!isPdf
+	// if b.IsPdf == "true" {
+
+	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,9 +127,9 @@ func (b *PurchaseBillExcel) drawSubTitles() error {
 		return nil
 	}
 
-	var drawRight = func(rowIndex int, value string) error {
-		right1Cell := fmt.Sprintf("G%d", rowIndex)
-		err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("L%d", rowIndex))
+	drawRight := func(rowIndex int, value string) error {
+		right1Cell := fmt.Sprintf("H%d", rowIndex)
+		err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("J%d", rowIndex))
 		if err != nil {
 			return err
 		}
@@ -109,39 +141,7 @@ func (b *PurchaseBillExcel) drawSubTitles() error {
 		return nil
 	}
 
-	// !!isPdf
-	if b.IsPdf == "true" {
-
-		drawLeft = func(rowIndex int, value string) error {
-			//左边1
-			left1Cell := fmt.Sprintf("A%d", rowIndex)
-			err = b.Excel.MergeCell(b.SheetName, left1Cell, fmt.Sprintf("E%d", rowIndex))
-			if err != nil {
-				return err
-			}
-			err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left1Cell, styleLeft)
-			if err != nil {
-				return err
-			}
-			b.Excel.SetCellValue(b.SheetName, left1Cell, value)
-			return nil
-		}
-
-		drawRight = func(rowIndex int, value string) error {
-			right1Cell := fmt.Sprintf("F%d", rowIndex)
-			err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("J%d", rowIndex))
-			if err != nil {
-				return err
-			}
-			err = b.Excel.SetCellStyle(b.SheetName, right1Cell, right1Cell, styleRight)
-			if err != nil {
-				return err
-			}
-			b.Excel.SetCellValue(b.SheetName, right1Cell, value)
-			return nil
-		}
-
-	}
+	// }
 
 	//第一行
 	drawLeft(b.Row, "类别:"+b.Content.Type)
@@ -233,28 +233,28 @@ func (b *PurchaseBillExcel) drawTableTitle() error {
 	}
 
 	// !!isPdf
-	if b.IsPdf == "true" {
-		drawCol("A", "采购项目")
-		drawCol("B", "规格(克)")
-		drawCol2("C", "D", "尺寸(mm)", "长", "宽")
-		drawCol("E", "下单数量")
-		drawCol2("F", "G", "单价", unit1, unit2)
-		drawCol("H", "预算金额")
-		drawCol("I", "交货时间")
-		drawCol("J", "备注")
-
-	} else {
-		drawCol("A", "采购项目")
-		drawCol("B", "规格(克)")
-		drawCol2("C", "D", "尺寸(mm)", "长", "宽")
-		drawCol("E", "下单数量")
-		drawCol("F", "完成数量")
-		drawCol2("G", "H", "单价", unit1, unit2)
-		drawCol("I", "预算金额")
-		drawCol("J", "实际金额")
-		drawCol("K", "交货时间")
-		drawCol("L", "备注")
-	}
+	// if b.IsPdf == "true" {
+	drawCol("A", "采购项目")
+	drawCol("B", "规格(克)")
+	drawCol2("C", "D", "尺寸(mm)", "长", "宽")
+	drawCol("E", "下单数量")
+	drawCol2("F", "G", "单价", unit1, unit2)
+	drawCol("H", "预算金额")
+	drawCol("I", "交货时间")
+	drawCol("J", "备注")
+
+	// } else {
+	// 	drawCol("A", "采购项目")
+	// 	drawCol("B", "规格(克)")
+	// 	drawCol2("C", "D", "尺寸(mm)", "长", "宽")
+	// 	drawCol("E", "下单数量")
+	// 	drawCol("F", "完成数量")
+	// 	drawCol2("G", "H", "单价", unit1, unit2)
+	// 	drawCol("I", "预算金额")
+	// 	drawCol("J", "实际金额")
+	// 	drawCol("K", "交货时间")
+	// 	drawCol("L", "备注")
+	// }
 
 	return nil
 }
@@ -263,11 +263,11 @@ func (b *PurchaseBillExcel) drawTableContent() error {
 	b.Row += 2
 
 	var DrawRow = func(rowIndex int, values ...string) {
-		charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"}
+		// charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"}
 		// !!isPdf
-		if b.IsPdf == "true" {
-			charas = []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"}
-		}
+		// if b.IsPdf == "true" {
+		charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"}
+		// }
 		for i, c := range charas {
 			v := ""
 			if i < len(values) {
@@ -302,12 +302,12 @@ func (b *PurchaseBillExcel) drawTableContent() error {
 			realPrice = fmt.Sprintf("%.3f", paper.OrderPrice*float64(paper.ConfirmCount))
 			b.FormatToEmpty(&realPrice)
 			// !!isPdf
-			if b.IsPdf == "true" {
-				DrawRow(b.Row, paper.Name, paper.Norm, paper.Height, paper.Width, fmt.Sprintf("%d", paper.OrderCount), price, price2, budgetAmount, deliveryTime, paper.Remark)
-			} else {
-				DrawRow(b.Row, paper.Name, paper.Norm, paper.Height, paper.Width, fmt.Sprintf("%d", paper.OrderCount), realCount, price, price2, budgetAmount, realPrice, deliveryTime, paper.Remark)
+			// if b.IsPdf == "true" {
+			DrawRow(b.Row, paper.Name, paper.Norm, paper.Height, paper.Width, fmt.Sprintf("%d", paper.OrderCount), price, price2, budgetAmount, deliveryTime, paper.Remark)
+			// } else {
+			// 	DrawRow(b.Row, paper.Name, paper.Norm, paper.Height, paper.Width, fmt.Sprintf("%d", paper.OrderCount), realCount, price, price2, budgetAmount, realPrice, deliveryTime, paper.Remark)
 
-			}
+			// }
 
 			b.Row++
 		}
@@ -330,17 +330,17 @@ func (b *PurchaseBillExcel) drawTableFooter() error {
 	})
 
 	sendToStartCell := fmt.Sprintf("A%d", b.Row)
-	sendToEndCell := fmt.Sprintf("G%d", b.Row)
-	supplierStartCell := fmt.Sprintf("H%d", b.Row)
-	supplierEndCell := fmt.Sprintf("L%d", b.Row)
+	// sendToEndCell := fmt.Sprintf("G%d", b.Row)
+	// supplierStartCell := fmt.Sprintf("H%d", b.Row)
+	// supplierEndCell := fmt.Sprintf("L%d", b.Row)
 
 	// !!isPdf
-	if b.IsPdf == "true" {
-		sendToEndCell = fmt.Sprintf("E%d", b.Row)
-		supplierStartCell = fmt.Sprintf("F%d", b.Row)
-		supplierEndCell = fmt.Sprintf("J%d", b.Row)
+	// if b.IsPdf == "true" {
+	sendToEndCell := fmt.Sprintf("E%d", b.Row)
+	supplierStartCell := fmt.Sprintf("F%d", b.Row)
+	supplierEndCell := fmt.Sprintf("J%d", b.Row)
 
-	}
+	// }
 	b.Excel.MergeCell(b.SheetName, sendToStartCell, sendToEndCell)
 	b.Excel.SetCellStyle(b.SheetName, sendToStartCell, sendToEndCell, styleLeft)
 	b.Excel.SetCellValue(b.SheetName, sendToStartCell, "送货地址:"+b.Content.SendTo)
@@ -366,21 +366,21 @@ func (b *PurchaseBillExcel) drawTableSignature() error {
 	b.Excel.MergeCell(b.SheetName, billUserCellS, billUserCellE)
 	b.Excel.SetCellValue(b.SheetName, billUserCellS, "制单人:"+b.Content.UserName)
 
-	fontNum := "H"
-	image1s := "I"
-	image2s := "K"
-	image1e := "J"
-	image2e := "L"
+	// fontNum := "H"
+	// image1s := "I"
+	// image2s := "K"
+	// image1e := "J"
+	// image2e := "L"
 
 	// !!isPdf
-	if b.IsPdf == "true" {
-		fontNum = "F"
-		image1s = "G"
-		image2s = "I"
-		image1e = "H"
-		image2e = "J"
+	// if b.IsPdf == "true" {
+	fontNum := "F"
+	image1s := "G"
+	image2s := "I"
+	image1e := "H"
+	image2e := "J"
 
-	}
+	// }
 
 	fontCell := fmt.Sprintf("%s%d", fontNum, b.Row)
 	fontEndCell := fmt.Sprintf("%s%d", fontNum, b.Row+2)
@@ -453,11 +453,11 @@ func NewPurchaseBill(f *excelize.File) *PurchaseBillExcel {
 		Signatures:       make([]*model.Signature, 0),
 	}
 
-	f.SetColWidth(b.SheetName, "A", "A", 15)
-	f.SetColWidth(b.SheetName, "B", "B", 15)
-	f.SetColWidth(b.SheetName, "C", "G", 7)
-	f.SetColWidth(b.SheetName, "H", "K", 10)
-	f.SetColWidth(b.SheetName, "L", "L", 11)
+	// f.SetColWidth(b.SheetName, "A", "A", 15)
+	// f.SetColWidth(b.SheetName, "B", "B", 15)
+	// f.SetColWidth(b.SheetName, "C", "G", 7)
+	// f.SetColWidth(b.SheetName, "H", "K", 10)
+	// f.SetColWidth(b.SheetName, "L", "L", 11)
 	f.SetPageMargins(b.SheetName, excelize.PageMarginTop(0), excelize.PageMarginLeft(0), excelize.PageMarginRight(0))
 	return b
 }

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

@@ -90,7 +90,7 @@ type ProduceBillData struct {
 	//单价 数量
 	Price float64 `bson:"price,omitempty" json:"price"`
 
-	Price2 float64 `bson:"price2,omitempty" json:"price2"`
+	Price2 float64 `bson:"price2,omitempty" json:"price2"` // 对应unit2
 
 	// 下单数量
 	OrderCount int `bson:"orderCount,omitempty" json:"orderCount"`
@@ -110,13 +110,14 @@ type ProduceBillData struct {
 	//来纸尺寸
 	PaperSize string `bson:"paperSize,omitempty" json:"paperSize"`
 
-	//印刷尺寸
+	//印刷尺寸/覆膜尺寸
 	PrintSize string `bson:"printSize,omitempty" json:"printSize"`
 
 	//交货时间
 	DeliveryTime time.Time `bson:"deliveryTime,omitempty" json:"deliveryTime"`
 
-	Unit string `bson:"unit,omitempty" json:"unit"`
+	Unit  string `bson:"unit,omitempty" json:"unit"`
+	Unit2 string `bson:"unit2,omitempty" json:"unit2"`
 }
 
 type ProduceBill struct {
@@ -154,6 +155,7 @@ type ProduceBill struct {
 	SerialNumber string `bson:"serialNumber,omitempty" json:"serialNumber"`
 
 	IsPrint bool `bson:"isPrint,omitempty" json:"isPrint"`
+	IsLam   bool `bson:"isLam,omitempty" json:"isLam"`
 
 	// 单据类型
 	BillType string `bson:"billType,omitempty" json:"billType"`