瀏覽代碼

fix:修复库存导出型号展示错误

zoie 10 月之前
父節點
當前提交
61f94c64e5
共有 2 個文件被更改,包括 15 次插入10 次删除
  1. 10 9
      controllers/Stock.go
  2. 5 1
      models/Stock/StockOut.go

+ 10 - 9
controllers/Stock.go

@@ -217,24 +217,25 @@ func (c *StockController) Stock_Detail_Excel() {
 		})
 
 	StockMonthDao := Stock.NewStockMonth(orm.NewOrm())
-	for i, r := range class_List {
-
+	var j = 0
+	for _, r := range class_List {
 		StockList := StockMonthDao.Read_StockMonth_List(T_depot_id, T_product_id, r.Id, T_start_date, T_end_date)
 		if len(StockList) == 0 {
 			continue
 		}
 
-		if i == 0 {
+		if j == 0 {
 			f.SetSheetName("Sheet1", r.T_name)
 		} else {
 			f.NewSheet(r.T_name)
 		}
-		f.MergeCell(r.T_name, "A1", "K1")
+		j += 1
+		f.MergeCell(r.T_name, "A1", "J1")
 		f.SetRowStyle(r.T_name, 1, 1, Style1)
 		f.SetCellValue(r.T_name, "A1", fmt.Sprintf("宝智达科技产品进销存统计表"))
 		f.SetRowHeight(r.T_name, 1, 30)
 		// 这里设置表头
-		f.SetCellStyle(r.T_name, "A2", "K2", Style2)
+		f.SetCellStyle(r.T_name, "A2", "J2", Style2)
 		f.SetRowHeight(r.T_name, 2, 20)
 
 		f.SetCellValue(r.T_name, "A2", "序号")
@@ -247,7 +248,7 @@ func (c *StockController) Stock_Detail_Excel() {
 		f.SetCellValue(r.T_name, "H2", "当月出库")
 		f.SetCellValue(r.T_name, "I2", "期末库存")
 		f.SetCellValue(r.T_name, "J2", "出库项目")
-		f.SetCellValue(r.T_name, "K2", "备注")
+		//f.SetCellValue(r.T_name, "K2", "备注")
 		// 设置列宽
 		f.SetColWidth(r.T_name, "A", "A", 10)
 		f.SetColWidth(r.T_name, "B", "B", 10)
@@ -259,7 +260,7 @@ func (c *StockController) Stock_Detail_Excel() {
 		f.SetColWidth(r.T_name, "H", "H", 10)
 		f.SetColWidth(r.T_name, "I", "I", 10)
 		f.SetColWidth(r.T_name, "J", "J", 10)
-		f.SetColWidth(r.T_name, "K", "K", 10)
+		//f.SetColWidth(r.T_name, "K", "K", 10)
 		line := 2
 
 		// 循环写入数据
@@ -269,7 +270,7 @@ func (c *StockController) Stock_Detail_Excel() {
 
 			f.SetCellValue(r.T_name, fmt.Sprintf("A%d", line), line-2)
 			f.SetCellValue(r.T_name, fmt.Sprintf("B%d", line), product.T_name)
-			f.SetCellValue(r.T_name, fmt.Sprintf("C%d", line), r.T_name)
+			f.SetCellValue(r.T_name, fmt.Sprintf("C%d", line), product.T_model)
 			f.SetCellValue(r.T_name, fmt.Sprintf("D%d", line), product.T_spec)
 			f.SetCellValue(r.T_name, fmt.Sprintf("E%d", line), v.T_month)
 			f.SetCellValue(r.T_name, fmt.Sprintf("F%d", line), v.T_beginning)
@@ -291,7 +292,7 @@ func (c *StockController) Stock_Detail_Excel() {
 				},
 			})
 
-		f.SetCellStyle(r.T_name, "A2", fmt.Sprintf("K%d", line), Style4)
+		f.SetCellStyle(r.T_name, "A2", fmt.Sprintf("J%d", line), Style4)
 
 	}
 

+ 5 - 1
models/Stock/StockOut.go

@@ -67,6 +67,7 @@ type StockOut_R struct {
 	T_date            string // 业务日期
 	T_receive         string // 领取人
 	T_receive_name    string // 领取人名称
+	T_project         string // 关联项目
 }
 
 type StockOut_Detail struct {
@@ -81,6 +82,7 @@ type StockOut_Detail struct {
 	T_receive_name    string // 领取人
 	T_submit          string // 经办人
 	T_submit_name     string // 经办人
+	T_project         string // 关联项目
 	T_remark          string // 备注
 	// ----销售出库------
 	T_delivery_type  int    // 1-自送 2-自提 3-快递
@@ -102,6 +104,7 @@ func StockOutToStockOut_R(t StockOut) (r StockOut_R) {
 	r.T_date = t.T_date
 	r.T_receive = t.T_receive
 	r.T_receive_name = Account.Read_User_T_name_Get(t.T_receive)
+	r.T_project = t.T_project
 	return r
 }
 
@@ -115,6 +118,7 @@ func StockOutToStockOut_Detail(t StockOut, productList []StockOutProduct_R) (r S
 	r.T_date = t.T_date
 	r.T_receive = t.T_receive
 	r.T_receive_name = Account.Read_User_T_name_Get(t.T_receive)
+	r.T_project = t.T_project
 	r.T_remark = t.T_remark
 	r.T_delivery_type = t.T_delivery_type
 	r.T_signer_unit = t.T_signer_unit
@@ -239,7 +243,7 @@ func (dao *StockOutDaoImpl) Read_StockOutProduct_List(T_name, T_start_date, T_en
 	var r []StockOutProductList
 	sqlWhere := ""
 	if len(T_name) > 0 {
-		sqlWhere += " AND (so.t_number like \"%" + T_name + "% or so.t_remark like \"%" + T_name + "%\" or so.t_project like \"%" + T_name + "%\")"
+		sqlWhere += " AND (so.t_number like \"%" + T_name + "%\" or so.t_remark like \"%" + T_name + "%\" or so.t_project like \"%" + T_name + "%\")"
 	}
 	if T_depot_id > 0 {
 		sqlWhere += fmt.Sprintf(" AND so.t_depot_id = %d", T_depot_id)