zhangqian
2024-07-31 da621f474d28ab041dcf258142eddb506100a8ce
service/history_forms.go
@@ -51,7 +51,7 @@
      }
      moreUnit := v.Product.MoreUnit
      if moreUnit != nil && *moreUnit {
         data.AmountMoreUnits = CreateMoreUnit(v.Amount, v.Product.MoreUnitList)
         data.AmountMoreUnits = v.MoreUnitList
      }
      result = append(result, data)
   }
@@ -77,7 +77,7 @@
   search.Orm = search.Orm.Model(&models.MoveHistory{}).
      Select("number, updated_at, product_name, from_location_id, operation_id,to_location_id, amount, " +
         "unit, operator, base_operation_type, weight, product_id, from_location, to_location, operation_type_name, weight").Order("id desc")
         "unit, operator, base_operation_type, weight, product_id, from_location, to_location, operation_type_name, weight, more_unit_value").Order("id desc")
   if len(ids) > 0 {
      search.Orm = search.Orm.Where("id in ?", ids)
   }
@@ -141,10 +141,19 @@
   // 自定义表头
   headers := []interface{}{"日期", "单号", "产品", "产品编码", "业务类型", "从", "至", map[string][]string{"数量": unitData}, "单位", "重量"}
   // 设置表头
   if err := SetExcelHeader(headers, f); err != nil {
   lastColumnNumber, err := SetExcelHeaders(headers, f)
   if err != nil {
      return "", err
   }
   for i := 1; i <= 7; i++ {
      column := getColumnAlphabet(i)
      f.MergeCell("Sheet1", column+"1", column+"2") // 合并单元格
   }
   for i := lastColumnNumber - 2; i <= lastColumnNumber; i++ {
      column := getColumnAlphabet(i)
      f.MergeCell("Sheet1", column+"1", column+"2") // 合并单元格
   }
   style, err := SetHeaderStyle(f)
@@ -152,25 +161,24 @@
      return "", err
   }
   lastColumn := getColumnAlphabet(13)
   f.SetCellStyle("Sheet1", "A1", lastColumn+"2", style)
   lastColumn := getColumnAlphabet(lastColumnNumber)
   f.SetCellStyle("Sheet1", "A1", lastColumn, style)
   // 设置列宽
   f.SetColWidth("Sheet1", "A", "G", 30)
   f.SetColWidth("Sheet1", "H", "K", 15)
   f.SetColWidth("Sheet1", "A", lastColumn, 20)
   for i, v := range dataList {
      column := strconv.Itoa(i + 3)
      f.SetCellValue("Sheet1", "A"+column, v.Date)
      f.SetCellValue("Sheet1", "B"+column, v.Number)
      f.SetCellValue("Sheet1", "C"+column, v.ProductName)
      f.SetCellValue("Sheet1", "D"+column, v.ProductId)
      f.SetCellValue("Sheet1", "E"+column, v.OperationTypeName)
      f.SetCellValue("Sheet1", "F"+column, v.FromLocation)
      f.SetCellValue("Sheet1", "G"+column, v.ToLocation)
      f.SetCellValue("Sheet1", "H"+column, v.Amount)
      FillMoreUnitToExcel(v.AmountMoreUnits, 7, i+3, unitIndexMap, f)
      f.SetCellValue("Sheet1", "L"+column, v.Unit)
      f.SetCellValue("Sheet1", "M"+column, v.Weight)
      row := strconv.Itoa(i + 3)
      f.SetCellValue("Sheet1", "A"+row, v.Date)
      f.SetCellValue("Sheet1", "B"+row, v.Number)
      f.SetCellValue("Sheet1", "C"+row, v.ProductName)
      f.SetCellValue("Sheet1", "D"+row, v.ProductId)
      f.SetCellValue("Sheet1", "E"+row, v.OperationTypeName)
      f.SetCellValue("Sheet1", "F"+row, v.FromLocation)
      f.SetCellValue("Sheet1", "G"+row, v.ToLocation)
      v.AmountMoreUnits = append(v.AmountMoreUnits, models.UnitItems{Amount: v.Amount, Unit: v.Unit})
      FillMoreUnitToExcel(v.AmountMoreUnits, 8, i+3, unitIndexMap, f)
      f.SetCellValue("Sheet1", getColumnAlphabet(8+len(unitData))+row, v.Unit)
      f.SetCellValue("Sheet1", getColumnAlphabet(9+len(unitData))+row, v.Weight)
   }
   if params.BaseOperationType == constvar.BaseOperationTypeIncoming {