|
@@ -31,19 +31,13 @@ type PurchaseBillExcel struct {
|
|
|
}
|
|
|
|
|
|
func (b *PurchaseBillExcel) drawTitle() error {
|
|
|
- // marginLeft := excelize.PageMarginLeft(0.15)
|
|
|
-
|
|
|
b.Row++
|
|
|
startCell := fmt.Sprintf("A%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 {
|
|
@@ -80,38 +74,6 @@ func (b *PurchaseBillExcel) drawSubTitles() error {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- // var drawLeft = func(rowIndex int, value string) error {
|
|
|
- // //左边1
|
|
|
- // 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
|
|
|
- // }
|
|
|
-
|
|
|
- // var drawRight = func(rowIndex int, value string) error {
|
|
|
- // right1Cell := fmt.Sprintf("G%d", rowIndex)
|
|
|
- // err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("L%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
|
|
|
- // }
|
|
|
-
|
|
|
- // !!isPdf
|
|
|
- // if b.IsPdf == "true" {
|
|
|
-
|
|
|
drawLeft := func(rowIndex int, value string) error {
|
|
|
//左边1
|
|
|
left1Cell := fmt.Sprintf("A%d", rowIndex)
|
|
@@ -141,8 +103,6 @@ func (b *PurchaseBillExcel) drawSubTitles() error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
- // }
|
|
|
-
|
|
|
//第一行
|
|
|
drawLeft(b.Row, "类别:"+b.Content.Type)
|
|
|
drawRight(b.Row, "单号:"+b.Content.SerialNumber)
|
|
@@ -171,7 +131,7 @@ func (b *PurchaseBillExcel) drawSubTitles() error {
|
|
|
|
|
|
func (b *PurchaseBillExcel) drawTableTitle() error {
|
|
|
b.Row += 3
|
|
|
- //A采购项目 B规格(克) 尺寸C-D 数量E 单价F-G 交货时间H 备注I
|
|
|
+
|
|
|
var drawCol = func(prefix string, value string) error {
|
|
|
left1Cell := fmt.Sprintf("%s%d", prefix, b.Row)
|
|
|
left2Cell := fmt.Sprintf("%s%d", prefix, b.Row+1)
|
|
@@ -214,7 +174,6 @@ func (b *PurchaseBillExcel) drawTableTitle() error {
|
|
|
b.Excel.SetCellValue(b.SheetName, val3Cel, value3)
|
|
|
return nil
|
|
|
}
|
|
|
- // ??? for ragne
|
|
|
unit1 := "-"
|
|
|
unit2 := "-"
|
|
|
if len(b.Content.Paper) > 0 {
|
|
@@ -232,8 +191,6 @@ func (b *PurchaseBillExcel) drawTableTitle() error {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // !!isPdf
|
|
|
- // if b.IsPdf == "true" {
|
|
|
drawCol("A", "采购项目")
|
|
|
drawCol("B", "规格(克)")
|
|
|
drawCol2("C", "D", "尺寸(mm)", "长", "宽")
|
|
@@ -243,19 +200,6 @@ func (b *PurchaseBillExcel) drawTableTitle() error {
|
|
|
drawCol("I", "交货时间")
|
|
|
drawCol("J", "备注")
|
|
|
|
|
|
- // } else {
|
|
|
- // drawCol("A", "采购项目")
|
|
|
- // drawCol("B", "规格(克)")
|
|
|
- // drawCol2("C", "D", "尺寸(mm)", "长", "宽")
|
|
|
- // drawCol("E", "下单数量")
|
|
|
- // drawCol("F", "完成数量")
|
|
|
- // drawCol2("G", "H", "单价", unit1, unit2)
|
|
|
- // drawCol("I", "预算金额")
|
|
|
- // drawCol("J", "实际金额")
|
|
|
- // drawCol("K", "交货时间")
|
|
|
- // drawCol("L", "备注")
|
|
|
- // }
|
|
|
-
|
|
|
return nil
|
|
|
}
|
|
|
|
|
@@ -263,11 +207,7 @@ func (b *PurchaseBillExcel) 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"}
|
|
|
- // !!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) {
|
|
@@ -301,14 +241,7 @@ 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)
|
|
|
-
|
|
|
- // }
|
|
|
-
|
|
|
b.Row++
|
|
|
}
|
|
|
}
|
|
@@ -330,17 +263,10 @@ func (b *PurchaseBillExcel) drawTableFooter() error {
|
|
|
})
|
|
|
|
|
|
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)
|
|
|
-
|
|
|
- // !!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.MergeCell(b.SheetName, sendToStartCell, sendToEndCell)
|
|
|
b.Excel.SetCellStyle(b.SheetName, sendToStartCell, sendToEndCell, styleLeft)
|
|
|
b.Excel.SetCellValue(b.SheetName, sendToStartCell, "送货地址:"+b.Content.SendTo)
|
|
@@ -354,7 +280,6 @@ func (b *PurchaseBillExcel) drawTableFooter() error {
|
|
|
|
|
|
func (b *PurchaseBillExcel) drawTableSignature() error {
|
|
|
b.Row += 2
|
|
|
- // row := b.Row
|
|
|
|
|
|
style1, _ := b.Excel.NewStyle(&excelize.Style{
|
|
|
Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
|
|
@@ -366,22 +291,12 @@ func (b *PurchaseBillExcel) drawTableSignature() error {
|
|
|
b.Excel.MergeCell(b.SheetName, billUserCellS, billUserCellE)
|
|
|
b.Excel.SetCellValue(b.SheetName, billUserCellS, "制单人:"+b.Content.UserName)
|
|
|
|
|
|
- // 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)
|
|
|
|
|
@@ -453,11 +368,6 @@ func NewPurchaseBill(f *excelize.File) *PurchaseBillExcel {
|
|
|
Signatures: make([]*model.Signature, 0),
|
|
|
}
|
|
|
|
|
|
- // 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, "H", "K", 10)
|
|
|
- // f.SetColWidth(b.SheetName, "L", "L", 11)
|
|
|
f.SetPageMargins(b.SheetName, excelize.PageMarginTop(0), excelize.PageMarginLeft(0), excelize.PageMarginRight(0))
|
|
|
return b
|
|
|
}
|