|
@@ -24,12 +24,11 @@ type ProduceBillExcel struct {
|
|
}
|
|
}
|
|
|
|
|
|
func (b *ProduceBillExcel) drawTitle() error {
|
|
func (b *ProduceBillExcel) drawTitle() error {
|
|
- // 设置外边距
|
|
|
|
|
|
+ b.Row++
|
|
marginLeft := excelize.PageMarginLeft(0.15)
|
|
marginLeft := excelize.PageMarginLeft(0.15)
|
|
b.Excel.SetPageMargins(b.SheetName, marginLeft)
|
|
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 {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
@@ -44,14 +43,13 @@ func (b *ProduceBillExcel) drawTitle() error {
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
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)
|
|
b.Excel.SetCellValue(b.SheetName, startCell, b.Title)
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
func (b *ProduceBillExcel) drawSubTitles() error {
|
|
func (b *ProduceBillExcel) drawSubTitles() error {
|
|
- row := b.Offset + 2
|
|
|
|
-
|
|
|
|
|
|
+ b.Row++
|
|
styleLeft, err := b.Excel.NewStyle(&excelize.Style{
|
|
styleLeft, err := b.Excel.NewStyle(&excelize.Style{
|
|
Alignment: &excelize.Alignment{Horizontal: "left", Vertical: "center"},
|
|
Alignment: &excelize.Alignment{Horizontal: "left", Vertical: "center"},
|
|
Font: &excelize.Font{Size: 11}})
|
|
Font: &excelize.Font{Size: 11}})
|
|
@@ -95,18 +93,18 @@ func (b *ProduceBillExcel) drawSubTitles() error {
|
|
}
|
|
}
|
|
|
|
|
|
//第一行
|
|
//第一行
|
|
- 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)
|
|
|
|
|
|
//第二行
|
|
//第二行
|
|
- drawLeft(row+1, "供应商名称:"+b.Content.Supplier)
|
|
|
|
|
|
+ drawLeft(b.Row+1, "供应商名称:"+b.Content.Supplier)
|
|
timeformat := b.Content.CreateTime.Local().Format("2006年01月02号 15:04:05")
|
|
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+1, "下单时间:"+timeformat)
|
|
|
|
+ b.Excel.SetRowHeight(b.SheetName, b.Row+1, 21)
|
|
|
|
|
|
//第三行
|
|
//第三行
|
|
- drawLeft(row+2, "产品名称:"+b.Content.ProductName)
|
|
|
|
|
|
+ drawLeft(b.Row+2, "产品名称:"+b.Content.ProductName)
|
|
status := ""
|
|
status := ""
|
|
if b.Content.Status == "complete" {
|
|
if b.Content.Status == "complete" {
|
|
status = fmt.Sprintf("已完成(%d)", b.Content.ConfirmCount)
|
|
status = fmt.Sprintf("已完成(%d)", b.Content.ConfirmCount)
|
|
@@ -114,19 +112,17 @@ func (b *ProduceBillExcel) drawSubTitles() error {
|
|
if b.Content.Status == "created" {
|
|
if b.Content.Status == "created" {
|
|
status = "进行中"
|
|
status = "进行中"
|
|
}
|
|
}
|
|
- drawRight(row+2, "状态:"+status)
|
|
|
|
- b.Excel.SetRowHeight(b.SheetName, row+2, 21)
|
|
|
|
|
|
+ drawRight(b.Row+2, "状态:"+status)
|
|
|
|
+ b.Excel.SetRowHeight(b.SheetName, b.Row+2, 21)
|
|
|
|
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
func (b *ProduceBillExcel) drawTableTitle() error {
|
|
func (b *ProduceBillExcel) drawTableTitle() error {
|
|
- row := b.Offset + 5
|
|
|
|
-
|
|
|
|
- //A加工项目 B规格(克) 尺寸C-D 数量E 单价F-G 交货时间H 备注I
|
|
|
|
|
|
+ b.Row += 3
|
|
var drawCol = func(prefix string, value string) error {
|
|
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)
|
|
err := b.Excel.MergeCell(b.SheetName, left1Cell, left2Cell)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -142,8 +138,8 @@ func (b *ProduceBillExcel) drawTableTitle() error {
|
|
|
|
|
|
var drawCol2 = func(prefix string, value1 string, value2 string) error {
|
|
var drawCol2 = func(prefix string, value1 string, value2 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.SetCellStyle(b.SheetName, left1Cell, left2Cell, b.AlignCenterStyle)
|
|
err := b.Excel.SetCellStyle(b.SheetName, left1Cell, left2Cell, b.AlignCenterStyle)
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
@@ -170,8 +166,7 @@ func (b *ProduceBillExcel) drawTableTitle() error {
|
|
}
|
|
}
|
|
|
|
|
|
func (b *ProduceBillExcel) drawTableContent() error {
|
|
func (b *ProduceBillExcel) drawTableContent() error {
|
|
- row := b.Offset + 7
|
|
|
|
- b.Row = row
|
|
|
|
|
|
+ b.Row += 2
|
|
var DrawRow = func(rowIndex int, values ...string) {
|
|
var DrawRow = func(rowIndex int, values ...string) {
|
|
charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"}
|
|
charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"}
|
|
for i, c := range charas {
|
|
for i, c := range charas {
|
|
@@ -189,48 +184,34 @@ func (b *ProduceBillExcel) drawTableContent() error {
|
|
|
|
|
|
produces := b.Content.Produces
|
|
produces := b.Content.Produces
|
|
if len(produces) > 0 {
|
|
if len(produces) > 0 {
|
|
- startRow := b.Row
|
|
|
|
- endRow := b.Row
|
|
|
|
for _, produce := range produces {
|
|
for _, produce := range produces {
|
|
- confirmCount := "-"
|
|
|
|
|
|
+ realCount := ""
|
|
price := produce.Price
|
|
price := produce.Price
|
|
priceStr := fmt.Sprintf("%.3f", price)
|
|
priceStr := fmt.Sprintf("%.3f", price)
|
|
b.FormatToEmpty(&priceStr)
|
|
b.FormatToEmpty(&priceStr)
|
|
// 预算金额
|
|
// 预算金额
|
|
- orderRealPrice := "-"
|
|
|
|
|
|
+ orderPrice := fmt.Sprintf("%.3f", produce.Price*float64(produce.OrderCount))
|
|
|
|
+ b.FormatToEmpty(&orderPrice)
|
|
// 实际金额
|
|
// 实际金额
|
|
- realPrice := "-"
|
|
|
|
|
|
+ realPrice := ""
|
|
if b.Content.Status == "complete" {
|
|
if b.Content.Status == "complete" {
|
|
// 实际完成数
|
|
// 实际完成数
|
|
- confirmCount = fmt.Sprintf("%d", produce.ConfirmCount)
|
|
|
|
- b.FormatToEmpty(&confirmCount)
|
|
|
|
|
|
+ realCount = fmt.Sprintf("%d", produce.ConfirmCount)
|
|
|
|
+ b.FormatToEmpty(&realCount)
|
|
|
|
+ realPrice = fmt.Sprintf("%.3f", produce.Price*float64(produce.ConfirmCount))
|
|
}
|
|
}
|
|
|
|
|
|
deliveryTime := produce.DeliveryTime.Local().Format("2006-01-02")
|
|
deliveryTime := produce.DeliveryTime.Local().Format("2006-01-02")
|
|
- DrawRow(row, produce.Name, produce.Norm, produce.Paper, produce.PaperSize, produce.PrintSize, fmt.Sprintf("%d", produce.OrderCount), confirmCount, priceStr, orderRealPrice, realPrice, deliveryTime, produce.Remark)
|
|
|
|
- endRow = b.Row
|
|
|
|
- row++
|
|
|
|
|
|
+ DrawRow(b.Row, produce.Name, produce.Norm, produce.Paper, produce.PaperSize, produce.PrintSize, fmt.Sprintf("%d", produce.OrderCount), realCount, priceStr, orderPrice, realPrice, deliveryTime, produce.Remark)
|
|
b.Row++
|
|
b.Row++
|
|
-
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
- // 多个工序 合并预算价格、实际价格
|
|
|
|
- b.Excel.MergeCell(b.SheetName, fmt.Sprintf("I%d", startRow), fmt.Sprintf("I%d", endRow))
|
|
|
|
- b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("I%d", startRow), b.Content.BudgetAmount)
|
|
|
|
- b.Excel.MergeCell(b.SheetName, fmt.Sprintf("J%d", startRow), fmt.Sprintf("J%d", endRow))
|
|
|
|
- b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("J%d", startRow), b.Content.RealAmount)
|
|
|
|
}
|
|
}
|
|
|
|
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
func (b *ProduceBillExcel) drawTableFooter() error {
|
|
func (b *ProduceBillExcel) drawTableFooter() error {
|
|
- // row := b.Offset + 8
|
|
|
|
- // b.Row++
|
|
|
|
- row := b.Row
|
|
|
|
-
|
|
|
|
- left1Cell := fmt.Sprintf("A%d", row)
|
|
|
|
-
|
|
|
|
|
|
+ left1Cell := fmt.Sprintf("A%d", b.Row)
|
|
border := []excelize.Border{
|
|
border := []excelize.Border{
|
|
{Type: "top", Style: 1, Color: "000000"},
|
|
{Type: "top", Style: 1, Color: "000000"},
|
|
{Type: "left", Style: 1, Color: "000000"},
|
|
{Type: "left", Style: 1, Color: "000000"},
|
|
@@ -246,18 +227,18 @@ func (b *ProduceBillExcel) drawTableFooter() error {
|
|
b.Excel.SetCellStyle(b.SheetName, left1Cell, left1Cell, styleLeft)
|
|
b.Excel.SetCellStyle(b.SheetName, left1Cell, left1Cell, styleLeft)
|
|
b.Excel.SetCellValue(b.SheetName, left1Cell, "送货地址")
|
|
b.Excel.SetCellValue(b.SheetName, left1Cell, "送货地址")
|
|
|
|
|
|
- addCel := fmt.Sprintf("B%d", row)
|
|
|
|
|
|
+ addCel := fmt.Sprintf("B%d", b.Row)
|
|
|
|
|
|
- b.Excel.MergeCell(b.SheetName, addCel, fmt.Sprintf("E%d", row))
|
|
|
|
- b.Excel.SetCellStyle(b.SheetName, addCel, fmt.Sprintf("E%d", row), styleLeft)
|
|
|
|
|
|
+ b.Excel.MergeCell(b.SheetName, addCel, fmt.Sprintf("E%d", b.Row))
|
|
|
|
+ b.Excel.SetCellStyle(b.SheetName, addCel, fmt.Sprintf("E%d", b.Row), styleLeft)
|
|
b.Excel.SetCellValue(b.SheetName, addCel, b.Content.SendTo)
|
|
b.Excel.SetCellValue(b.SheetName, addCel, b.Content.SendTo)
|
|
|
|
|
|
- sureCel := fmt.Sprintf("F%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)
|
|
|
|
|
|
+ sureCel := fmt.Sprintf("F%d", b.Row)
|
|
|
|
+ b.Excel.MergeCell(b.SheetName, sureCel, fmt.Sprintf("L%d", b.Row))
|
|
|
|
+ b.Excel.SetCellStyle(b.SheetName, sureCel, fmt.Sprintf("L%d", b.Row), styleLeft)
|
|
b.Excel.SetCellValue(b.SheetName, sureCel, "供应商签字:")
|
|
b.Excel.SetCellValue(b.SheetName, sureCel, "供应商签字:")
|
|
|
|
|
|
- b.Excel.SetRowHeight(b.SheetName, row, 21)
|
|
|
|
|
|
+ b.Excel.SetRowHeight(b.SheetName, b.Row, 21)
|
|
|
|
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
@@ -265,7 +246,7 @@ func (b *ProduceBillExcel) drawTableFooter() error {
|
|
func (b *ProduceBillExcel) drawTableSignature() error {
|
|
func (b *ProduceBillExcel) drawTableSignature() error {
|
|
// row := b.Offset + 11
|
|
// row := b.Offset + 11
|
|
b.Row += 2
|
|
b.Row += 2
|
|
- row := b.Row
|
|
|
|
|
|
+ // row := b.Row
|
|
|
|
|
|
style1, _ := b.Excel.NewStyle(&excelize.Style{
|
|
style1, _ := b.Excel.NewStyle(&excelize.Style{
|
|
Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
|
|
Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
|
|
@@ -273,25 +254,25 @@ func (b *ProduceBillExcel) drawTableSignature() error {
|
|
})
|
|
})
|
|
|
|
|
|
// 制单人
|
|
// 制单人
|
|
- billUserCell := fmt.Sprintf("A%d", row+1)
|
|
|
|
|
|
+ billUserCell := fmt.Sprintf("A%d", b.Row+1)
|
|
b.Excel.SetCellValue(b.SheetName, billUserCell, "制单人:")
|
|
b.Excel.SetCellValue(b.SheetName, billUserCell, "制单人:")
|
|
- billUservCell := fmt.Sprintf("B%d", row+1)
|
|
|
|
|
|
+ billUservCell := fmt.Sprintf("B%d", b.Row+1)
|
|
b.Excel.SetCellValue(b.SheetName, billUservCell, b.Content.UserName)
|
|
b.Excel.SetCellValue(b.SheetName, billUservCell, b.Content.UserName)
|
|
|
|
|
|
- fontCell := fmt.Sprintf("H%d", row)
|
|
|
|
- imageCell1 := fmt.Sprintf("I%d", row)
|
|
|
|
- imageCell2 := fmt.Sprintf("K%d", row)
|
|
|
|
- b.Excel.MergeCell(b.SheetName, fontCell, fmt.Sprintf("H%d", row+2))
|
|
|
|
|
|
+ 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))
|
|
b.Excel.SetCellStyle(b.SheetName, fontCell, fontCell, style1)
|
|
b.Excel.SetCellStyle(b.SheetName, fontCell, fontCell, style1)
|
|
b.Excel.SetCellValue(b.SheetName, fontCell, "审核签字:")
|
|
b.Excel.SetCellValue(b.SheetName, fontCell, "审核签字:")
|
|
|
|
|
|
// 签字图片1 I10-J12
|
|
// 签字图片1 I10-J12
|
|
- b.Excel.MergeCell(b.SheetName, imageCell1, fmt.Sprintf("J%d", row+2))
|
|
|
|
|
|
+ b.Excel.MergeCell(b.SheetName, imageCell1, fmt.Sprintf("J%d", b.Row+2))
|
|
b.Excel.SetCellStyle(b.SheetName, imageCell1, imageCell1, style1)
|
|
b.Excel.SetCellStyle(b.SheetName, imageCell1, imageCell1, style1)
|
|
b.Excel.SetCellValue(b.SheetName, imageCell1, "")
|
|
b.Excel.SetCellValue(b.SheetName, imageCell1, "")
|
|
|
|
|
|
// 签字图片2 K10-L12
|
|
// 签字图片2 K10-L12
|
|
- b.Excel.MergeCell(b.SheetName, imageCell2, fmt.Sprintf("L%d", row+2))
|
|
|
|
|
|
+ b.Excel.MergeCell(b.SheetName, imageCell2, fmt.Sprintf("L%d", b.Row+2))
|
|
b.Excel.SetCellStyle(b.SheetName, imageCell2, imageCell1, style1)
|
|
b.Excel.SetCellStyle(b.SheetName, imageCell2, imageCell1, style1)
|
|
b.Excel.SetCellValue(b.SheetName, imageCell2, "")
|
|
b.Excel.SetCellValue(b.SheetName, imageCell2, "")
|
|
|
|
|
|
@@ -306,7 +287,7 @@ func (b *ProduceBillExcel) drawTableSignature() error {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- b.Excel.SetRowHeight(b.SheetName, row, 21)
|
|
|
|
|
|
+ b.Excel.SetRowHeight(b.SheetName, b.Row, 21)
|
|
|
|
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
@@ -343,11 +324,6 @@ func NewProduceBill(f *excelize.File) *ProduceBillExcel {
|
|
Signatures: make([]*model.Signature, 0),
|
|
Signatures: make([]*model.Signature, 0),
|
|
}
|
|
}
|
|
|
|
|
|
- // f.SetColWidth(b.SheetName, "A", "A", 17)
|
|
|
|
- // f.SetColWidth(b.SheetName, "B", "B", 13)
|
|
|
|
- // f.SetColWidth(b.SheetName, "C", "G", 9.5)
|
|
|
|
- // f.SetColWidth(b.SheetName, "H", "I", 12)
|
|
|
|
-
|
|
|
|
f.SetColWidth(b.SheetName, "A", "A", 12)
|
|
f.SetColWidth(b.SheetName, "A", "A", 12)
|
|
f.SetColWidth(b.SheetName, "B", "K", 9.5)
|
|
f.SetColWidth(b.SheetName, "B", "K", 9.5)
|
|
// f.SetColWidth(b.SheetName, "I", "J", 8)
|
|
// f.SetColWidth(b.SheetName, "I", "J", 8)
|