Browse Source

出库、入库明细,和来料登记里的源单查询功能优化

chensibo 1 month ago
parent
commit
5b92e8d406

+ 32 - 2
src/views/rtkwms/inrequest/InRequestForm.vue

@@ -941,13 +941,43 @@ export default {
         this.relatedOrderList = this.allRelatedOrderList;
       }
     },
+    // remoteMethod(query) {
+    //   if (query !== "") {
+    //     this.sourceOrderNoList = this.allSourceOrderNoList.filter((item) =>
+    //       item.sourceOrderNo.toLowerCase().includes(query.toLowerCase())
+    //     );
+    //   } else {
+    //     this.sourceOrderNoList = this.allSourceOrderNoList;
+    //   }
+    // },
     remoteMethod(query) {
-      if (query !== "") {
+      if (!query) {
+        // 清空:恢复全部
+        this.sourceOrderNoList = this.allSourceOrderNoList;
+      } else if (query.length <= 4) {
+        // 1-4个字符:本地过滤
         this.sourceOrderNoList = this.allSourceOrderNoList.filter((item) =>
           item.sourceOrderNo.toLowerCase().includes(query.toLowerCase())
         );
       } else {
-        this.sourceOrderNoList = this.allSourceOrderNoList;
+        // 超过4个字符:远程搜索
+        this.loading = true;
+        InRequestApi.getSourceOrder({
+          businessType: this.formData.businessType,
+          businessDescribe: this.selectedBusinessDescribe,
+          businessCategory: this.currentBusinessDescribeRow?.value,
+          sourceOrderNo: query,
+          pageSize: 100,
+        })
+          .then(({ data }) => {
+            this.sourceOrderNoList = data || [];
+          })
+          .catch(() => {
+            this.sourceOrderNoList = [];
+          })
+          .finally(() => {
+            this.loading = false;
+          });
       }
     },
     add() {

+ 144 - 0
src/views/wms/incoming/register/components/OrderSelect2.vue

@@ -0,0 +1,144 @@
+<template>
+  <el-select
+    v-model="selectedValue"
+    filterable
+    remote
+    reserve-keyword
+    clearable
+    :disabled="disabled"
+    :placeholder="placeholder"
+    :remote-method="remoteMethod"
+    :loading="loading"
+    @change="handleChange"
+  >
+    <el-option
+      v-for="item in options"
+      :key="item.erpOrderNo"
+      :label="item.erpOrderNo"
+      :value="item.erpOrderNo"
+    />
+  </el-select>
+</template>
+
+<script>
+import { getDropDownList, getDropDownList2 } from "@/api/wms/orders/purchase";
+
+export default {
+  name: "OrderSelect",
+  props: {
+    value: {
+      type: String,
+      default: "",
+    },
+    disabled: {
+      type: Boolean,
+      default: false,
+    },
+    placeholder: {
+      type: String,
+      default: "请输入源单编号",
+    },
+    // 收料类别
+    receiptType: {
+      type: String,
+      default: "",
+    },
+  },
+  data() {
+    return {
+      selectedValue: this.value,
+      options: [],
+      loading: false,
+      allOptions: [], // 预加载的全部数据
+    };
+  },
+  watch: {
+    value(val) {
+      this.selectedValue = val;
+    },
+    selectedValue(val) {
+      this.$emit("input", val);
+    },
+    // 收料类别变化时重新加载数据
+    receiptType: {
+      immediate: true,
+      handler(val) {
+        if (val === "1" || val === "3") {
+          this.loadAllData();
+        } else {
+          this.options = [];
+          this.allOptions = [];
+          this.selectedValue = "";
+        }
+      },
+    },
+  },
+  methods: {
+    // 预加载全部数据(收料类别变化时调用)
+    async loadAllData() {
+      this.loading = true;
+      try {
+        const api =
+          this.receiptType === "3" ? getDropDownList2 : getDropDownList;
+
+        // 两个接口统一传 pageNo 和 pageSize
+        const params = {
+          pageNo: 1,
+          pageSize: 999,
+        };
+
+        const { data } = await api(params);
+        this.allOptions = data || [];
+        this.options = this.allOptions;
+      } finally {
+        this.loading = false;
+      }
+    },
+
+    // 远程搜索方法(输入超过4个字符时调用)
+    remoteMethod(query) {
+      if (!query) {
+        // 清空:恢复预加载的全部数据
+        this.options = this.allOptions;
+        return;
+      }
+
+      if (query.length <= 3) {
+        // 1-3个字符:本地过滤
+        const keyword = query.toLowerCase();
+        this.options = this.allOptions.filter((item) =>
+          item.erpOrderNo.toLowerCase().includes(keyword)
+        );
+        return;
+      }
+
+      // 超过3个字符:远程搜索
+      this.loading = true;
+      const api = this.receiptType === "3" ? getDropDownList2 : getDropDownList;
+
+      // 两个接口统一传 pageNo 和 pageSize,加上搜索关键字
+      const params = {
+        pageNo: 1,
+        pageSize: 999,
+        orderNo: query,
+      };
+
+      api(params)
+        .then(({ data }) => {
+          this.options = data || [];
+        })
+        .catch(() => {
+          this.options = [];
+        })
+        .finally(() => {
+          this.loading = false;
+        });
+    },
+
+    handleChange(val) {
+      const item = this.options.find((o) => o.erpOrderNo === val);
+      this.$emit("change", item || val);
+    },
+  },
+};
+</script>

+ 6 - 7
src/views/wms/incoming/register/materialRegistration.vue

@@ -62,6 +62,7 @@
               ref="purchaseOrder"
               v-model="form.purchaseOrderNo"
               clearable
+              :receipt-type="form.receiptType"
               :disabled="
                 form.receiptType === '4' ||
                 form.receiptType === '2' ||
@@ -354,7 +355,7 @@ import {
   getFilesById,
   getMaterialInfo,
 } from "@/api/wms/incoming/register";
-import OrderSelect from "./components/OrderSelect.vue";
+import OrderSelect from "./components/OrderSelect2.vue";
 import MaterialSelect from "./components/MaterialSelect.vue";
 import PrintTemplate from "./components/PrintTemplate.vue";
 import { printLabel } from "@/api/common";
@@ -641,7 +642,6 @@ export default {
       this.form.receiptQty = total || null;
     },
     /** 删除按钮操作 */
-    /** 删除按钮操作 */
     handleDelete(row, $index) {
       const { id } = row;
       const index = this.list.findIndex((item) => item.id === id);
@@ -841,7 +841,7 @@ export default {
     },
     // 原单单号change事件
     OrderNoChange(item) {
-      if (item) {
+      if (item && typeof item === "object") {
         const { erpOrderNo, id, supplierCode } = item;
         this.form.purchaseOrderNo = erpOrderNo;
         if (supplierCode) {
@@ -852,7 +852,6 @@ export default {
         } else {
           this.$refs.materialOrder.inStockId = id;
         }
-        // this.fetchMaterialNoList(id);
         this.materialDisabled = false;
       }
     },
@@ -903,7 +902,7 @@ export default {
           // 设置源单编号为必填项
           this.$refs.form.rules.purchaseOrderNo[0].required = true;
           // 获取订单号列表
-          this.fetchOrderNoList();
+          // this.fetchOrderNoList();
         }
       } else if (v === "3") {
         // 显示收料单相关字段
@@ -919,7 +918,7 @@ export default {
           // 设置源单编号为必填项
           this.$refs.form.rules.purchaseOrderNo[0].required = true;
           // 获取订单号列表
-          this.fetchOrderNoList2();
+          // this.fetchOrderNoList2();
         }
       }
       // 收料类型为'4'(其他入库)时的处理逻辑
@@ -1020,7 +1019,7 @@ export default {
     supplierChange(item) {
       if (item) {
         const { code } = item;
-        this.fetchOrderNoList(code);
+        // this.fetchOrderNoList(code);
       }
     },
     // 查询子组件源单单号列表

+ 33 - 2
src/views/wms/output/inrequest/components/InRequestForm.vue

@@ -1043,13 +1043,44 @@ export default {
         this.$set(this.formData.list, index, newRow);
       }
     },
+    // 本地过滤
+    // remoteMethod(query) {
+    //   if (query !== "") {
+    //     this.sourceOrderNoList = this.allSourceOrderNoList.filter((item) =>
+    //       item.sourceOrderNo.toLowerCase().includes(query.toLowerCase())
+    //     );
+    //   } else {
+    //     this.sourceOrderNoList = this.allSourceOrderNoList;
+    //   }
+    // },
     remoteMethod(query) {
-      if (query !== "") {
+      if (!query) {
+        // 清空:恢复全部
+        this.sourceOrderNoList = this.allSourceOrderNoList;
+      } else if (query.length <= 4) {
+        // 1-4个字符:本地过滤
         this.sourceOrderNoList = this.allSourceOrderNoList.filter((item) =>
           item.sourceOrderNo.toLowerCase().includes(query.toLowerCase())
         );
       } else {
-        this.sourceOrderNoList = this.allSourceOrderNoList;
+        // 超过4个字符:远程搜索
+        this.loading = true;
+        InRequestApi.getSourceOrder({
+          businessType: this.formData.businessType,
+          businessDescribe: this.selectedBusinessDescribe,
+          businessCategory: this.currentBusinessDescribeRow?.value,
+          sourceOrderNo: query,
+          pageSize: 100,
+        })
+          .then(({ data }) => {
+            this.sourceOrderNoList = data || [];
+          })
+          .catch(() => {
+            this.sourceOrderNoList = [];
+          })
+          .finally(() => {
+            this.loading = false;
+          });
       }
     },
     // 远程搜索调入区域