|
@@ -33,9 +33,10 @@ type ReportProcessExcel struct {
|
|
|
func (b *ReportProcessExcel) drawTitle() error {
|
|
|
marginLeft := excelize.PageMarginLeft(0.3)
|
|
|
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("J%d", tileIndex))
|
|
|
+ // tileIndex := b.Offset + 1
|
|
|
+ b.Row++
|
|
|
+ startCell := fmt.Sprintf("A%d", b.Row)
|
|
|
+ err := b.Excel.MergeCell(b.SheetName, startCell, fmt.Sprintf("J%d", b.Row))
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
@@ -50,13 +51,14 @@ func (b *ReportProcessExcel) 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 *ReportProcessExcel) drawSubTitles() error {
|
|
|
- row := b.Offset + 2
|
|
|
+ // row := b.Offset + 2
|
|
|
+ b.Row++
|
|
|
styleLeft, err := b.Excel.NewStyle(&excelize.Style{
|
|
|
Alignment: &excelize.Alignment{Horizontal: "left", Vertical: "center"},
|
|
|
Font: &excelize.Font{Size: 11}})
|
|
@@ -99,18 +101,20 @@ func (b *ReportProcessExcel) 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)
|
|
@@ -118,18 +122,19 @@ func (b *ReportProcessExcel) 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 *ReportProcessExcel) drawTableTitle() error {
|
|
|
- row := b.Offset + 5
|
|
|
+ // row := b.Offset + 5
|
|
|
+ b.Row++
|
|
|
// 品名 规格 数量 单位 单价 金额
|
|
|
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 {
|
|
@@ -158,8 +163,9 @@ func (b *ReportProcessExcel) drawTableTitle() error {
|
|
|
}
|
|
|
|
|
|
func (b *ReportProcessExcel) 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"}
|
|
@@ -196,8 +202,8 @@ func (b *ReportProcessExcel) drawTableContent() error {
|
|
|
orderCount := fmt.Sprintf("%d", ps.OrderCount)
|
|
|
price := fmt.Sprintf("%.3f", ps.Price)
|
|
|
b.FormatToEmpty(&price)
|
|
|
- DrawRow(row, ps.Name, ps.Norm, orderCount, ps.Unit, confirmCount, price, budgetAmount, realAmount, deliveryTime, ps.Remark)
|
|
|
- row++
|
|
|
+ DrawRow(b.Row, ps.Name, ps.Norm, orderCount, ps.Unit, confirmCount, price, budgetAmount, realAmount, deliveryTime, ps.Remark)
|
|
|
+ // row++
|
|
|
b.Row++
|
|
|
b.BudgetCount += b.Content.BudgetAmount
|
|
|
b.RealCount += b.Content.RealAmount
|