Browse Source

修改即时库存

chensibo 1 week ago
parent
commit
ac0c0d6eb4

+ 43 - 28
src/views/wms/incoming/wareHousing/components/AreaSelect.vue

@@ -3,7 +3,10 @@
     v-model="selected"
     v-bind="$attrs"
     :loading="loading"
+    remote
+    :remote-method="remoteMethod"
     @change="change"
+    @visible-change="handleVisible"
   >
     <el-option
       v-for="item in options"
@@ -12,58 +15,70 @@
       :value="item.id"
     />
   </el-select>
-
 </template>
 
 <script>
-import { getStockAreaPage } from '@/api/wms/base/stockArea'
+import { getStockAreaPage } from "@/api/wms/base/stockArea";
 
 export default {
   props: {
     value: {
       type: [String, Number],
-      default: ''
-    }
+      default: "",
+    },
   },
   data() {
     return {
       options: [],
-      loading: false
-    }
+      loading: false,
+      wmsStockId: null,
+    };
   },
   computed: {
     selected: {
       get() {
-        return this.value
+        return this.value;
       },
       set(v) {
-        this.$emit('input', v)
-      }
-    }
+        this.$emit("input", v);
+      },
+    },
   },
   methods: {
-    fetchAreaList(wmsStockId) {
-      this.loading = true
+    fetchAreaList(wmsStockId, name) {
+      this.loading = true;
+      if (wmsStockId !== undefined) {
+        this.wmsStockId = wmsStockId;
+      }
       const params = {
         pageNo: 1,
-        pageSize: 100,
-        wmsStockId
+        pageSize: 10,
+        wmsStockId: this.wmsStockId,
+        name,
+      };
+      getStockAreaPage(params)
+        .then((res) => {
+          const { list = [] } = res.data || {};
+          this.options = list;
+        })
+        .finally(() => {
+          this.loading = false;
+        });
+    },
+    remoteMethod(query) {
+      this.fetchAreaList(undefined, query);
+    },
+    handleVisible(visible) {
+      if (visible) {
+        this.fetchAreaList();
       }
-      getStockAreaPage(params).then(res => {
-        const { list = [] } = res.data || {}
-        this.options = list
-      }).finally(() => {
-        this.loading = false
-      })
     },
     change(v) {
-      const item = this.options.find(i => i.id === v)
-      this.$emit('change', item)
-    }
-  }
-}
+      const item = this.options.find((i) => i.id === v);
+      this.$emit("change", item);
+    },
+  },
+};
 </script>
 
-  <style>
-  </style>
-
+<style></style>

+ 46 - 29
src/views/wms/incoming/wareHousing/components/LocationSelect.vue

@@ -3,7 +3,10 @@
     v-model="selected"
     v-bind="$attrs"
     :loading="loading"
+    remote
+    :remote-method="remoteMethod"
     @change="change"
+    @visible-change="handleVisible"
   >
     <el-option
       v-for="item in options"
@@ -13,62 +16,76 @@
     >
       <el-row :gutter="20">
         <el-col :span="12">{{ item.name }}</el-col>
-        <el-col :span="12" class="text-right">{{ item.remainderStorageQty }}</el-col>
+        <el-col :span="12" class="text-right">{{
+          item.remainderStorageQty
+        }}</el-col>
       </el-row>
     </el-option>
   </el-select>
-
 </template>
 
 <script>
-import { getStockLocationPage } from '@/api/wms/base/stockLocation'
+import { getStockLocationPage } from "@/api/wms/base/stockLocation";
 
 export default {
   props: {
     value: {
       type: [String, Number],
-      default: ''
-    }
+      default: "",
+    },
   },
   data() {
     return {
       options: [],
-      loading: false
-    }
+      loading: false,
+      wmsStockAreaId: null,
+    };
   },
   computed: {
     selected: {
       get() {
-        return this.value
+        return this.value;
       },
       set(v) {
-        this.$emit('input', v)
-      }
-    }
+        this.$emit("input", v);
+      },
+    },
   },
   methods: {
-    fetchLocationList(wmsStockAreaId) {
-      this.loading = true
+    fetchLocationList(wmsStockAreaId, name) {
+      this.loading = true;
+      if (wmsStockAreaId !== undefined) {
+        this.wmsStockAreaId = wmsStockAreaId;
+      }
       const params = {
         pageNo: 1,
-        pageSize: 100,
-        wmsStockAreaId
+        pageSize: 10,
+        wmsStockAreaId: this.wmsStockAreaId,
+        name,
+      };
+      getStockLocationPage(params)
+        .then((res) => {
+          const { list = [] } = res.data || {};
+          this.options = list;
+        })
+        .finally(() => {
+          this.loading = false;
+        });
+    },
+    remoteMethod(query) {
+      this.fetchLocationList(undefined, query);
+    },
+    handleVisible(visible) {
+      if (visible) {
+        this.fetchLocationList();
       }
-      getStockLocationPage(params).then(res => {
-        const { list = [] } = res.data || {}
-        this.options = list
-      }).finally(() => {
-        this.loading = false
-      })
     },
     change(v) {
-      const item = this.options.find(i => i.id === v)
-      this.$emit('change', item)
-    }
-  }
-}
+      const item = this.options.find((i) => i.id === v);
+      this.$emit("change", item);
+    },
+  },
+};
 </script>
 
-    <style>
-    </style>
-
+<style></style>

+ 8 - 2
src/views/wms/incoming/wareHousing/components/StockSelect.vue

@@ -3,6 +3,8 @@
     v-model="selected"
     v-bind="$attrs"
     :loading="loading"
+    remote
+    :remote-method="remoteMethod"
     @change="change"
     @visible-change="handleVisible"
   >
@@ -42,11 +44,12 @@ export default {
     },
   },
   methods: {
-    fetchStockList() {
+    fetchStockList(name) {
       this.loading = true;
       const params = {
         pageNo: 1,
-        pageSize: 100,
+        pageSize: 10,
+        name,
       };
       getStockPage(params)
         .then((res) => {
@@ -57,6 +60,9 @@ export default {
           this.loading = false;
         });
     },
+    remoteMethod(query) {
+      this.fetchStockList(query);
+    },
     handleVisible(visible) {
       if (visible) {
         this.fetchStockList();