animeic 2 rokov pred
rodič
commit
ffb0ad2345

+ 4 - 4
boxcost/api/report-produce-excel.go

@@ -21,8 +21,8 @@ type ReportProduceExcel struct {
 
 	Content *model.ProduceBill
 
-	BudgetCount float64
-	RealCount   float64
+	BudgetAmount float64
+	RealAmount   float64
 }
 
 func (b *ReportProduceExcel) drawTitle() error {
@@ -211,8 +211,8 @@ func (b *ReportProduceExcel) drawTableContent() error {
 			deliveryTime := produce.DeliveryTime.Local().Format("2006-01-02")
 			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.BudgetCount += produce.Price * float64(produce.OrderCount)
-			b.RealCount += produce.Price * float64(produce.ConfirmCount)
+			b.BudgetAmount += produce.Price * float64(produce.OrderCount)
+			b.RealAmount += produce.Price * float64(produce.ConfirmCount)
 		}
 	}
 

+ 7 - 12
boxcost/api/report-product-excel.go

@@ -26,14 +26,13 @@ type ReportProductExcel struct {
 
 	Content *model.ProductBill
 
-	BudgetCount float64
-	RealCount   float64
+	BudgetAmount float64
+	RealAmount   float64
 }
 
 func (b *ReportProductExcel) drawTitle() error {
 	marginLeft := excelize.PageMarginLeft(0.3)
 	b.Excel.SetPageMargins(b.SheetName, marginLeft)
-	// 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))
@@ -57,7 +56,6 @@ func (b *ReportProductExcel) drawTitle() error {
 }
 
 func (b *ReportProductExcel) drawSubTitles() error {
-	// row := b.Offset + 2
 	b.Row++
 	styleLeft, err := b.Excel.NewStyle(&excelize.Style{
 		Alignment: &excelize.Alignment{Horizontal: "left", Vertical: "center"},
@@ -129,7 +127,6 @@ func (b *ReportProductExcel) drawSubTitles() error {
 }
 
 func (b *ReportProductExcel) drawTableTitle() error {
-	// row := b.Offset + 5
 	b.Row++
 	// 品名 规格  数量 单位 单价 金额
 	var drawCol = func(prefix string, value string) error {
@@ -163,8 +160,6 @@ func (b *ReportProductExcel) drawTableTitle() error {
 }
 
 func (b *ReportProductExcel) drawTableContent() error {
-	// row := b.Offset + 7
-	// b.Row = row
 	b.Row += 2
 
 	var DrawRow = func(rowIndex int, values ...string) {
@@ -186,8 +181,8 @@ func (b *ReportProductExcel) drawTableContent() error {
 	if len(products) > 0 {
 		for _, product := range products {
 			deliveryTime := product.DeliveryTime.Local().Format("2006-01-02")
-			realCount := "-"
-			realPrice := "-"
+			realCount := ""
+			realPrice := ""
 			// 预算金额
 			orderPrice := fmt.Sprintf("%.3f", float64(product.OrderCount)*product.Price)
 			b.FormatToEmpty(&orderPrice)
@@ -206,8 +201,8 @@ func (b *ReportProductExcel) drawTableContent() error {
 			b.FormatToEmpty(&price)
 			DrawRow(b.Row, product.Name, product.Norm, orderCount, product.Unit, realCount, price, orderPrice, realPrice, deliveryTime, product.Remark)
 			b.Row++
-			b.BudgetCount += float64(product.OrderCount) * product.Price
-			b.RealCount += float64(product.ConfirmCount) * product.Price
+			b.BudgetAmount += float64(product.OrderCount) * product.Price
+			b.RealAmount += float64(product.ConfirmCount) * product.Price
 		}
 	}
 
@@ -222,7 +217,7 @@ func (b *ReportProductExcel) drawRemark() error {
 	b.Row++
 
 	remarkContentScell := fmt.Sprintf("A%d", b.Row)
-	// 预留五行备注内容
+	// 根据换行符确定多少行单元格
 	reg := regexp.MustCompile(`\n`)
 	remarkRowNum := len(reg.FindAllString(b.Content.Remark, -1)) + 1
 	b.Row += remarkRowNum

+ 41 - 49
boxcost/api/report.go

@@ -87,28 +87,25 @@ func ReportProduceDownload(c *gin.Context, apictx *ApiSession) (interface{}, err
 		Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
 		Border:    border,
 	})
-	offset := 0
 	companyName := getCompanyName(apictx)
 
-	var budgetCount float64 = 0
-	var realCount float64 = 0
+	var budgetAmount float64 = 0
+	var realAmount float64 = 0
 	var row int = 0
 
 	for _, produce := range produces {
 		produceExcel := NewReportProduceExcel(f)
+		produceExcel.Row = row
 		produceExcel.Content = produce
-
 		produceExcel.Title = fmt.Sprintf("%s加工单", companyName)
 		//设置对应的数据
-		produceExcel.Offset = offset
 		produceExcel.Draws()
-		budgetCount += produceExcel.BudgetCount
-		realCount += produceExcel.RealCount
-		offset += 15
-		row = produceExcel.Row
+		budgetAmount += produceExcel.BudgetAmount
+		realAmount += produceExcel.RealAmount
+		row = produceExcel.Row + 3
 
 	}
-	row++
+	row = row - 2
 	startCell := fmt.Sprintf("%s%d", "A", row)
 	endCell := fmt.Sprintf("%s%d", "H", row)
 	f.MergeCell(sheetName, startCell, endCell)
@@ -116,23 +113,23 @@ func ReportProduceDownload(c *gin.Context, apictx *ApiSession) (interface{}, err
 	f.SetCellValue(sheetName, startCell, "汇总金额")
 
 	// 预算金额汇总
-	budgetCountCell := fmt.Sprintf("%s%d", "I", row)
-	budgetCountStr := ""
-	if realCount > 0 {
-		budgetCountStr = fmt.Sprintf("%.3f", budgetCount)
+	budgetAmountCell := fmt.Sprintf("%s%d", "I", row)
+	budgetAmountStr := ""
+	if budgetAmount > 0 {
+		budgetAmountStr = fmt.Sprintf("%.3f", budgetAmount)
 	}
-	f.SetCellValue(sheetName, budgetCountCell, budgetCountStr)
-	f.SetCellStyle(sheetName, budgetCountCell, budgetCountCell, alignCenterStyle)
+	f.SetCellValue(sheetName, budgetAmountCell, budgetAmountStr)
+	f.SetCellStyle(sheetName, budgetAmountCell, budgetAmountCell, alignCenterStyle)
 
 	// 实际金额汇总
-	RealCountCell := fmt.Sprintf("%s%d", "J", row)
+	realAmountCell := fmt.Sprintf("%s%d", "J", row)
 
-	realCountStr := ""
-	if realCount > 0 {
-		realCountStr = fmt.Sprintf("%.3f", realCount)
+	realAmountStr := ""
+	if realAmount > 0 {
+		realAmountStr = fmt.Sprintf("%.3f", realAmount)
 	}
-	f.SetCellValue(sheetName, RealCountCell, realCountStr)
-	f.SetCellStyle(sheetName, RealCountCell, RealCountCell, alignCenterStyle)
+	f.SetCellValue(sheetName, realAmountCell, realAmountStr)
+	f.SetCellStyle(sheetName, realAmountCell, realAmountCell, alignCenterStyle)
 
 	f.SetRowHeight(sheetName, row, 21)
 
@@ -260,28 +257,23 @@ func ReportProductDownload(c *gin.Context, apictx *ApiSession) (interface{}, err
 		Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
 		Border:    border,
 	})
-	offset := 0
 	companyName := getCompanyName(apictx)
 
-	var budgetCount float64 = 0
-	var realCount float64 = 0
+	var budgetAmount float64 = 0
+	var realAmount float64 = 0
 	var row int = 0
 
 	for _, product := range products {
-		produceExcel := NewReportProductBill(f)
-		produceExcel.Content = product
-
-		produceExcel.Title = fmt.Sprintf("%s成品采购单", companyName)
-		//设置对应的数据
-		produceExcel.Offset = offset
-		produceExcel.Draws()
-		budgetCount += produceExcel.BudgetCount
-		realCount += produceExcel.RealCount
-		offset += 15
-		row = produceExcel.Row
-
+		productExcel := NewReportProductBill(f)
+		productExcel.Row = row
+		productExcel.Content = product
+		productExcel.Title = fmt.Sprintf("%s成品采购单", companyName)
+		productExcel.Draws()
+		budgetAmount += productExcel.BudgetAmount
+		realAmount += productExcel.RealAmount
+		row = productExcel.Row + 3
 	}
-	row++
+	row = row - 2
 	startCell := fmt.Sprintf("%s%d", "A", row)
 	endCell := fmt.Sprintf("%s%d", "H", row)
 	f.MergeCell(sheetName, startCell, endCell)
@@ -289,23 +281,23 @@ func ReportProductDownload(c *gin.Context, apictx *ApiSession) (interface{}, err
 	f.SetCellValue(sheetName, startCell, "汇总金额")
 
 	// 预算金额汇总
-	budgetCountCell := fmt.Sprintf("%s%d", "I", row)
+	budgetAmountCell := fmt.Sprintf("%s%d", "I", row)
 	budgetCountStr := ""
-	if realCount > 0 {
-		budgetCountStr = fmt.Sprintf("%.3f", budgetCount)
+	if realAmount > 0 {
+		budgetCountStr = fmt.Sprintf("%.3f", realAmount)
 	}
-	f.SetCellValue(sheetName, budgetCountCell, budgetCountStr)
-	f.SetCellStyle(sheetName, budgetCountCell, budgetCountCell, alignCenterStyle)
+	f.SetCellValue(sheetName, budgetAmountCell, budgetCountStr)
+	f.SetCellStyle(sheetName, budgetAmountCell, budgetAmountCell, alignCenterStyle)
 
 	// 实际金额汇总
-	RealCountCell := fmt.Sprintf("%s%d", "J", row)
+	realAmountCell := fmt.Sprintf("%s%d", "J", row)
 
-	realCountStr := ""
-	if realCount > 0 {
-		realCountStr = fmt.Sprintf("%.3f", realCount)
+	realAmountStr := ""
+	if realAmount > 0 {
+		realAmountStr = fmt.Sprintf("%.3f", realAmount)
 	}
-	f.SetCellValue(sheetName, RealCountCell, realCountStr)
-	f.SetCellStyle(sheetName, RealCountCell, RealCountCell, alignCenterStyle)
+	f.SetCellValue(sheetName, realAmountCell, realAmountStr)
+	f.SetCellStyle(sheetName, realAmountCell, realAmountCell, alignCenterStyle)
 
 	f.SetRowHeight(sheetName, row, 21)