animeic 2 年之前
父節點
當前提交
f9d798390a
共有 3 個文件被更改,包括 114 次插入37 次删除
  1. 0 2
      boxcost/api/bill-produce-excel.go
  2. 103 27
      boxcost/api/report-produce-excel.go
  3. 11 8
      boxcost/api/supplier.go

+ 0 - 2
boxcost/api/bill-produce-excel.go

@@ -61,9 +61,7 @@ func (b *ProduceBillExcel) drawTitle() error {
 		}
 
 	}
-
 	b.Excel.SetPageMargins(b.SheetName, marginLeft)
-
 	err := b.Excel.MergeCell(b.SheetName, startCell, endCell)
 	if err != nil {
 		return err

+ 103 - 27
boxcost/api/report-produce-excel.go

@@ -26,21 +26,47 @@ type ReportProduceExcel struct {
 }
 
 func (b *ReportProduceExcel) drawTitle() error {
+	b.Row++
+
 	// 设置外边距
-	marginLeft := excelize.PageMarginLeft(0.15)
+	startCell := fmt.Sprintf("A%d", b.Row)
 	endCell := fmt.Sprintf("L%d", b.Row)
+	marginLeft := excelize.PageMarginLeft(0.15)
+
+	if b.Content.IsPrint {
+		// A加工项目 B规格 C纸张 D来纸尺寸 E印刷尺寸 F下单数量 G完成数量 H单价 I预算金额 J实际金额 K交货时间 L备注
+		b.Excel.SetColWidth(b.SheetName, "A", "A", 16)
+		b.Excel.SetColWidth(b.SheetName, "B", "B", 14)
+		b.Excel.SetColWidth(b.SheetName, "C", "C", 10)
+		b.Excel.SetColWidth(b.SheetName, "D", "E", 14)
+		b.Excel.SetColWidth(b.SheetName, "F", "K", 12)
+		b.Excel.SetColWidth(b.SheetName, "J", "J", 18)
+
+	} else {
+		// 不是打印
+		// A加工项目 B规格 C下单数量 D完成数量 E单价 F预算金额 G实际金额 H交货时间 I备注
+		endCell = fmt.Sprintf("G%d", b.Row)
+		marginLeft = excelize.PageMarginLeft(0.6)
+		b.Excel.SetColWidth(b.SheetName, "A", "A", 16)
+		b.Excel.SetColWidth(b.SheetName, "B", "B", 14)
+		b.Excel.SetColWidth(b.SheetName, "C", "H", 12)
+		b.Excel.SetColWidth(b.SheetName, "I", "I", 18)
+		// 是覆膜
+		if b.Content.IsLam {
+
+			// A加工项目 B规格 C覆膜尺寸 D下单数量 E完成数量 F元/吨,G元/张 H预算金额 I实际金额 J交货时间 K备注
+			endCell = fmt.Sprintf("I%d", b.Row)
+			marginLeft = excelize.PageMarginLeft(0.3)
+			b.Excel.SetColWidth(b.SheetName, "A", "A", 16)
+			b.Excel.SetColWidth(b.SheetName, "B", "C", 14)
+			// 覆膜规格
+			b.Excel.SetColWidth(b.SheetName, "D", "J", 12)
+			b.Excel.SetColWidth(b.SheetName, "K", "K", 18)
+		}
 
-	// !isPrint
-	if !b.Content.IsPrint {
-		endCell = fmt.Sprintf("I%d", b.Row)
-		marginLeft = excelize.PageMarginLeft(0.4)
-		b.Excel.SetColWidth(b.SheetName, "A", "B", 16)
-		b.Excel.SetColWidth(b.SheetName, "C", "H", 10.5)
-		b.Excel.SetColWidth(b.SheetName, "I", "I", 16)
 	}
+
 	b.Excel.SetPageMargins(b.SheetName, marginLeft)
-	b.Row++
-	startCell := fmt.Sprintf("A%d", b.Row)
 	err := b.Excel.MergeCell(b.SheetName, startCell, endCell)
 	if err != nil {
 		return err
@@ -199,19 +225,35 @@ func (b *ReportProduceExcel) drawTableTitle() error {
 		return nil
 	}
 
-	// !isPrint
-	if !b.Content.IsPrint {
-		drawCol("A", "加工项目")
-		drawCol("B", "规格")
-		drawCol("C", "下单数量")
-		drawCol("D", "完成数量")
-		drawCol2("E", "单价", "元/张")
-		drawCol("F", "预算金额")
-		drawCol("G", "实际金额")
-		drawCol("H", "交货时间")
-		drawCol("I", "备注")
+	var drawCol3 = func(prefix1 string, prefix2 string, value1 string, value2 string, value3 string) error {
+		left1Cell := fmt.Sprintf("%s%d", prefix1, b.Row)
+		left2Cell := fmt.Sprintf("%s%d", prefix2, b.Row)
+		err := b.Excel.MergeCell(b.SheetName, left1Cell, left2Cell)
+		if err != nil {
+			return err
+		}
+		if err != nil {
+			fmt.Println(err)
+			return err
+		}
+		err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left2Cell, b.AlignCenterStyle)
+		if err != nil {
+			return err
+		}
+		b.Excel.SetCellValue(b.SheetName, left1Cell, value1)
 
-	} else {
+		val2Cel := fmt.Sprintf("%s%d", prefix1, b.Row+1)
+		b.Excel.SetCellStyle(b.SheetName, val2Cel, val2Cel, b.AlignCenterStyle)
+		b.Excel.SetCellValue(b.SheetName, val2Cel, value2)
+
+		val3Cel := fmt.Sprintf("%s%d", prefix2, b.Row+1)
+		b.Excel.SetCellStyle(b.SheetName, val3Cel, val3Cel, b.AlignCenterStyle)
+		b.Excel.SetCellValue(b.SheetName, val3Cel, value3)
+		return nil
+	}
+
+	unit := b.Content.Produces[0].Unit
+	if b.Content.IsPrint {
 		drawCol("A", "加工项目")
 		drawCol("B", "规格")
 		drawCol("C", "纸张")
@@ -219,11 +261,39 @@ func (b *ReportProduceExcel) drawTableTitle() error {
 		drawCol("E", "印刷尺寸")
 		drawCol("F", "下单数量")
 		drawCol("G", "完成数量")
-		drawCol2("H", "单价", "元/张")
+		drawCol2("H", "单价", unit)
 		drawCol("I", "预算金额")
 		drawCol("J", "实际金额")
 		drawCol("K", "交货时间")
 		drawCol("L", "备注")
+
+	} else {
+		if b.Content.IsLam {
+			drawCol("A", "加工项目")
+			drawCol("B", "规格")
+			drawCol("C", "覆膜尺寸")
+			drawCol("D", "下单数量")
+			drawCol("E", "完成数量")
+			unit2 := b.Content.Produces[0].Unit2
+			drawCol3("E", "G", "单价", unit, unit2)
+			drawCol("H", "预算金额")
+			drawCol("I", "实际金额")
+			drawCol("J", "交货时间")
+			drawCol("K", "备注")
+
+		} else {
+			drawCol("A", "加工项目")
+			drawCol("B", "规格")
+			drawCol("C", "下单数量")
+			drawCol("D", "完成数量")
+			drawCol2("E", "单价", unit)
+			drawCol("F", "预算金额")
+			drawCol("G", "实际金额")
+			drawCol("H", "交货时间")
+			drawCol("I", "备注")
+
+		}
+
 	}
 
 	return nil
@@ -236,6 +306,9 @@ func (b *ReportProduceExcel) drawTableContent() error {
 		// !isPrint
 		if !b.Content.IsPrint {
 			charas = []string{"A", "B", "C", "D", "E", "F", "G", "H", "I"}
+			if b.Content.IsLam {
+				charas = []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K"}
+			}
 		}
 		for i, c := range charas {
 			v := ""
@@ -273,7 +346,13 @@ func (b *ReportProduceExcel) drawTableContent() error {
 
 			// !isPrint
 			if !b.Content.IsPrint {
-				DrawRow(b.Row, produce.Name, produce.Norm, fmt.Sprintf("%d", produce.OrderCount), realCount, priceStr, budgetAmount, realPrice, deliveryTime, produce.Remark)
+
+				if b.Content.IsLam {
+					DrawRow(b.Row, produce.Name, produce.Norm, produce.PrintSize, fmt.Sprintf("%d", produce.OrderCount), realCount, priceStr, fmt.Sprintf("%.3f", produce.Price2), budgetAmount, realPrice, deliveryTime, produce.Remark)
+
+				} else {
+					DrawRow(b.Row, produce.Name, produce.Norm, fmt.Sprintf("%d", produce.OrderCount), realCount, priceStr, budgetAmount, realPrice, deliveryTime, produce.Remark)
+				}
 			} else {
 				DrawRow(b.Row, produce.Name, produce.Norm, produce.Paper, produce.PaperSize, produce.PrintSize, fmt.Sprintf("%d", produce.OrderCount), realCount, priceStr, budgetAmount, realPrice, deliveryTime, produce.Remark)
 
@@ -315,9 +394,6 @@ func NewReportProduceExcel(f *excelize.File) *ReportProduceExcel {
 		Offset:           0,
 		AlignCenterStyle: styleLeft,
 	}
-	f.SetColWidth(b.SheetName, "A", "A", 12)
-	f.SetColWidth(b.SheetName, "B", "K", 9.5)
-	f.SetColWidth(b.SheetName, "L", "L", 10)
 	f.SetPageMargins(b.SheetName, excelize.PageMarginTop(0), excelize.PageMarginLeft(0), excelize.PageMarginRight(0))
 
 	return b

+ 11 - 8
boxcost/api/supplier.go

@@ -113,10 +113,6 @@ func GetSuppliers(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 
 func GetPlanSuppliers(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	page, size, query := UtilQueryPageSize(c)
-	if _name, ok := query["name"]; ok {
-		delete(query, "name")
-		query["name"] = bson.M{"$regex": _name.(string)}
-	}
 	//category =>根据内容查询 供应对应内容的供应商
 	emtyPage := &repo.PageResult{
 		Total: 0,
@@ -135,15 +131,21 @@ func GetPlanSuppliers(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 		}
 		return repo.RepoPageSearch(apictx.CreateRepoCtx(), option)
 	}
+	if _name, ok := query["name"]; ok {
+		delete(query, "name")
+		query["name"] = bson.M{"$regex": _name.(string)}
+	}
 
 	if cate, ok := query["category"]; ok {
 		delete(query, "category")
+		query["categorys"] = bson.M{"$in": []string{cate.(string)}}
 		option := &repo.PageSearchOptions{
 			CollectName: repo.CollectionSupplier,
-			Query:       repo.Map{"categorys": bson.M{"$in": []string{cate.(string)}}},
-			Page:        page,
-			Size:        size,
-			Sort:        bson.M{"createTime": -1},
+			// Query:       repo.Map{"categorys": bson.M{"$in": []string{cate.(string)}}},
+			Query: query,
+			Page:  page,
+			Size:  size,
+			Sort:  bson.M{"createTime": -1},
 		}
 		return repo.RepoPageSearch(apictx.CreateRepoCtx(), option)
 	}
@@ -269,6 +271,7 @@ func GetPlanSuppliers(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 		return emtyPage, nil
 	}
 
+	query["_id"] = bson.M{"$in": suppliers}
 	option := &repo.PageSearchOptions{
 		CollectName: repo.CollectionSupplier,
 		Query:       repo.Map{"_id": bson.M{"$in": suppliers}},