소스 검색

销售出库添加分批出库相关功能逻辑

lph 10 달 전
부모
커밋
1cd7ded3ee
2개의 변경된 파일279개의 추가작업 그리고 56개의 파일을 삭제
  1. 1 1
      zkqy-ui/src/views/orderMange/index.vue
  2. 278 55
      zkqy-ui/src/views/orderMange/outStock/index.vue

+ 1 - 1
zkqy-ui/src/views/orderMange/index.vue

@@ -809,7 +809,7 @@
         :title="stockTitle"
         :visible.sync="outStockShow"
         width="1200px"
-        :before-close="getList"
+        :before-close="outStockCloseHandler"
       >
         <!-- <OutStock ref="outStockRef"></OutStock> -->
         <OutStockDetail ref="OutStockDetailRef"></OutStockDetail>

+ 278 - 55
zkqy-ui/src/views/orderMange/outStock/index.vue

@@ -1,19 +1,62 @@
 <template>
   <el-card shadow="always" :body-style="{ padding: '10px' }">
     <div class="app-container">
-      <el-row :gutter="10">
+      <el-row>
         <el-col :span="10">
           <div class="table-area">
-            <el-button
-              type="success"
-              size="small"
-              @click="handleRefresh"
-              :icon="loading ? 'el-icon-loading' : 'el-icon-refresh'"
-              :disabled="loading"
-              >刷新
-            </el-button>
-
+            <el-row>
+              <el-form
+                :model="queryParams"
+                ref="queryParams"
+                label-width="80px"
+                :inline="true"
+                size="mini"
+              >
+                <el-col :span="10">
+                  <el-form-item label="客户名称:">
+                    <el-input
+                      style="width: 126px"
+                      placeholder="请输入"
+                      clearable
+                      @keyup.enter.native="initData"
+                      v-model="queryParams.customerName"
+                    ></el-input>
+                  </el-form-item>
+                </el-col>
+                <el-col :span="10">
+                  <el-form-item label="通知单号:">
+                    <el-input
+                      style="width: 126px"
+                      placeholder="请输入"
+                      clearable
+                      @keyup.enter.native="initData"
+                      v-model="queryParams.noticeNumber"
+                    ></el-input>
+                  </el-form-item>
+                </el-col>
+                <el-col :span="4">
+                  <el-form-item>
+                    <el-button
+                      type="success"
+                      size="mini"
+                      @click="handleRefresh"
+                      :icon="loading ? 'el-icon-loading' : 'el-icon-search'"
+                      :disabled="loading"
+                      >查询
+                    </el-button>
+                    <!-- <el-button
+                      type="info"
+                      size="mini"
+                      @click="reSetQueryParams"
+                      icon="el-icon-refresh"
+                      >重置</el-button
+                    > -->
+                  </el-form-item>
+                </el-col>
+              </el-form>
+            </el-row>
             <el-table
+              ref="leftTableDataRef"
               :data="leftTableData"
               border
               stripe
@@ -42,6 +85,13 @@
               >
               </el-table-column>
             </el-table>
+            <pagination
+              v-show="total > 0"
+              :total="total"
+              :page.sync="queryParams.pageNum"
+              :limit.sync="queryParams.pageSize"
+              @pagination="initData"
+            />
           </div>
         </el-col>
         <el-col :span="14">
@@ -121,6 +171,24 @@
                     </el-select>
                   </el-form-item>
                 </el-col>
+                <el-col :span="12">
+                  <el-form-item label="批次" prop="batchNumber">
+                    <el-select
+                      v-model="form.batchNumber"
+                      clearable
+                      filterable
+                      @change="batchChangeHandler"
+                    >
+                      <el-option
+                        v-for="item in batchList"
+                        :key="item.value"
+                        :label="item.label"
+                        :value="item.value"
+                      >
+                      </el-option>
+                    </el-select>
+                  </el-form-item>
+                </el-col>
                 <!-- <el-col :span="12">
               <el-form-item label="调拨仓库" prop="transferWarehouse">
                 <el-select
@@ -138,12 +206,14 @@
                 </el-select>
               </el-form-item>
             </el-col> -->
-                <el-form-item>
-                  <el-button type="primary" @click="outStockHandler"
-                    >出库
-                  </el-button>
-                  <el-button @click="refreshHandler">刷新</el-button>
-                </el-form-item>
+                <el-col :span="12">
+                  <el-form-item>
+                    <el-button type="primary" @click="outStockHandler"
+                      >出库
+                    </el-button>
+                    <el-button @click="refreshHandler">刷新</el-button>
+                  </el-form-item>
+                </el-col>
               </el-form>
             </el-row>
             <el-table
@@ -153,7 +223,7 @@
               :span-method="objectSpanMethod"
               :row-class-name="tableRowClassName"
             >
-              <el-table-column align="center" label="编码" prop="productCode">
+              <el-table-column align="center" label="编码" prop="productId">
               </el-table-column>
               <el-table-column align="center" label="品名" prop="productName">
               </el-table-column>
@@ -164,10 +234,19 @@
               >
               </el-table-column>
               <el-table-column align="center" label="色泽" prop="productColor">
+                <template slot-scope="scope">
+                  {{ scope.row.productColor || scope.row.productColour }}
+                </template>
               </el-table-column>
               <el-table-column align="center" label="批号" prop="lotNum">
+                <template slot-scope="scope">
+                  {{ scope.row.lotNum || scope.row.lotNumber }}
+                </template>
               </el-table-column>
               <el-table-column align="center" label="等级" prop="levels">
+                <template slot-scope="scope">
+                  {{ scope.row.productLevel || scope.row.levels }}
+                </template>
               </el-table-column>
               <el-table-column align="center" label="通知">
                 <el-table-column
@@ -193,6 +272,9 @@
                 >
                 </el-table-column>
                 <el-table-column align="center" label="重量" prop="weight">
+                  <template slot-scope="scope">
+                    {{ scope.row.weight || scope.row.productNumber }}
+                  </template>
                 </el-table-column>
               </el-table-column>
             </el-table>
@@ -209,6 +291,7 @@ import {
   saleStorageDetails,
   queryDropDownBoxData,
   noticeOutStorage,
+  printOutsourceOrderList,
 } from "@/api/tablelist/commonTable";
 import { mapState } from "vuex";
 
@@ -237,6 +320,7 @@ export default {
         deliveryWarehouse: "", //发货仓库
         transferWarehouse: "", //调拨仓库
         id: "",
+        batchNumber: "", //批次
       },
       leftTableData: [],
       warehouseList: [],
@@ -252,9 +336,90 @@ export default {
           { required: true, message: "请选择调拨仓库", trigger: "change" },
         ],
       },
+      queryParams: {
+        pageSize: 10,
+        pageNum: 1,
+        customerName: "",
+        noticeNumber: "",
+      },
+      total: 0,
+      batchDataMap: {},
+      batchList: [], //批次数据
+      rightProductInfoList: [],
+      allSaleProductInfoList: [],
     };
   },
   methods: {
+    // 批次改变
+    batchChangeHandler(value) {
+      if (value === "all") {
+        //全部
+        this.saleProductInfoList = this.formateProductData(
+          this.allSaleProductInfoList
+        );
+      } else {
+        let temp = this.formateProductData(this.batchDataMap[value], false);
+        temp.forEach((item) => {
+          let targetItem = this.allSaleProductInfoList.find((item2) => {
+            return (
+              item2.productId === item.productId &&
+              item2.productColor === item.productColour &&
+              item2.levels == item.productLevel
+            );
+          });
+          item.actualWeight = targetItem?.actualWeight || "";
+        });
+        this.saleProductInfoList = temp;
+      }
+    },
+    // 产品数据整合函数
+    formateProductData(list, flag = true) {
+      //flag:true 旧接口  false 新接口
+      // 使用 reduce 方法来累加相同 productCode 和 productColor 的第一条数据的 boxNum
+      const codeColorSums = list.reduce((acc, curr, index) => {
+        // 创建一个用于组合 productCode 和 productColor 的键
+        const key = flag
+          ? `${curr.productId}-${curr.productColor}-${curr.levels}`
+          : `${curr.productId}-${curr.productColour}-${curr.productLevel}`;
+
+        // 检查当前 key 是否已经存在
+        if (!acc[key]) {
+          // 如果不存在,添加 key 作为键,并将 boxNum 设置为当前值
+          acc[key] = {
+            firstIndex: index,
+            sum: curr.boxNum,
+            weight: flag ? curr.weight : curr.productNumber,
+            count: 1,
+          };
+        } else {
+          acc[key].count++; // 增加计数
+          acc[key].sum += curr.boxNum;
+          acc[key].weight += flag ? curr.weight : curr.productNumber;
+        }
+        return acc;
+      }, {});
+      list.forEach((item, index) => {
+        const key = flag
+          ? `${item.productId}-${item.productColor}-${item.levels}`
+          : `${item.productId}-${item.productColour}-${item.productLevel}`;
+        if (codeColorSums[key]) {
+          item.coutBoxNum = codeColorSums[key].sum;
+          item.coutweight = codeColorSums[key].weight.toFixed(2);
+        }
+      });
+      console.log("list", list);
+      return list;
+    },
+    // 重置查询
+    reSetQueryParams() {
+      this.queryParams = {
+        pageSize: 10,
+        pageNum: 1,
+        customerName: "",
+        noticeNumber: "",
+      };
+      this.initData();
+    },
     tableRowClassName({ row, rowIndex }) {
       if (!row.actualWeight && row.actualWeight != 0) {
         return "warning-row";
@@ -309,6 +474,10 @@ export default {
     },
     // 出库回调
     outStockHandler() {
+      if (!this.form.deliveryWarehouse) {
+        this.$message.error("请选择发货仓库");
+        return;
+      }
       this.$refs.form.validate(async (valid) => {
         if (valid) {
           this.$confirm("是否确认出库?", "提示", {
@@ -364,20 +533,27 @@ export default {
         } else {
           throw new Error(res.msg);
         }
-      } catch (error) {}
+      } catch (error) {
+        this.$message.error(error.message);
+      }
     },
     // 初始化数据
     async initData() {
       try {
         let payload = {
-          isEnablePaging: false,
+          ...this.queryParams,
           status: 1,
         };
         let res = await productInvoiceList(payload);
         if (res.code == 200) {
           this.leftTableData = res.rows;
+          this.total = res.total;
+          this.$nextTick(() => {
+            this.$refs.leftTableDataRef.setCurrentRow(this.leftTableData[0]);
+          });
           if (this.leftTableData.length > 0) {
             this.currentIndex = 0;
+
             this.initFormData();
           }
         } else {
@@ -397,10 +573,12 @@ export default {
     async initFormData() {
       // let { id, customerName } = this.leftTableData[this.currentIndex];
       let id = false,
-        customerName;
+        customerName,
+        saleNo;
       if (this.leftTableData[this.currentIndex]) {
         id = this.leftTableData[this.currentIndex].id;
         customerName = this.leftTableData[this.currentIndex].customerName;
+        saleNo = this.leftTableData[this.currentIndex].saleOrderNo;
       }
       if (!id) {
         //重置表单数据
@@ -438,42 +616,46 @@ export default {
           //    let {productColor : colorB,productCode : codeB}=b
           //   return (colorA+codeA)-(colorB-codeB)
           // })
-
-          this.saleProductInfoList = saleProductInfoList;
+          this.allSaleProductInfoList = JSON.parse(
+            JSON.stringify(saleProductInfoList)
+          );
+          this.saleProductInfoList =
+            this.formateProductData(saleProductInfoList);
           // 使用 reduce 方法来累加相同 productCode 和 productColor 的第一条数据的 boxNum
-          const codeColorSums = this.saleProductInfoList.reduce(
-            (acc, curr, index) => {
-              // 创建一个用于组合 productCode 和 productColor 的键
-              const key = `${curr.productCode}-${curr.productColor}`;
+          // const codeColorSums = this.saleProductInfoList.reduce(
+          //   (acc, curr, index) => {
+          //     // 创建一个用于组合 productCode 和 productColor 的键
+          //     const key = `${curr.productCode}-${curr.productColor}`;
 
-              // 检查当前 key 是否已经存在
-              if (!acc[key]) {
-                // 如果不存在,添加 key 作为键,并将 boxNum 设置为当前值
-                acc[key] = {
-                  firstIndex: index,
-                  sum: curr.boxNum,
-                  weight: curr.weight,
-                  count: 1,
-                };
-              } else {
-                acc[key].count++; // 增加计数
-                acc[key].sum += curr.boxNum;
-                acc[key].weight += curr.weight;
-              }
-              return acc;
-            },
-            {}
-          );
-          this.saleProductInfoList.forEach((item, index) => {
-            if (codeColorSums[`${item.productCode}-${item.productColor}`]) {
-              item.coutBoxNum =
-                codeColorSums[`${item.productCode}-${item.productColor}`].sum;
-              item.coutweight =
-                codeColorSums[
-                  `${item.productCode}-${item.productColor}`
-                ].weight.toFixed(2);
-            }
-          });
+          //     // 检查当前 key 是否已经存在
+          //     if (!acc[key]) {
+          //       // 如果不存在,添加 key 作为键,并将 boxNum 设置为当前值
+          //       acc[key] = {
+          //         firstIndex: index,
+          //         sum: curr.boxNum,
+          //         weight: curr.weight,
+          //         count: 1,
+          //       };
+          //     } else {
+          //       acc[key].count++; // 增加计数
+          //       acc[key].sum += curr.boxNum;
+          //       acc[key].weight += curr.weight;
+          //     }
+          //     return acc;
+          //   },
+          //   {}
+          // );
+          // this.saleProductInfoList.forEach((item, index) => {
+          //   if (codeColorSums[`${item.productCode}-${item.productColor}`]) {
+          //     item.coutBoxNum =
+          //       codeColorSums[`${item.productCode}-${item.productColor}`].sum;
+          //     item.coutweight =
+          //       codeColorSums[
+          //         `${item.productCode}-${item.productColor}`
+          //       ].weight.toFixed(2);
+          //   }
+          // });
+          // console.log("this.saleProductInfoList", this.saleProductInfoList);
 
           Object.assign(this.form, {
             noticeNumber, //通知单号
@@ -488,7 +670,48 @@ export default {
           });
           this.form.deliveryClerk = this.nickName;
         }
-      } catch (error) {}
+
+        // 获取批次数据
+        let lotRes = await printOutsourceOrderList({ saleNo });
+        if (lotRes.code == 200) {
+          let tempMap = {};
+          this.batchList = [
+            {
+              value: 0,
+              label: "当前批",
+            },
+            {
+              value: "all",
+              label: "全部批次",
+            },
+          ];
+          this.form.batchNumber = "all";
+
+          lotRes.data.forEach((item) => {
+            if (!item.batchNumber) {
+              if (tempMap[0]) {
+                tempMap[0].push(item);
+              } else {
+                tempMap[0] = [item];
+              }
+            } else if (tempMap[item.batchNumber]) {
+              tempMap[item.batchNumber].push(item);
+            } else {
+              tempMap[item.batchNumber] = [item];
+              this.batchList.push({
+                value: item.batchNumber,
+                label: item.batchNumber + "批",
+              });
+            }
+          });
+          if (!tempMap[0]) tempMap[0] = [];
+          this.batchDataMap = tempMap; //根据批次分组
+        } else {
+          throw new Error(lotRes.msg);
+        }
+      } catch (error) {
+        console.log(error);
+      }
     },
   },
   computed: {