animeic 2 жил өмнө
parent
commit
2cc269d42b

+ 13 - 9
boxcost/api/plan-cost-excel.go

@@ -210,6 +210,7 @@ func (b *PlanCostExcel) drawSupplierContent() error {
 								stage.Unit = "张"
 							}
 
+							// 生成单据时已billType为准
 							stageType := ""
 							if stage.BillType > 0 {
 								stage.Type = stage.BillType
@@ -301,7 +302,7 @@ func (b *PlanCostExcel) drawAllContent() error {
 			var perRealPrice float64 = 0.00
 			if len(comp.Stages) > 0 {
 				startRow := b.Row
-				// cates := map[string][]int{}
+				cates := map[string][]int{}
 				for _, stage := range comp.Stages {
 					matHeigth := fmt.Sprintf("%d", stage.BatchSizeHeight)
 					b.FormatToEmpty(&matHeigth)
@@ -345,18 +346,21 @@ func (b *PlanCostExcel) drawAllContent() error {
 						stageType = "成品采购"
 					}
 					b.drawRow(b.Row, "", stageType, stage.Name, supplierName, stage.Norm, matHeigth, matWidth, stage.Unit, orderCount, realCount, price, budgetPrice, realPrice)
-					// cates[stage.Group] = append(cates[stage.Group], b.Row)
+					if stage.SupplierInfo != nil {
+						cates[stage.SupplierInfo.Name] = append(cates[stage.SupplierInfo.Name], b.Row)
+
+					}
+
 					b.Row++
 
 				}
 
-				// // 合并同一供应商名
-				// for supplierName, cate := range cates {
-				// 	mergeStartRow := cate[0]
-				// 	mergeEndRow := cate[len(cate)-1]
-				// 	b.Excel.MergeCell(b.SheetName, fmt.Sprintf("D%d", mergeStartRow), fmt.Sprintf("D%d", mergeEndRow))
-				// 	b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("D%d", mergeEndRow), supplierName)
-				// }
+				for supplierName, cate := range cates {
+					mergeStartRow := cate[0]
+					mergeEndRow := cate[len(cate)-1]
+					b.Excel.MergeCell(b.SheetName, fmt.Sprintf("D%d", mergeStartRow), fmt.Sprintf("D%d", mergeEndRow))
+					b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("D%d", mergeEndRow), supplierName)
+				}
 
 				endRow := b.Row - 1
 				// 组件名字