animeic 2 years ago
parent
commit
de0a9b4dd3

+ 7 - 4
boxcost/api/bill-produce.go

@@ -206,10 +206,13 @@ func UpdateProduceBill(c *gin.Context, apictx *ApiSession) (interface{}, error)
 	}
 
 	// 如果更改类型
-	if billType != bill.Type {
-		bill.SerialNumber, err = generateSerial(apictx, bill.Type)
-		if err != nil {
-			return nil, err
+	if len(bill.Type) > 0 {
+		if billType != bill.Type {
+			bill.SerialNumber, err = generateSerial(apictx, bill.Type)
+			if err != nil {
+				return nil, err
+			}
+
 		}
 	}
 	// 计算结算价格

+ 8 - 4
boxcost/api/bill-product.go

@@ -206,12 +206,16 @@ func UpdateProductBill(c *gin.Context, apictx *ApiSession) (interface{}, error)
 	}
 
 	// 如果更改类型
-	if billType != bill.Type {
-		bill.SerialNumber, err = generateSerial(apictx, bill.Type)
-		if err != nil {
-			return nil, err
+	if len(bill.Type) > 0 {
+		if billType != bill.Type {
+			bill.SerialNumber, err = generateSerial(apictx, bill.Type)
+			if err != nil {
+				return nil, err
+			}
+
 		}
 	}
+
 	// 计算结算价格
 	if bill.Status == "complete" {
 		bill.CompleteTime = time.Now()

+ 8 - 5
boxcost/api/bill.go

@@ -300,13 +300,16 @@ func UpdateBill(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	}
 
 	// 如果更改类型
-	if billType != bill.Type {
-		bill.SerialNumber, err = generateSerial(apictx, bill.Type)
-		if err != nil {
-			return nil, err
-		}
+	if len(bill.Type) > 0 {
+		if billType != bill.Type {
+			bill.SerialNumber, err = generateSerial(apictx, bill.Type)
+			if err != nil {
+				return nil, err
+			}
 
+		}
 	}
+
 	if bill.Status == "complete" {
 		bill.CompleteTime = time.Now()
 	}

+ 23 - 10
boxcost/api/plan-cost-excel.go

@@ -128,13 +128,13 @@ func (b *PlanCostExcel) drawTableTitle() error {
 	}
 
 	drawCol("A", "产品部件名称")
-	drawCol2("B", "C", "材料/工序", "材料", "工序")
+	drawCol2("B", "C", "类型/项目", "类型", "项目")
 	drawCol("D", "供应商名称")
 	drawCol3("E", "F", "G", "规格", "厚度(纸克)", "长", "宽")
 	drawCol("H", "单位")
 	drawCol("I", "下单数量")
 	drawCol("J", "实际数量")
-	drawCol("K", "单价")
+	drawCol("K", "单价") // ??? 下单单价
 	drawCol("L", "预算金额")
 	drawCol("M", "实际金额")
 	return nil
@@ -322,19 +322,32 @@ func (b *PlanCostExcel) drawAllContent() error {
 					if stage.SupplierInfo != nil {
 						supplierName = stage.SupplierInfo.Name
 					}
-					b.drawRow(b.Row, "", stage.Name, "", supplierName, stage.Norm, matHeigth, matWidth, stage.Unit, orderCount, realCount, price, budgetPrice, realPrice)
+					stageType := ""
+					if stage.BillType > 0 {
+						stage.Type = stage.BillType
+					}
+					if stage.Type == 1 {
+						stageType = "材料采购"
+					}
+					if stage.Type == 2 {
+						stageType = "工艺"
+					}
+					if stage.Type == 3 {
+						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)
 					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
 				// 组件名字

+ 1 - 0
boxcost/api/utils.go

@@ -78,6 +78,7 @@ func generateSerial(ctx *ApiSession, typeName string) (serial string, err error)
 }
 
 func searchBillTypeById(ctx *ApiSession, collectName string, id primitive.ObjectID) (string, error) {
+	fmt.Println(id.Hex())
 	found, curbill := repo.RepoSeachDocMap(ctx.CreateRepoCtx(), &repo.DocSearchOptions{
 		CollectName: collectName,
 		Project:     []string{"type"},