Browse Source

成品采购调整为合同样式

animeic 2 years ago
parent
commit
7ef40a8989

+ 58 - 7
boxcost/api/bill-product-excel.go

@@ -30,8 +30,6 @@ type ProductBillExcel struct {
 }
 
 func (b *ProductBillExcel) drawTitle() error {
-	marginLeft := excelize.PageMarginLeft(0.25)
-	b.Excel.SetPageMargins(b.SheetName, marginLeft)
 	b.Row++
 	startCell := fmt.Sprintf("A%d", b.Row)
 	err := b.Excel.MergeCell(b.SheetName, startCell, fmt.Sprintf("J%d", b.Row))
@@ -98,18 +96,18 @@ func (b *ProductBillExcel) drawSubTitles() error {
 		return nil
 	}
 	//第一行
-	drawLeft(b.Row, "类别:"+b.Content.Type)
+	drawLeft(b.Row, "需求方(甲方):"+b.Title+"订单")
 	drawRight(b.Row, "单号:"+b.Content.SerialNumber)
 	b.Excel.SetRowHeight(b.SheetName, b.Row, 21)
 
 	//第二行
-	drawLeft(b.Row+1, "供应商名称:"+b.Content.Supplier)
+	drawLeft(b.Row+1, "供应方(乙方):"+b.Content.Supplier)
 	timeformat := b.Content.CreateTime.Local().Format("2006年01月02号 15:04:05")
 	drawRight(b.Row+1, "下单时间:"+timeformat)
 	b.Excel.SetRowHeight(b.SheetName, b.Row+1, 21)
 
 	//第三行
-	drawLeft(b.Row+2, "产品名称:"+b.Content.ProductName)
+	drawLeft(b.Row+2, "产品名称:"+b.Content.ProductName+"  类别:"+b.Content.Type)
 	status := ""
 	if b.Content.Status == "complete" {
 		status = "已完成"
@@ -228,7 +226,7 @@ func (b *ProductBillExcel) drawTableFooter() error {
 	sureCel := fmt.Sprintf("F%d", b.Row)
 	b.Excel.MergeCell(b.SheetName, sureCel, fmt.Sprintf("J%d", b.Row))
 	b.Excel.SetCellStyle(b.SheetName, sureCel, fmt.Sprintf("J%d", b.Row), styleLeft)
-	b.Excel.SetCellValue(b.SheetName, sureCel, "供应商签字:")
+	b.Excel.SetCellValue(b.SheetName, sureCel, "收货人:")
 
 	b.Excel.SetRowHeight(b.SheetName, b.Row, 30)
 
@@ -251,6 +249,59 @@ func (b *ProductBillExcel) drawRemark() error {
 	b.Excel.MergeCell(b.SheetName, remarkContentScell, remarkContentEcell)
 	b.Excel.SetCellValue(b.SheetName, remarkContentScell, b.Content.Remark)
 
+	// 签字位置
+	b.Row++
+	styleLeft, err := b.Excel.NewStyle(&excelize.Style{
+		Alignment: &excelize.Alignment{Horizontal: "left", Vertical: "center"},
+		Font:      &excelize.Font{Size: 11}})
+	if err != nil {
+		return err
+	}
+	var drawLeft = func(rowIndex int, value string) error {
+		//左边1
+		left1Cell := fmt.Sprintf("A%d", rowIndex)
+		err := b.Excel.MergeCell(b.SheetName, left1Cell, fmt.Sprintf("E%d", rowIndex))
+		if err != nil {
+			return err
+		}
+		err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left1Cell, styleLeft)
+		if err != nil {
+			return err
+		}
+		b.Excel.SetCellValue(b.SheetName, left1Cell, value)
+		return nil
+	}
+
+	var drawRight = func(rowIndex int, value string) error {
+		right1Cell := fmt.Sprintf("F%d", rowIndex)
+		err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("J%d", rowIndex))
+		if err != nil {
+			return err
+		}
+		err = b.Excel.SetCellStyle(b.SheetName, right1Cell, right1Cell, styleLeft)
+		if err != nil {
+			return err
+		}
+		b.Excel.SetCellValue(b.SheetName, right1Cell, value)
+		return nil
+	}
+
+	//第一行
+	drawLeft(b.Row, "甲方:"+b.Title)
+	drawRight(b.Row, "乙方:"+b.Content.Supplier)
+	b.Excel.SetRowHeight(b.SheetName, b.Row, 21)
+
+	//第二行
+	drawLeft(b.Row+1, "联系人:")
+	timeformat := b.Content.CreateTime.Local().Format("2006年01月02号 15:04:05")
+	drawRight(b.Row+1, "联系人:")
+	b.Excel.SetRowHeight(b.SheetName, b.Row+1, 21)
+
+	//第三行
+	drawLeft(b.Row+2, "时间:"+timeformat)
+	drawRight(b.Row+2, "时间:"+timeformat)
+	b.Excel.SetRowHeight(b.SheetName, b.Row+2, 21)
+
 	return nil
 
 }
@@ -342,7 +393,7 @@ func NewProductBill(f *excelize.File) *ProductBillExcel {
 	}
 
 	f.SetColWidth(b.SheetName, "A", "J", 11.5)
-	f.SetPageMargins(b.SheetName, excelize.PageMarginTop(0), excelize.PageMarginLeft(0), excelize.PageMarginRight(0))
+	f.SetPageMargins(b.SheetName, excelize.PageMarginTop(1.5), excelize.PageMarginLeft(0.25), excelize.PageMarginRight(0))
 	return b
 }
 

+ 1 - 2
boxcost/api/bill-product.go

@@ -276,8 +276,7 @@ func DownProductBill(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 
 	}
 	billExcel.Content = &bill
-	companyName := getCompanyName(apictx)
-	billExcel.Title = fmt.Sprintf("%s成品采购单", companyName)
+	billExcel.Title = getCompanyName(apictx)
 	//设置对应的数据
 	billExcel.Draws()
 

+ 1 - 3
boxcost/api/bill-purchase-excel.go

@@ -31,7 +31,6 @@ type PurchaseBillExcel struct {
 func (b *PurchaseBillExcel) drawTitle() error {
 	marginLeft := excelize.PageMarginLeft(0.15)
 	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("L%d", b.Row))
@@ -56,7 +55,6 @@ func (b *PurchaseBillExcel) drawTitle() error {
 
 func (b *PurchaseBillExcel) drawSubTitles() error {
 
-	// row := b.Offset + 2
 	b.Row++
 
 	styleLeft, err := b.Excel.NewStyle(&excelize.Style{
@@ -231,7 +229,7 @@ func (b *PurchaseBillExcel) drawTableContent() error {
 
 			realCount := ""
 			realPrice := ""
-			price := fmt.Sprintf("%.3f", paper.Price)
+			price := fmt.Sprintf("%.3f", paper.OrderPrice)
 			price2 := fmt.Sprintf("%.3f", paper.Price2)
 
 			// 预算金额

+ 1 - 1
boxcost/api/plan.go

@@ -222,7 +222,7 @@ func DownLoadCompBills(c *gin.Context, apictx *ApiSession) (interface{}, error)
 
 				}
 				billExcel.SetContent(&product)
-				billExcel.SetTitle(fmt.Sprintf("%s成品采购单", companyName))
+				billExcel.SetTitle(companyName)
 			}
 		}
 		billExcel.SetRow(row)

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

@@ -31,8 +31,6 @@ type ReportProductExcel struct {
 }
 
 func (b *ReportProductExcel) drawTitle() error {
-	marginLeft := excelize.PageMarginLeft(0.3)
-	b.Excel.SetPageMargins(b.SheetName, marginLeft)
 	b.Row++
 	startCell := fmt.Sprintf("A%d", b.Row)
 	err := b.Excel.MergeCell(b.SheetName, startCell, fmt.Sprintf("J%d", b.Row))
@@ -99,20 +97,18 @@ func (b *ReportProductExcel) drawSubTitles() error {
 		return nil
 	}
 	//第一行
-	drawLeft(b.Row, "类别:"+b.Content.Type)
+	drawLeft(b.Row, "需求方(甲方):"+b.Title+"订单")
 	drawRight(b.Row, "单号:"+b.Content.SerialNumber)
 	b.Excel.SetRowHeight(b.SheetName, b.Row, 21)
 
-	b.Row++
 	//第二行
-	drawLeft(b.Row, "供应商名称:"+b.Content.Supplier)
+	drawLeft(b.Row+1, "供应方(乙方):"+b.Content.Supplier)
 	timeformat := b.Content.CreateTime.Local().Format("2006年01月02号 15:04:05")
-	drawRight(b.Row, "下单时间:"+timeformat)
-	b.Excel.SetRowHeight(b.SheetName, b.Row, 21)
+	drawRight(b.Row+1, "下单时间:"+timeformat)
+	b.Excel.SetRowHeight(b.SheetName, b.Row+1, 21)
 
-	b.Row++
 	//第三行
-	drawLeft(b.Row, "产品名称:"+b.Content.ProductName)
+	drawLeft(b.Row+2, "产品名称:"+b.Content.ProductName+"  类别:"+b.Content.Type)
 	status := ""
 	if b.Content.Status == "complete" {
 		status = "已完成"
@@ -120,8 +116,8 @@ func (b *ReportProductExcel) drawSubTitles() error {
 	if b.Content.Status == "created" {
 		status = "进行中"
 	}
-	drawRight(b.Row, "状态:"+status)
-	b.Excel.SetRowHeight(b.SheetName, b.Row, 21)
+	drawRight(b.Row+2, "状态:"+status)
+	b.Excel.SetRowHeight(b.SheetName, b.Row+2, 21)
 
 	return nil
 }
@@ -225,6 +221,59 @@ func (b *ReportProductExcel) drawRemark() error {
 	b.Excel.MergeCell(b.SheetName, remarkContentScell, remarkContentEcell)
 	b.Excel.SetCellValue(b.SheetName, remarkContentScell, b.Content.Remark)
 
+	// 签字位置
+	b.Row++
+	styleLeft, err := b.Excel.NewStyle(&excelize.Style{
+		Alignment: &excelize.Alignment{Horizontal: "left", Vertical: "center"},
+		Font:      &excelize.Font{Size: 11}})
+	if err != nil {
+		return err
+	}
+	var drawLeft = func(rowIndex int, value string) error {
+		//左边1
+		left1Cell := fmt.Sprintf("A%d", rowIndex)
+		err := b.Excel.MergeCell(b.SheetName, left1Cell, fmt.Sprintf("E%d", rowIndex))
+		if err != nil {
+			return err
+		}
+		err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left1Cell, styleLeft)
+		if err != nil {
+			return err
+		}
+		b.Excel.SetCellValue(b.SheetName, left1Cell, value)
+		return nil
+	}
+
+	var drawRight = func(rowIndex int, value string) error {
+		right1Cell := fmt.Sprintf("F%d", rowIndex)
+		err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("J%d", rowIndex))
+		if err != nil {
+			return err
+		}
+		err = b.Excel.SetCellStyle(b.SheetName, right1Cell, right1Cell, styleLeft)
+		if err != nil {
+			return err
+		}
+		b.Excel.SetCellValue(b.SheetName, right1Cell, value)
+		return nil
+	}
+
+	//第一行
+	drawLeft(b.Row, "甲方:"+b.Title)
+	drawRight(b.Row, "乙方:"+b.Content.Supplier)
+	b.Excel.SetRowHeight(b.SheetName, b.Row, 21)
+
+	//第二行
+	drawLeft(b.Row+1, "联系人:")
+	timeformat := b.Content.CreateTime.Local().Format("2006年01月02号 15:04:05")
+	drawRight(b.Row+1, "联系人:")
+	b.Excel.SetRowHeight(b.SheetName, b.Row+1, 21)
+
+	//第三行
+	drawLeft(b.Row+2, "时间:"+timeformat)
+	drawRight(b.Row+2, "时间:"+timeformat)
+	b.Excel.SetRowHeight(b.SheetName, b.Row+2, 21)
+
 	return nil
 
 }
@@ -261,7 +310,7 @@ func NewReportProductBill(f *excelize.File) *ReportProductExcel {
 	}
 
 	f.SetColWidth(b.SheetName, "A", "J", 11.5)
-	f.SetPageMargins(b.SheetName, excelize.PageMarginTop(0), excelize.PageMarginLeft(0), excelize.PageMarginRight(0))
+	f.SetPageMargins(b.SheetName, excelize.PageMarginTop(1.5), excelize.PageMarginLeft(0.25), excelize.PageMarginRight(0))
 	return b
 }
 

+ 1 - 1
boxcost/api/report-purchase-excel.go

@@ -235,7 +235,7 @@ func (b *ReportPurchaseExcel) drawTableContent() error {
 
 			realCount := ""
 			realPrice := ""
-			price := fmt.Sprintf("%.3f", paper.Price)
+			price := fmt.Sprintf("%.3f", paper.OrderPrice)
 			price2 := fmt.Sprintf("%.3f", paper.Price2)
 
 			// 预算金额

+ 1 - 1
boxcost/api/report.go

@@ -267,7 +267,7 @@ func ReportProductDownload(c *gin.Context, apictx *ApiSession) (interface{}, err
 		productExcel := NewReportProductBill(f)
 		productExcel.Row = row
 		productExcel.Content = product
-		productExcel.Title = fmt.Sprintf("%s成品采购单", companyName)
+		productExcel.Title = companyName
 		productExcel.Draws()
 		budgetAmount += productExcel.BudgetAmount
 		realAmount += productExcel.RealAmount