animeic 2 лет назад
Родитель
Сommit
226398b44c
2 измененных файлов с 184 добавлено и 38 удалено
  1. 105 25
      boxcost/api/bill-produce-excel.go
  2. 79 13
      boxcost/api/report-produce-excel.go

+ 105 - 25
boxcost/api/bill-produce-excel.go

@@ -26,6 +26,14 @@ type ProduceBillExcel struct {
 func (b *ProduceBillExcel) drawTitle() error {
 	b.Row++
 	marginLeft := excelize.PageMarginLeft(0.15)
+
+	// !isPrint
+	if !b.Content.IsPrint {
+		marginLeft = excelize.PageMarginLeft(0.3)
+		b.Excel.SetColWidth(b.SheetName, "A", "B", 16)
+		b.Excel.SetColWidth(b.SheetName, "C", "H", 12)
+		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))
@@ -66,7 +74,7 @@ func (b *ProduceBillExcel) drawSubTitles() 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("E%d", rowIndex))
+		err = b.Excel.MergeCell(b.SheetName, left1Cell, fmt.Sprintf("F%d", rowIndex))
 		if err != nil {
 			return err
 		}
@@ -79,7 +87,7 @@ func (b *ProduceBillExcel) drawSubTitles() error {
 	}
 
 	var drawRight = func(rowIndex int, value string) error {
-		right1Cell := fmt.Sprintf("F%d", rowIndex)
+		right1Cell := fmt.Sprintf("G%d", rowIndex)
 		err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("L%d", rowIndex))
 		if err != nil {
 			return err
@@ -92,6 +100,40 @@ func (b *ProduceBillExcel) drawSubTitles() error {
 		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
+		}
+
+	}
+
 	//第一行
 	drawLeft(b.Row, "类别:"+b.Content.Type)
 	drawRight(b.Row, "单号:"+b.Content.SerialNumber)
@@ -148,18 +190,32 @@ func (b *ProduceBillExcel) drawTableTitle() error {
 		b.Excel.SetCellValue(b.SheetName, left2Cell, value2)
 		return nil
 	}
-	drawCol("A", "加工项目")
-	drawCol("B", "规格")
-	drawCol("C", "纸张")
-	drawCol("D", "来纸尺寸")
-	drawCol("E", "印刷尺寸")
-	drawCol("F", "下单数量")
-	drawCol("G", "完成数量")
-	drawCol2("H", "单价", "元/张")
-	drawCol("I", "预算金额")
-	drawCol("J", "实际金额")
-	drawCol("K", "交货时间")
-	drawCol("L", "备注")
+	// !isPrint
+	if !b.Content.IsPrint {
+		drawCol("A", "加工项目")
+		drawCol("B", "规格")
+		drawCol("F", "下单数量")
+		drawCol("G", "完成数量")
+		drawCol2("H", "单价", "元/张")
+		drawCol("I", "预算金额")
+		drawCol("J", "实际金额")
+		drawCol("K", "交货时间")
+		drawCol("L", "备注")
+
+	} 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
 }
@@ -168,6 +224,10 @@ 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"}
+		// !isPrint
+		if !b.Content.IsPrint {
+			charas = []string{"A", "B", "C", "D", "E", "F", "G", "H", "I"}
+		}
 		for i, c := range charas {
 			v := ""
 			if i < len(values) {
@@ -202,7 +262,13 @@ func (b *ProduceBillExcel) drawTableContent() error {
 			deliveryTime := produce.DeliveryTime.Local().Format("2006-01-02")
 
 			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)
+			// !isPrint
+			if !b.Content.IsPrint {
+				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, produce.Paper, produce.PaperSize, produce.PrintSize, fmt.Sprintf("%d", produce.OrderCount), realCount, priceStr, budgetAmount, realPrice, deliveryTime, produce.Remark)
 
+			}
 			b.Row++
 		}
 	}
@@ -223,26 +289,31 @@ func (b *ProduceBillExcel) drawTableFooter() error {
 		Border:    border,
 	})
 
-	addCel := fmt.Sprintf("A%d", b.Row)
-
-	b.Excel.MergeCell(b.SheetName, addCel, fmt.Sprintf("G%d", b.Row))
-	b.Excel.SetCellStyle(b.SheetName, addCel, fmt.Sprintf("G%d", b.Row), styleLeft)
-	b.Excel.SetCellValue(b.SheetName, addCel, "送货地址:"+b.Content.SendTo)
+	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)
 
-	sureCel := fmt.Sprintf("H%d", b.Row)
-	b.Excel.MergeCell(b.SheetName, sureCel, fmt.Sprintf("L%d", b.Row))
-	b.Excel.SetCellStyle(b.SheetName, sureCel, fmt.Sprintf("L%d", b.Row), styleLeft)
-	b.Excel.SetCellValue(b.SheetName, sureCel, "供应商签字:")
+	// !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)
 
+	}
+	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.SetRowHeight(b.SheetName, b.Row, 21)
 
 	return nil
 }
 
 func (b *ProduceBillExcel) drawTableSignature() error {
-	// row := b.Offset + 11
 	b.Row += 2
-	// row := b.Row
 
 	style1, _ := b.Excel.NewStyle(&excelize.Style{
 		Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
@@ -264,6 +335,15 @@ func (b *ProduceBillExcel) drawTableSignature() error {
 	fontCell := fmt.Sprintf("H%d", b.Row)
 	imageCell1 := fmt.Sprintf("I%d", b.Row)
 	imageCell2 := fmt.Sprintf("K%d", b.Row)
+
+	// !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)
+
+	}
+
 	b.Excel.MergeCell(b.SheetName, fontCell, fmt.Sprintf("H%d", b.Row+2))
 	b.Excel.SetCellStyle(b.SheetName, fontCell, fontCell, style1)
 	b.Excel.SetCellValue(b.SheetName, fontCell, "审核签字:")

+ 79 - 13
boxcost/api/report-produce-excel.go

@@ -28,6 +28,13 @@ type ReportProduceExcel struct {
 func (b *ReportProduceExcel) drawTitle() error {
 	// 设置外边距
 	marginLeft := excelize.PageMarginLeft(0.15)
+	// !isPrint
+	if !b.Content.IsPrint {
+		marginLeft = excelize.PageMarginLeft(0.3)
+		b.Excel.SetColWidth(b.SheetName, "A", "B", 16)
+		b.Excel.SetColWidth(b.SheetName, "C", "H", 12)
+		b.Excel.SetColWidth(b.SheetName, "I", "I", 16)
+	}
 	b.Excel.SetPageMargins(b.SheetName, marginLeft)
 	b.Row++
 	startCell := fmt.Sprintf("A%d", b.Row)
@@ -96,6 +103,40 @@ func (b *ReportProduceExcel) drawSubTitles() error {
 		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
+		}
+
+	}
+
 	//第一行
 	drawLeft(b.Row, "类别:"+b.Content.Type)
 	drawRight(b.Row, "单号:"+b.Content.SerialNumber)
@@ -155,18 +196,32 @@ func (b *ReportProduceExcel) drawTableTitle() error {
 		return nil
 	}
 
-	drawCol("A", "加工项目")
-	drawCol("B", "规格")
-	drawCol("C", "纸张")
-	drawCol("D", "来纸尺寸")
-	drawCol("E", "印刷尺寸")
-	drawCol("F", "下单数量")
-	drawCol("G", "完成数量")
-	drawCol2("H", "单价", "元/张")
-	drawCol("I", "预算金额")
-	drawCol("J", "实际金额")
-	drawCol("K", "交货时间")
-	drawCol("L", "备注")
+	// !isPrint
+	if !b.Content.IsPrint {
+		drawCol("A", "加工项目")
+		drawCol("B", "规格")
+		drawCol("F", "下单数量")
+		drawCol("G", "完成数量")
+		drawCol2("H", "单价", "元/张")
+		drawCol("I", "预算金额")
+		drawCol("J", "实际金额")
+		drawCol("K", "交货时间")
+		drawCol("L", "备注")
+
+	} 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
 }
@@ -175,6 +230,10 @@ func (b *ReportProduceExcel) 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"}
+		// !isPrint
+		if !b.Content.IsPrint {
+			charas = []string{"A", "B", "C", "D", "E", "F", "G", "H", "I"}
+		}
 		for i, c := range charas {
 			v := ""
 			if i < len(values) {
@@ -208,7 +267,14 @@ func (b *ReportProduceExcel) drawTableContent() error {
 			b.FormatToEmpty(&realPrice)
 
 			deliveryTime := produce.DeliveryTime.Local().Format("2006-01-02")
-			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)
+
+			// !isPrint
+			if !b.Content.IsPrint {
+				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, produce.Paper, produce.PaperSize, produce.PrintSize, fmt.Sprintf("%d", produce.OrderCount), realCount, priceStr, budgetAmount, realPrice, deliveryTime, produce.Remark)
+
+			}
 			b.Row++
 			b.BudgetAmount += produce.OrderPrice * float64(produce.OrderCount)
 			b.RealAmount += produce.OrderPrice * float64(produce.ConfirmCount)