|
@@ -27,40 +27,40 @@ type ProduceBillExcel struct {
|
|
|
|
|
|
func (b *ProduceBillExcel) drawTitle() error {
|
|
|
b.Row++
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- marginLeft := excelize.PageMarginLeft(0.18)
|
|
|
+
|
|
|
startCell := fmt.Sprintf("A%d", b.Row)
|
|
|
+ marginLeft := excelize.PageMarginLeft(0.18)
|
|
|
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)
|
|
|
+ if b.Content.IsPrint {
|
|
|
+ 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)
|
|
|
|
|
|
-
|
|
|
- if !b.Content.IsPrint {
|
|
|
+ } else {
|
|
|
+
|
|
|
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.Content.IsLam {
|
|
|
+ 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", "D", 10)
|
|
|
+ b.Excel.SetColWidth(b.SheetName, "E", "F", 12)
|
|
|
+ b.Excel.SetColWidth(b.SheetName, "G", "H", 10)
|
|
|
+ b.Excel.SetColWidth(b.SheetName, "I", "I", 14)
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
+ }
|
|
|
|
|
|
b.Excel.SetPageMargins(b.SheetName, marginLeft)
|
|
|
|
|
@@ -99,71 +99,6 @@ func (b *ProduceBillExcel) drawSubTitles() error {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
drawLeft := func(rowIndex int, value string) error {
|
|
|
|
|
|
left1Cell := fmt.Sprintf("A%d", rowIndex)
|
|
@@ -193,7 +128,6 @@ func (b *ProduceBillExcel) drawSubTitles() error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-
|
|
|
if !b.Content.IsPrint {
|
|
|
drawLeft = func(rowIndex int, value string) error {
|
|
|
|
|
@@ -223,9 +157,38 @@ func (b *ProduceBillExcel) drawSubTitles() error {
|
|
|
b.Excel.SetCellValue(b.SheetName, right1Cell, value)
|
|
|
return nil
|
|
|
}
|
|
|
- }
|
|
|
+ if b.Content.IsLam {
|
|
|
+ drawLeft = func(rowIndex int, value string) error {
|
|
|
+
|
|
|
+ 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
|
|
|
+ }
|
|
|
+
|
|
|
+ drawRight = func(rowIndex int, value string) error {
|
|
|
+ right1Cell := fmt.Sprintf("G%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)
|
|
@@ -284,6 +247,34 @@ func (b *ProduceBillExcel) drawTableTitle() error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
+ 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)
|
|
|
+
|
|
|
+ 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", "规格")
|
|
@@ -291,77 +282,35 @@ func (b *ProduceBillExcel) drawTableTitle() error {
|
|
|
drawCol("D", "来纸尺寸")
|
|
|
drawCol("E", "印刷尺寸")
|
|
|
drawCol("F", "下单数量")
|
|
|
- drawCol2("G", "单价", "元/张")
|
|
|
+ drawCol2("G", "单价", unit)
|
|
|
drawCol("H", "预算金额")
|
|
|
drawCol("I", "交货时间")
|
|
|
drawCol("J", "备注")
|
|
|
|
|
|
} else {
|
|
|
- drawCol("A", "加工项目")
|
|
|
- drawCol("B", "规格")
|
|
|
- drawCol("C", "下单数量")
|
|
|
- drawCol2("D", "单价", "元/张")
|
|
|
- drawCol("E", "预算金额")
|
|
|
- drawCol("F", "交货时间")
|
|
|
- drawCol("G", "备注")
|
|
|
+ if b.Content.IsLam {
|
|
|
+ drawCol("A", "加工项目")
|
|
|
+ drawCol("B", "规格")
|
|
|
+ drawCol("C", "覆膜尺寸")
|
|
|
+ drawCol("D", "下单数量")
|
|
|
+ unit2 := b.Content.Produces[0].Unit2
|
|
|
+ drawCol3("E", "F", "单价", unit, unit2)
|
|
|
+ drawCol("G", "预算金额")
|
|
|
+ drawCol("H", "交货时间")
|
|
|
+ drawCol("I", "备注")
|
|
|
+
|
|
|
+ } else {
|
|
|
+ drawCol("A", "加工项目")
|
|
|
+ drawCol("B", "规格")
|
|
|
+ drawCol("C", "下单数量")
|
|
|
+ drawCol2("D", "单价", unit)
|
|
|
+ drawCol("E", "预算金额")
|
|
|
+ drawCol("F", "交货时间")
|
|
|
+ drawCol("G", "备注")
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ }
|
|
|
|
|
|
return nil
|
|
|
}
|
|
@@ -369,18 +318,14 @@ func (b *ProduceBillExcel) drawTableTitle() error {
|
|
|
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"}
|
|
|
|
|
|
if !b.Content.IsPrint {
|
|
|
charas = []string{"A", "B", "C", "D", "E", "F", "G"}
|
|
|
+ if b.Content.IsLam {
|
|
|
+ charas = []string{"A", "B", "C", "D", "E", "F", "G", "H", "I"}
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -421,30 +366,17 @@ func (b *ProduceBillExcel) drawTableContent() error {
|
|
|
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)
|
|
|
+
|
|
|
+ if b.Content.IsLam {
|
|
|
+ DrawRow(b.Row, produce.Name, produce.Norm, produce.PrintSize, fmt.Sprintf("%d", produce.OrderCount), priceStr, fmt.Sprintf("%.3f", produce.Price2), budgetAmount, deliveryTime, produce.Remark)
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ } else {
|
|
|
|
|
|
-
|
|
|
+ DrawRow(b.Row, produce.Name, produce.Norm, fmt.Sprintf("%d", produce.OrderCount), priceStr, budgetAmount, deliveryTime, produce.Remark)
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ }
|
|
|
b.Row++
|
|
|
}
|
|
|
}
|
|
@@ -466,19 +398,7 @@ func (b *ProduceBillExcel) drawTableFooter() error {
|
|
|
})
|
|
|
|
|
|
sendToStartCell := fmt.Sprintf("A%d", b.Row)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
sendToEndCell := fmt.Sprintf("E%d", b.Row)
|
|
|
supplierStartCell := fmt.Sprintf("F%d", b.Row)
|
|
|
supplierEndCell := fmt.Sprintf("J%d", b.Row)
|
|
@@ -487,9 +407,14 @@ func (b *ProduceBillExcel) drawTableFooter() error {
|
|
|
sendToEndCell = fmt.Sprintf("D%d", b.Row)
|
|
|
supplierStartCell = fmt.Sprintf("E%d", b.Row)
|
|
|
supplierEndCell = fmt.Sprintf("G%d", b.Row)
|
|
|
- }
|
|
|
|
|
|
-
|
|
|
+ if b.Content.IsLam {
|
|
|
+ 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)
|
|
@@ -516,24 +441,6 @@ func (b *ProduceBillExcel) drawTableSignature() error {
|
|
|
b.Excel.MergeCell(b.SheetName, billUserCellS, billUserCellE)
|
|
|
b.Excel.SetCellValue(b.SheetName, billUserCellS, "制单人:"+b.Content.UserName)
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
fontNum := "F"
|
|
|
image1s := "G"
|
|
|
image2s := "I"
|
|
@@ -545,9 +452,15 @@ func (b *ProduceBillExcel) drawTableSignature() error {
|
|
|
image2s = "G"
|
|
|
image1e = "F"
|
|
|
image2e = "G"
|
|
|
- }
|
|
|
+ if b.Content.IsLam {
|
|
|
+ fontNum = "E"
|
|
|
+ image1s = "F"
|
|
|
+ image2s = "H"
|
|
|
+ image1e = "G"
|
|
|
+ image2e = "I"
|
|
|
|
|
|
-
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
fontCell := fmt.Sprintf("%s%d", fontNum, b.Row)
|
|
|
fontEndCell := fmt.Sprintf("%s%d", fontNum, b.Row+2)
|
|
@@ -620,10 +533,6 @@ func NewProduceBill(f *excelize.File) *ProduceBillExcel {
|
|
|
Signatures: make([]*model.Signature, 0),
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
f.SetPageMargins(b.SheetName, excelize.PageMarginTop(0), excelize.PageMarginLeft(0), excelize.PageMarginRight(0))
|
|
|
|
|
|
return b
|