From 79aef24a785581d95343ccd99e9cb362b2bc9c97 Mon Sep 17 00:00:00 2001 From: yinbentan <yinbentan@live.com> Date: 星期六, 06 七月 2024 21:31:59 +0800 Subject: [PATCH] 调整库存商品位置错误 --- service/location_forms.go | 40 +++++++++++++++++++++++++++++++++++----- 1 files changed, 35 insertions(+), 5 deletions(-) diff --git a/service/location_forms.go b/service/location_forms.go index af6a6c9..27932a2 100644 --- a/service/location_forms.go +++ b/service/location_forms.go @@ -27,14 +27,15 @@ resp := new(response.LocationForms) resp.Amount = amount.Amount resp.LocationId = amount.LocationId - resp.LocationName = amount.Location.Name + resp.LocationName = amount.Location.JointName resp.ProduceId = amount.Product.ID resp.ProductName = amount.Product.Name resp.ProductTypeName = amount.ProductCategory.Name resp.Unit = amount.Product.Unit resp.Value = resp.Amount.Mul(amount.Product.Cost) - if *amount.Product.MoreUnit { + moreUnit := amount.Product.MoreUnit + if moreUnit != nil && *moreUnit { resp.AmountMoreUnits = CreateMoreUnit(resp.Amount, amount.Product.MoreUnitList) } @@ -45,10 +46,11 @@ } func (slf *LocationFormsService) BuildSearch(params request.GetLocationForms) (search *models.LocationProductAmountSearch, err error) { - ids := make([]int, 0) + ids := params.LocationIds if params.LocationId != 0 { ids = append(ids, params.LocationId) - } else { + } + if len(ids) == 0 { //鏌ヨ浣嶇疆 locations, err := models.NewLocationSearch().SetJointName(params.WareHouseCode).SetType(3).FindAll() if err != nil { @@ -111,6 +113,7 @@ } else if childHeaders, ok := h.(map[string][]string); ok { for title, list := range childHeaders { f.SetCellValue("Sheet1", getColumnAlphabet(i)+"1", title) + err = f.MergeCell("Sheet1", getColumnAlphabet(i)+"1", getColumnAlphabet(i-1+len(list))+"1") // 鍚堝苟鍗曞厓鏍� for _, t := range list { f.SetCellValue("Sheet1", getColumnAlphabet(i)+"2", t) i++ @@ -119,13 +122,40 @@ } } + // 璁剧疆琛ㄥご鏍峰紡 + style := &excelize.Style{ + Border: nil, + Fill: excelize.Fill{ + Type: "pattern", + Pattern: 1, + Shading: 0, + }, + Font: &excelize.Font{ + Bold: true, + }, + Alignment: &excelize.Alignment{ + Horizontal: "center", + }, + } + titleStyle, err := f.NewStyle(style) + if err != nil { + return + } + + lastColumn := getColumnAlphabet(i) + f.SetCellStyle("Sheet1", "A1", lastColumn+"2", titleStyle) + // 璁剧疆鍒楀 + f.SetColWidth("Sheet1", "A", "C", 30) + f.SetColWidth("Sheet1", "D", lastColumn, 15) + for i, v := range dataList { - column := strconv.Itoa(i + 2) + column := strconv.Itoa(i + 3) f.SetCellValue("Sheet1", "A"+column, v.LocationName) f.SetCellValue("Sheet1", "B"+column, v.ProductName) f.SetCellValue("Sheet1", "C"+column, v.ProductTypeName) f.SetCellValue("Sheet1", "D"+column, v.Amount) FillMoreUnitToExcel(v.Amount, v.AmountMoreUnits, 4, i+2, f) + f.SetCellValue("Sheet1", "H"+column, v.Value) } fileName = fmt.Sprintf("浣嶇疆鎶ヨ〃%s.xlsx", time.Now().Format("2006-01-02-1504")) -- Gitblit v1.8.0