|
@@ -24,18 +24,14 @@ type ReportPurchaseExcel struct {
|
|
|
AlignCenterStyle int
|
|
|
|
|
|
Content *model.PurchaseBill
|
|
|
-
|
|
|
- BudgetCount float64
|
|
|
- RealCount float64
|
|
|
}
|
|
|
|
|
|
func (b *ReportPurchaseExcel) drawTitle() error {
|
|
|
+ b.Row++
|
|
|
marginLeft := excelize.PageMarginLeft(0.15)
|
|
|
b.Excel.SetPageMargins(b.SheetName, marginLeft)
|
|
|
-
|
|
|
- tileIndex := b.Offset + 1
|
|
|
- startCell := fmt.Sprintf("A%d", tileIndex)
|
|
|
- err := b.Excel.MergeCell(b.SheetName, startCell, fmt.Sprintf("L%d", tileIndex))
|
|
|
+ startCell := fmt.Sprintf("A%d", b.Row)
|
|
|
+ err := b.Excel.MergeCell(b.SheetName, startCell, fmt.Sprintf("L%d", b.Row))
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
@@ -50,14 +46,14 @@ func (b *ReportPurchaseExcel) drawTitle() error {
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- b.Excel.SetRowHeight(b.SheetName, tileIndex, 23)
|
|
|
+ b.Excel.SetRowHeight(b.SheetName, b.Row, 23)
|
|
|
b.Excel.SetCellValue(b.SheetName, startCell, b.Title)
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (b *ReportPurchaseExcel) drawSubTitles() error {
|
|
|
|
|
|
- row := b.Offset + 2
|
|
|
+ b.Row++
|
|
|
|
|
|
styleLeft, err := b.Excel.NewStyle(&excelize.Style{
|
|
|
Alignment: &excelize.Alignment{Horizontal: "left", Vertical: "center"},
|
|
@@ -101,18 +97,20 @@ func (b *ReportPurchaseExcel) drawSubTitles() error {
|
|
|
return nil
|
|
|
}
|
|
|
//第一行
|
|
|
- drawLeft(row, "类别:"+b.Content.Type)
|
|
|
- drawRight(row, "单号:"+b.Content.SerialNumber)
|
|
|
- b.Excel.SetRowHeight(b.SheetName, row, 21)
|
|
|
+ drawLeft(b.Row, "类别:"+b.Content.Type)
|
|
|
+ drawRight(b.Row, "单号:"+b.Content.SerialNumber)
|
|
|
+ b.Excel.SetRowHeight(b.SheetName, b.Row, 21)
|
|
|
+ b.Row++
|
|
|
|
|
|
//第二行
|
|
|
- drawLeft(row+1, "供应商名称:"+b.Content.Supplier)
|
|
|
+ drawLeft(b.Row, "供应商名称:"+b.Content.Supplier)
|
|
|
timeformat := b.Content.CreateTime.Local().Format("2006年01月02号 15:04:05")
|
|
|
- drawRight(row+1, "下单时间:"+timeformat)
|
|
|
- b.Excel.SetRowHeight(b.SheetName, row+1, 21)
|
|
|
+ drawRight(b.Row, "下单时间:"+timeformat)
|
|
|
+ b.Excel.SetRowHeight(b.SheetName, b.Row, 21)
|
|
|
|
|
|
+ b.Row++
|
|
|
//第三行
|
|
|
- drawLeft(row+2, "产品名称:"+b.Content.ProductName)
|
|
|
+ drawLeft(b.Row, "产品名称:"+b.Content.ProductName)
|
|
|
status := ""
|
|
|
if b.Content.Status == "complete" {
|
|
|
status = fmt.Sprintf("已完成(%d)", b.Content.ConfirmCount)
|
|
@@ -120,18 +118,18 @@ func (b *ReportPurchaseExcel) drawSubTitles() error {
|
|
|
if b.Content.Status == "created" {
|
|
|
status = "进行中"
|
|
|
}
|
|
|
- drawRight(row+2, "状态:"+status)
|
|
|
- b.Excel.SetRowHeight(b.SheetName, row+2, 21)
|
|
|
+ drawRight(b.Row, "状态:"+status)
|
|
|
+ b.Excel.SetRowHeight(b.SheetName, b.Row, 21)
|
|
|
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (b *ReportPurchaseExcel) drawTableTitle() error {
|
|
|
- row := b.Offset + 5
|
|
|
+ b.Row++
|
|
|
//A采购项目 B规格(克) 尺寸C-D 数量E 单价F-G 交货时间H 备注I
|
|
|
var drawCol = func(prefix string, value string) error {
|
|
|
- left1Cell := fmt.Sprintf("%s%d", prefix, row)
|
|
|
- left2Cell := fmt.Sprintf("%s%d", prefix, row+1)
|
|
|
+ left1Cell := fmt.Sprintf("%s%d", prefix, b.Row)
|
|
|
+ left2Cell := fmt.Sprintf("%s%d", prefix, b.Row+1)
|
|
|
|
|
|
err := b.Excel.MergeCell(b.SheetName, left1Cell, left2Cell)
|
|
|
if err != nil {
|
|
@@ -146,8 +144,8 @@ func (b *ReportPurchaseExcel) drawTableTitle() error {
|
|
|
}
|
|
|
|
|
|
var drawCol2 = func(prefix1 string, prefix2 string, value1 string, value2 string, value3 string) error {
|
|
|
- left1Cell := fmt.Sprintf("%s%d", prefix1, row)
|
|
|
- left2Cell := fmt.Sprintf("%s%d", prefix2, row)
|
|
|
+ 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
|
|
@@ -162,11 +160,11 @@ func (b *ReportPurchaseExcel) drawTableTitle() error {
|
|
|
}
|
|
|
b.Excel.SetCellValue(b.SheetName, left1Cell, value1)
|
|
|
|
|
|
- val2Cel := fmt.Sprintf("%s%d", prefix1, row+1)
|
|
|
+ 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, row+1)
|
|
|
+ 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
|
|
@@ -208,8 +206,9 @@ func (b *ReportPurchaseExcel) drawTableTitle() error {
|
|
|
}
|
|
|
|
|
|
func (b *ReportPurchaseExcel) drawTableContent() error {
|
|
|
- row := b.Offset + 7
|
|
|
- b.Row = row
|
|
|
+ // row := b.Offset + 7
|
|
|
+ // b.Row = row
|
|
|
+ b.Row += 2
|
|
|
|
|
|
var DrawRow = func(rowIndex int, values ...string) {
|
|
|
charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"}
|
|
@@ -238,7 +237,6 @@ func (b *ReportPurchaseExcel) drawTableContent() error {
|
|
|
// 预算金额
|
|
|
budgetAmount := fmt.Sprintf("%.3f", b.Content.BudgetAmount)
|
|
|
b.FormatToEmpty(&budgetAmount)
|
|
|
- b.BudgetCount += b.Content.BudgetAmount
|
|
|
|
|
|
// 实际完成数
|
|
|
confirmCount = fmt.Sprintf("%d", b.Content.ConfirmCount)
|
|
@@ -247,10 +245,8 @@ func (b *ReportPurchaseExcel) drawTableContent() error {
|
|
|
// 实际金额
|
|
|
realAmount = fmt.Sprintf("%.3f", b.Content.RealAmount)
|
|
|
b.FormatToEmpty(&realAmount)
|
|
|
- b.RealCount += b.Content.RealAmount
|
|
|
|
|
|
- DrawRow(row, paper.Name, paper.Norm, paper.Height, paper.Width, fmt.Sprintf("%d", paper.OrderCount), confirmCount, price, price2, budgetAmount, realAmount, deliveryTime, paper.Remark)
|
|
|
- row++
|
|
|
+ DrawRow(b.Row, paper.Name, paper.Norm, paper.Height, paper.Width, fmt.Sprintf("%d", paper.OrderCount), confirmCount, price, price2, budgetAmount, realAmount, deliveryTime, paper.Remark)
|
|
|
b.Row++
|
|
|
}
|
|
|
}
|
|
@@ -325,3 +321,7 @@ func (b *ReportPurchaseExcel) SetRow(row int) {
|
|
|
b.Row = row
|
|
|
|
|
|
}
|
|
|
+func (b *ReportPurchaseExcel) GetRow() int {
|
|
|
+ return b.Row
|
|
|
+
|
|
|
+}
|