|
@@ -26,21 +26,47 @@ type ReportProduceExcel struct {
|
|
|
}
|
|
|
|
|
|
func (b *ReportProduceExcel) 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)
|
|
|
+
|
|
|
+ if b.Content.IsPrint {
|
|
|
+ // A加工项目 B规格 C纸张 D来纸尺寸 E印刷尺寸 F下单数量 G完成数量 H单价 I预算金额 J实际金额 K交货时间 L备注
|
|
|
+ b.Excel.SetColWidth(b.SheetName, "A", "A", 16)
|
|
|
+ b.Excel.SetColWidth(b.SheetName, "B", "B", 14)
|
|
|
+ b.Excel.SetColWidth(b.SheetName, "C", "C", 10)
|
|
|
+ b.Excel.SetColWidth(b.SheetName, "D", "E", 14)
|
|
|
+ b.Excel.SetColWidth(b.SheetName, "F", "K", 12)
|
|
|
+ b.Excel.SetColWidth(b.SheetName, "J", "J", 18)
|
|
|
+
|
|
|
+ } else {
|
|
|
+ // 不是打印
|
|
|
+ // A加工项目 B规格 C下单数量 D完成数量 E单价 F预算金额 G实际金额 H交货时间 I备注
|
|
|
+ endCell = fmt.Sprintf("G%d", b.Row)
|
|
|
+ marginLeft = excelize.PageMarginLeft(0.6)
|
|
|
+ b.Excel.SetColWidth(b.SheetName, "A", "A", 16)
|
|
|
+ b.Excel.SetColWidth(b.SheetName, "B", "B", 14)
|
|
|
+ b.Excel.SetColWidth(b.SheetName, "C", "H", 12)
|
|
|
+ b.Excel.SetColWidth(b.SheetName, "I", "I", 18)
|
|
|
+ // 是覆膜
|
|
|
+ if b.Content.IsLam {
|
|
|
+
|
|
|
+ // A加工项目 B规格 C覆膜尺寸 D下单数量 E完成数量 F元/吨,G元/张 H预算金额 I实际金额 J交货时间 K备注
|
|
|
+ endCell = fmt.Sprintf("I%d", b.Row)
|
|
|
+ marginLeft = excelize.PageMarginLeft(0.3)
|
|
|
+ b.Excel.SetColWidth(b.SheetName, "A", "A", 16)
|
|
|
+ b.Excel.SetColWidth(b.SheetName, "B", "C", 14)
|
|
|
+ // 覆膜规格
|
|
|
+ b.Excel.SetColWidth(b.SheetName, "D", "J", 12)
|
|
|
+ b.Excel.SetColWidth(b.SheetName, "K", "K", 18)
|
|
|
+ }
|
|
|
|
|
|
- // !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)
|
|
|
}
|
|
|
+
|
|
|
b.Excel.SetPageMargins(b.SheetName, marginLeft)
|
|
|
- b.Row++
|
|
|
- startCell := fmt.Sprintf("A%d", b.Row)
|
|
|
err := b.Excel.MergeCell(b.SheetName, startCell, endCell)
|
|
|
if err != nil {
|
|
|
return err
|
|
@@ -199,19 +225,35 @@ func (b *ReportProduceExcel) drawTableTitle() error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
- // !isPrint
|
|
|
- if !b.Content.IsPrint {
|
|
|
- drawCol("A", "加工项目")
|
|
|
- drawCol("B", "规格")
|
|
|
- drawCol("C", "下单数量")
|
|
|
- drawCol("D", "完成数量")
|
|
|
- drawCol2("E", "单价", "元/张")
|
|
|
- drawCol("F", "预算金额")
|
|
|
- drawCol("G", "实际金额")
|
|
|
- drawCol("H", "交货时间")
|
|
|
- drawCol("I", "备注")
|
|
|
+ var drawCol3 = func(prefix1 string, prefix2 string, value1 string, value2 string, value3 string) error {
|
|
|
+ left1Cell := fmt.Sprintf("%s%d", prefix1, b.Row)
|
|
|
+ left2Cell := fmt.Sprintf("%s%d", prefix2, b.Row)
|
|
|
+ err := b.Excel.MergeCell(b.SheetName, left1Cell, left2Cell)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left2Cell, b.AlignCenterStyle)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ b.Excel.SetCellValue(b.SheetName, left1Cell, value1)
|
|
|
|
|
|
- } else {
|
|
|
+ val2Cel := fmt.Sprintf("%s%d", prefix1, b.Row+1)
|
|
|
+ b.Excel.SetCellStyle(b.SheetName, val2Cel, val2Cel, b.AlignCenterStyle)
|
|
|
+ b.Excel.SetCellValue(b.SheetName, val2Cel, value2)
|
|
|
+
|
|
|
+ val3Cel := fmt.Sprintf("%s%d", prefix2, b.Row+1)
|
|
|
+ b.Excel.SetCellStyle(b.SheetName, val3Cel, val3Cel, b.AlignCenterStyle)
|
|
|
+ b.Excel.SetCellValue(b.SheetName, val3Cel, value3)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+
|
|
|
+ unit := b.Content.Produces[0].Unit
|
|
|
+ if b.Content.IsPrint {
|
|
|
drawCol("A", "加工项目")
|
|
|
drawCol("B", "规格")
|
|
|
drawCol("C", "纸张")
|
|
@@ -219,11 +261,39 @@ func (b *ReportProduceExcel) drawTableTitle() error {
|
|
|
drawCol("E", "印刷尺寸")
|
|
|
drawCol("F", "下单数量")
|
|
|
drawCol("G", "完成数量")
|
|
|
- drawCol2("H", "单价", "元/张")
|
|
|
+ drawCol2("H", "单价", unit)
|
|
|
drawCol("I", "预算金额")
|
|
|
drawCol("J", "实际金额")
|
|
|
drawCol("K", "交货时间")
|
|
|
drawCol("L", "备注")
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if b.Content.IsLam {
|
|
|
+ drawCol("A", "加工项目")
|
|
|
+ drawCol("B", "规格")
|
|
|
+ drawCol("C", "覆膜尺寸")
|
|
|
+ drawCol("D", "下单数量")
|
|
|
+ drawCol("E", "完成数量")
|
|
|
+ unit2 := b.Content.Produces[0].Unit2
|
|
|
+ drawCol3("E", "G", "单价", unit, unit2)
|
|
|
+ drawCol("H", "预算金额")
|
|
|
+ drawCol("I", "实际金额")
|
|
|
+ drawCol("J", "交货时间")
|
|
|
+ drawCol("K", "备注")
|
|
|
+
|
|
|
+ } else {
|
|
|
+ drawCol("A", "加工项目")
|
|
|
+ drawCol("B", "规格")
|
|
|
+ drawCol("C", "下单数量")
|
|
|
+ drawCol("D", "完成数量")
|
|
|
+ drawCol2("E", "单价", unit)
|
|
|
+ drawCol("F", "预算金额")
|
|
|
+ drawCol("G", "实际金额")
|
|
|
+ drawCol("H", "交货时间")
|
|
|
+ drawCol("I", "备注")
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
return nil
|
|
@@ -236,6 +306,9 @@ func (b *ReportProduceExcel) drawTableContent() error {
|
|
|
// !isPrint
|
|
|
if !b.Content.IsPrint {
|
|
|
charas = []string{"A", "B", "C", "D", "E", "F", "G", "H", "I"}
|
|
|
+ if b.Content.IsLam {
|
|
|
+ charas = []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K"}
|
|
|
+ }
|
|
|
}
|
|
|
for i, c := range charas {
|
|
|
v := ""
|
|
@@ -273,7 +346,13 @@ func (b *ReportProduceExcel) drawTableContent() error {
|
|
|
|
|
|
// !isPrint
|
|
|
if !b.Content.IsPrint {
|
|
|
- DrawRow(b.Row, produce.Name, produce.Norm, fmt.Sprintf("%d", produce.OrderCount), realCount, priceStr, budgetAmount, realPrice, deliveryTime, produce.Remark)
|
|
|
+
|
|
|
+ if b.Content.IsLam {
|
|
|
+ DrawRow(b.Row, produce.Name, produce.Norm, produce.PrintSize, fmt.Sprintf("%d", produce.OrderCount), realCount, priceStr, fmt.Sprintf("%.3f", produce.Price2), 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 {
|
|
|
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)
|
|
|
|
|
@@ -315,9 +394,6 @@ func NewReportProduceExcel(f *excelize.File) *ReportProduceExcel {
|
|
|
Offset: 0,
|
|
|
AlignCenterStyle: styleLeft,
|
|
|
}
|
|
|
- f.SetColWidth(b.SheetName, "A", "A", 12)
|
|
|
- f.SetColWidth(b.SheetName, "B", "K", 9.5)
|
|
|
- f.SetColWidth(b.SheetName, "L", "L", 10)
|
|
|
f.SetPageMargins(b.SheetName, excelize.PageMarginTop(0), excelize.PageMarginLeft(0), excelize.PageMarginRight(0))
|
|
|
|
|
|
return b
|