From d2e6dff92184f2c6b9cff56ce04e2f11b8494672 Mon Sep 17 00:00:00 2001
From: lishihai <dslsh@dscom>
Date: 星期四, 13 六月 2024 11:37:33 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/jialian' into jialian

---
 service/location_forms.go |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/service/location_forms.go b/service/location_forms.go
index eafd283..af6a6c9 100644
--- a/service/location_forms.go
+++ b/service/location_forms.go
@@ -33,6 +33,11 @@
 		resp.ProductTypeName = amount.ProductCategory.Name
 		resp.Unit = amount.Product.Unit
 		resp.Value = resp.Amount.Mul(amount.Product.Cost)
+
+		if *amount.Product.MoreUnit {
+			resp.AmountMoreUnits = CreateMoreUnit(resp.Amount, amount.Product.MoreUnitList)
+		}
+
 		result = append(result, resp)
 	}
 
@@ -95,12 +100,23 @@
 	f := excelize.NewFile()
 
 	// 鑷畾涔夎〃澶�
-	headers := []string{"浣嶇疆", "浜у搧", "浜у搧绫诲埆", "鍦ㄥ簱鏁伴噺", "浠峰��"}
+	headers := []interface{}{"浣嶇疆", "浜у搧", "浜у搧绫诲埆", map[string][]string{"鍦ㄥ簱鏁伴噺": {"浠�", "鍖�", "绫�", "閲嶉噺"}}, "浠峰��"}
 
 	// 璁剧疆琛ㄥご
-	for i, header := range headers {
-		cell := getColumnAlphabet(i+1) + "1"
-		f.SetCellValue("Sheet1", cell, header)
+	var i int
+	for _, h := range headers {
+		if v, ok := h.(string); ok {
+			f.SetCellValue("Sheet1", getColumnAlphabet(i)+"1", v)
+			i++
+		} else if childHeaders, ok := h.(map[string][]string); ok {
+			for title, list := range childHeaders {
+				f.SetCellValue("Sheet1", getColumnAlphabet(i)+"1", title)
+				for _, t := range list {
+					f.SetCellValue("Sheet1", getColumnAlphabet(i)+"2", t)
+					i++
+				}
+			}
+		}
 	}
 
 	for i, v := range dataList {
@@ -109,7 +125,7 @@
 		f.SetCellValue("Sheet1", "B"+column, v.ProductName)
 		f.SetCellValue("Sheet1", "C"+column, v.ProductTypeName)
 		f.SetCellValue("Sheet1", "D"+column, v.Amount)
-		f.SetCellValue("Sheet1", "E"+column, v.Value)
+		FillMoreUnitToExcel(v.Amount, v.AmountMoreUnits, 4, i+2, f)
 	}
 
 	fileName = fmt.Sprintf("浣嶇疆鎶ヨ〃%s.xlsx", time.Now().Format("2006-01-02-1504"))

--
Gitblit v1.8.0