animeic 2 years ago
parent
commit
3d8d82f037

+ 29 - 13
boxcost/api/bill-produce-excel.go

@@ -26,17 +26,20 @@ 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)
 
 	// !isPrint
 	if !b.Content.IsPrint {
-		marginLeft = excelize.PageMarginLeft(0.3)
+		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", 12)
+		b.Excel.SetColWidth(b.SheetName, "C", "H", 10.5)
 		b.Excel.SetColWidth(b.SheetName, "I", "I", 16)
 	}
 	b.Excel.SetPageMargins(b.SheetName, marginLeft)
-	startCell := fmt.Sprintf("A%d", b.Row)
-	err := b.Excel.MergeCell(b.SheetName, startCell, fmt.Sprintf("L%d", b.Row))
+
+	err := b.Excel.MergeCell(b.SheetName, startCell, endCell)
 	if err != nil {
 		return err
 	}
@@ -332,29 +335,42 @@ func (b *ProduceBillExcel) drawTableSignature() error {
 	b.Excel.SetCellStyle(b.SheetName, billUserCell, billUservCell, style2)
 	b.Excel.SetCellValue(b.SheetName, billUserCell, "制单人:"+b.Content.UserName)
 
-	fontCell := fmt.Sprintf("H%d", b.Row)
-	imageCell1 := fmt.Sprintf("I%d", b.Row)
-	imageCell2 := fmt.Sprintf("K%d", b.Row)
+	fontNum := "H"
+	image1s := "I"
+	image2s := "K"
+	image1e := "J"
+	image2e := "L"
 
 	// !isPrint
 	if !b.Content.IsPrint {
-		fontCell = fmt.Sprintf("E%d", b.Row)
-		imageCell1 = fmt.Sprintf("F%d", b.Row)
-		imageCell2 = fmt.Sprintf("H%d", b.Row)
+		fontNum = "E"
+		image1s = "F"
+		image2s = "H"
+		image1e = "G"
+		image2e = "I"
 
 	}
 
-	b.Excel.MergeCell(b.SheetName, fontCell, fmt.Sprintf("H%d", b.Row+2))
+	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, fmt.Sprintf("J%d", b.Row+2))
+	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, fmt.Sprintf("L%d", b.Row+2))
+	b.Excel.MergeCell(b.SheetName, imageCell2, imageEndCell2)
 	b.Excel.SetCellStyle(b.SheetName, imageCell2, imageCell1, style1)
 	b.Excel.SetCellValue(b.SheetName, imageCell2, "")
 

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

@@ -310,57 +310,57 @@ func (b *ProductBillExcel) drawRemark() error {
 
 }
 
-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) 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()
@@ -369,7 +369,7 @@ func (b *ProductBillExcel) Draws() {
 	b.drawTableContent()
 	b.drawTableFooter()
 	b.drawRemark()
-	b.drawTableSignature()
+	// b.drawTableSignature()
 }
 
 func NewProductBill(f *excelize.File) *ProductBillExcel {

+ 6 - 3
boxcost/api/report-produce-excel.go

@@ -28,17 +28,20 @@ type ReportProduceExcel struct {
 func (b *ReportProduceExcel) drawTitle() error {
 	// 设置外边距
 	marginLeft := excelize.PageMarginLeft(0.15)
+	endCell := fmt.Sprintf("L%d", b.Row)
+
 	// !isPrint
 	if !b.Content.IsPrint {
-		marginLeft = excelize.PageMarginLeft(0.3)
+		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", 12)
+		b.Excel.SetColWidth(b.SheetName, "C", "H", 10.5)
 		b.Excel.SetColWidth(b.SheetName, "I", "I", 16)
 	}
 	b.Excel.SetPageMargins(b.SheetName, marginLeft)
 	b.Row++
 	startCell := fmt.Sprintf("A%d", b.Row)
-	err := b.Excel.MergeCell(b.SheetName, startCell, fmt.Sprintf("L%d", b.Row))
+	err := b.Excel.MergeCell(b.SheetName, startCell, endCell)
 	if err != nil {
 		return err
 	}

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

@@ -74,6 +74,9 @@ type PurchaseBill struct {
 	SerialNumber string `bson:"serialNumber,omitempty" json:"serialNumber"`
 
 	Remark string `bson:"remark,omitempty" json:"remark"`
+
+	// 单据类型
+	BillType string `bson:"billType,omitempty" json:"billType"`
 }
 
 // 工艺生产数据
@@ -151,6 +154,9 @@ type ProduceBill struct {
 	SerialNumber string `bson:"serialNumber,omitempty" json:"serialNumber"`
 
 	IsPrint bool `bson:"isPrint,omitempty" json:"isPrint"`
+
+	// 单据类型
+	BillType string `bson:"billType,omitempty" json:"billType"`
 }
 
 // 成品采购单据
@@ -190,6 +196,9 @@ type ProductBill struct {
 
 	//备注
 	Remark string `bson:"remark,omitempty" json:"remark"`
+
+	// 单据类型
+	BillType string `bson:"billType,omitempty" json:"billType"`
 }
 
 // 工艺生产数据