| | |
| | | |
| | | moreUnit := amount.Product.MoreUnit |
| | | if moreUnit != nil && *moreUnit { |
| | | resp.AmountMoreUnits = CreateMoreUnit(resp.Amount, amount.Product.MoreUnitList) |
| | | resp.AmountMoreUnits = amount.MoreUnitList |
| | | } |
| | | |
| | | result = append(result, resp) |
| | |
| | | var fileName string |
| | | f := excelize.NewFile() |
| | | |
| | | unitData, unitIndexMap := GetAllUnits() |
| | | // 自定义表头 |
| | | headers := []interface{}{"位置", "产品", "产品类别", map[string][]string{"在库数量": {"件", "匹", "米", "重量"}}, "价值"} |
| | | headers := []interface{}{"位置", "产品", "产品类别", map[string][]string{"在库数量": unitData}, "价值"} |
| | | |
| | | // 设置表头 |
| | | var i int |
| | | i := 1 |
| | | for _, h := range headers { |
| | | if v, ok := h.(string); ok { |
| | | f.SetCellValue("Sheet1", getColumnAlphabet(i)+"1", v) |
| | |
| | | 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 + 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) |
| | | row := strconv.Itoa(i + 3) |
| | | f.SetCellValue("Sheet1", "A"+row, v.LocationName) |
| | | f.SetCellValue("Sheet1", "B"+row, v.ProductName) |
| | | f.SetCellValue("Sheet1", "C"+row, v.ProductTypeName) |
| | | v.AmountMoreUnits = append(v.AmountMoreUnits, models.UnitItems{Amount: v.Amount, Unit: v.Unit}) |
| | | FillMoreUnitToExcel(v.AmountMoreUnits, 4, i+3, unitIndexMap, f) |
| | | f.SetCellValue("Sheet1", getColumnAlphabet(4+len(unitData))+row, v.Value) |
| | | } |
| | | |
| | | fileName = fmt.Sprintf("位置报表%s.xlsx", time.Now().Format("2006-01-02-1504")) |