|
@@ -27,14 +27,25 @@ type PurchaseBillExcel struct {
|
|
|
Content *model.PurchaseBill
|
|
|
|
|
|
Signatures []*model.Signature
|
|
|
+ IsPdf string
|
|
|
}
|
|
|
|
|
|
func (b *PurchaseBillExcel) drawTitle() error {
|
|
|
marginLeft := excelize.PageMarginLeft(0.15)
|
|
|
- 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))
|
|
|
+ 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 {
|
|
|
return err
|
|
|
}
|
|
@@ -97,6 +108,41 @@ func (b *PurchaseBillExcel) 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
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
//第一行
|
|
|
drawLeft(b.Row, "类别:"+b.Content.Type)
|
|
|
drawRight(b.Row, "单号:"+b.Content.SerialNumber)
|
|
@@ -168,18 +214,9 @@ func (b *PurchaseBillExcel) drawTableTitle() error {
|
|
|
b.Excel.SetCellValue(b.SheetName, val3Cel, value3)
|
|
|
return nil
|
|
|
}
|
|
|
-
|
|
|
- drawCol("A", "采购项目")
|
|
|
- drawCol("B", "规格(克)")
|
|
|
-
|
|
|
- drawCol("E", "下单数量")
|
|
|
- drawCol("F", "完成数量")
|
|
|
-
|
|
|
- drawCol2("C", "D", "尺寸(mm)", "长", "宽")
|
|
|
- drawCol2("C", "D", "尺寸(mm)", "长", "宽")
|
|
|
+ // ??? for ragne
|
|
|
unit1 := "-"
|
|
|
unit2 := "-"
|
|
|
- // ??? for ragne
|
|
|
if len(b.Content.Paper) > 0 {
|
|
|
if b.Content.Paper[0].PriceUnit != "" {
|
|
|
unit1 = b.Content.Paper[0].PriceUnit
|
|
@@ -195,11 +232,31 @@ func (b *PurchaseBillExcel) drawTableTitle() error {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- drawCol2("G", "H", "单价", unit1, unit2)
|
|
|
- drawCol("I", "预算金额")
|
|
|
- drawCol("J", "实际金额")
|
|
|
- drawCol("K", "交货时间")
|
|
|
- drawCol("L", "备注")
|
|
|
+ // !!isPdf
|
|
|
+ if b.IsPdf == "true" {
|
|
|
+ drawCol("A", "采购项目")
|
|
|
+ drawCol("B", "规格(克)")
|
|
|
+ drawCol2("C", "D", "尺寸(mm)", "长", "宽")
|
|
|
+ drawCol2("C", "D", "尺寸(mm)", "长", "宽")
|
|
|
+ drawCol("E", "下单数量")
|
|
|
+ drawCol2("F", "G", "单价", unit1, unit2)
|
|
|
+ drawCol("H", "预算金额")
|
|
|
+ drawCol("I", "交货时间")
|
|
|
+ drawCol("J", "备注")
|
|
|
+
|
|
|
+ } else {
|
|
|
+ drawCol("A", "采购项目")
|
|
|
+ drawCol("B", "规格(克)")
|
|
|
+ drawCol("E", "下单数量")
|
|
|
+ drawCol("F", "完成数量")
|
|
|
+ drawCol2("C", "D", "尺寸(mm)", "长", "宽")
|
|
|
+ drawCol2("C", "D", "尺寸(mm)", "长", "宽")
|
|
|
+ drawCol2("G", "H", "单价", unit1, unit2)
|
|
|
+ drawCol("I", "预算金额")
|
|
|
+ drawCol("J", "实际金额")
|
|
|
+ drawCol("K", "交货时间")
|
|
|
+ drawCol("L", "备注")
|
|
|
+ }
|
|
|
|
|
|
return nil
|
|
|
}
|
|
@@ -209,6 +266,10 @@ func (b *PurchaseBillExcel) drawTableContent() error {
|
|
|
|
|
|
var DrawRow = func(rowIndex int, values ...string) {
|
|
|
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"}
|
|
|
+ }
|
|
|
for i, c := range charas {
|
|
|
v := ""
|
|
|
if i < len(values) {
|
|
@@ -242,8 +303,14 @@ 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)
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- 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++
|
|
|
}
|
|
|
}
|
|
@@ -252,8 +319,6 @@ func (b *PurchaseBillExcel) drawTableContent() error {
|
|
|
}
|
|
|
|
|
|
func (b *PurchaseBillExcel) drawTableFooter() error {
|
|
|
- row := b.Row
|
|
|
-
|
|
|
border := []excelize.Border{
|
|
|
{Type: "top", Style: 1, Color: "000000"},
|
|
|
{Type: "left", Style: 1, Color: "000000"},
|
|
@@ -266,17 +331,25 @@ func (b *PurchaseBillExcel) drawTableFooter() error {
|
|
|
Border: border,
|
|
|
})
|
|
|
|
|
|
- addCel := fmt.Sprintf("A%d", row)
|
|
|
- b.Excel.MergeCell(b.SheetName, addCel, fmt.Sprintf("G%d", row))
|
|
|
- b.Excel.SetCellStyle(b.SheetName, addCel, fmt.Sprintf("G%d", 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", row)
|
|
|
- b.Excel.MergeCell(b.SheetName, sureCel, fmt.Sprintf("L%d", row))
|
|
|
- b.Excel.SetCellStyle(b.SheetName, sureCel, fmt.Sprintf("L%d", row), styleLeft)
|
|
|
- b.Excel.SetCellValue(b.SheetName, sureCel, "供应商签字:")
|
|
|
+ // !!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)
|
|
|
|
|
|
- b.Excel.SetRowHeight(b.SheetName, row, 21)
|
|
|
+ }
|
|
|
+ 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
|
|
|
}
|
|
@@ -292,36 +365,46 @@ func (b *PurchaseBillExcel) drawTableSignature() error {
|
|
|
// 制单人
|
|
|
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("H%d", b.Row)
|
|
|
- imageCell1 := fmt.Sprintf("I%d", b.Row)
|
|
|
- imageCell2 := fmt.Sprintf("K%d", b.Row)
|
|
|
- b.Excel.MergeCell(b.SheetName, fontCell, fmt.Sprintf("H%d", b.Row+2))
|
|
|
+ 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"
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ 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, "")
|
|
|
|
|
|
- // 状态为已审核时,签字
|
|
|
- // `{
|
|
|
- // "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 {
|
|
@@ -370,14 +453,9 @@ func NewPurchaseBill(f *excelize.File) *PurchaseBillExcel {
|
|
|
Signatures: make([]*model.Signature, 0),
|
|
|
}
|
|
|
|
|
|
- // f.SetColWidth(b.SheetName, "A", "A", 12)
|
|
|
- // f.SetColWidth(b.SheetName, "B", "K", 9.5)
|
|
|
- // f.SetColWidth(b.SheetName, "L", "L", 10)
|
|
|
-
|
|
|
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, "C", "H", 9.5)
|
|
|
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))
|