From 4d29fcfc27c10a09a3ac5aaf52b6cd3407d11ade Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期一, 19 一月 2026 13:55:40 +0800
Subject: [PATCH] 组盘前端添加防抖,首页的优化

---
 项目代码/WIDESEA_WMSClient/src/extension/inbound/extend/Pallet.vue |   80 ++++++++++++---------------------------
 1 files changed, 25 insertions(+), 55 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/Pallet.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/Pallet.vue"
index 39cbe94..e7a1b57 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/Pallet.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/Pallet.vue"
@@ -203,6 +203,8 @@
       scanTimer: null,
       manualInputTimer: null,
       scanTarget: 'tray', // 褰撳墠鎵爜鐩爣: tray 鎴� material
+      isSubmitting: false, // 鏂板锛氭彁浜ら攣瀹氾紝闃叉閲嶅璇锋眰
+      groupedBarcodes: [],
 
       // 搴撳瓨缁熻鐩稿叧鍙橀噺
       totalStockSum: 0,
@@ -266,7 +268,6 @@
         this.resetData();
         this.$nextTick(() => {
           setTimeout(() => {
-            this.fetchStockStatistics(); // 鍔犺浇缁熻鏁版嵁
             this.fetchUnpalletMaterialDetails();
           }, 300);
         });
@@ -286,18 +287,12 @@
         this.palletForm = { palletCode: '', barcode: '' };
         this.backData = [];
         this.$refs.palletForm?.reset();
-        this.fetchStockStatistics(); // 鍗曟嵁鍙峰彉浜嗭紝鍒锋柊缁熻
         this.fetchUnpalletMaterialDetails();
       }
     }
   },
   mounted() {
-
     document.addEventListener('keypress', this.handleKeyPress);
-
-    setTimeout(() => {
-      this.focusLocationSelect();
-    }, 300);
   },
   beforeDestroy() {
     document.removeEventListener('keypress', this.handleKeyPress);
@@ -306,9 +301,10 @@
   methods: {
     open() {
       this.show = true;
+      this.orderNo = "";
+      this.resetData();
       this.initLocationTypes();
       this.initwarehouseTypes();
-      this.fetchStockStatistics();
       this.fetchUnpalletMaterialDetails();
     },
     validateLocationType(rule, value, callback) {
@@ -324,7 +320,7 @@
     // 鏍规嵁鏉$爜鍒楄〃鑾峰彇璇︾粏鏁版嵁
     async fetchUnpalletMaterialDetails() {
       try {
-        const response = await http.post('/api/InboundOrder/UnPalletGroupBarcode?orderNo=' + this.docNo, {});
+        const response = await http.post('/api/InboundOrder/UnPalletGroupBarcode?orderNo=' + this.orderNo, {});
         if (response.status && Array.isArray(response.data)) {
           this.unpalletMaterials = response.data;
           this.unpalletBarcodes = response.data.map(item => item.barcode || '');
@@ -361,9 +357,9 @@
       }
     },
 
-    async fetchStockStatistics() {
+    async fetchStockStatistics(orderNo) {
       // 鍗曟嵁鍙蜂负绌烘椂涓嶆煡璇�
-      if (!this.docNo) {
+      if (!orderNo) {
         this.sumError = '鍗曟嵁鍙蜂负绌猴紝鏃犳硶缁熻';
         return;
       }
@@ -371,7 +367,7 @@
       this.sumLoading = true;
       this.sumError = '';
       try {
-        const response = await http.post('/api/InboundOrder/UnPalletQuantity?orderNo=' + this.docNo, {});
+        const response = await http.post('/api/InboundOrder/UnPalletQuantity?orderNo=' + orderNo, {});
         if (response.data) {
           this.totalStockSum = response.data.stockSumQuantity || 0;
           this.totalStockCount = response.data.stockCount || 0;
@@ -440,7 +436,8 @@
     },
     // 閲嶇疆鎵�鏈夋暟鎹�
     resetData() {
-      console.log('閲嶇疆寮规鏁版嵁');
+      this.groupedBarcodes = []; // 娓呯┖宸茬粍鐩樻潯鐮�
+      this.isSubmitting = false; // 閲嶇疆鎻愪氦閿�
       this.trayBarcode = '';
       this.barcode = '';
       this.materials = [];
@@ -626,6 +623,10 @@
 
     // 澶勭悊鐗╂枡鏉$爜鎻愪氦
     async handleBarcodeSubmit() {
+      if (this.isSubmitting) {
+    this.$message.warning('姝e湪澶勭悊涓紝璇风◢鍊�');
+    return;
+  }
       if (!await this.validateForm()) return;
       const currentBarcode = this.barcode.trim();
 
@@ -643,8 +644,8 @@
       this.focusBarcodeInput();
       this.error = '';
       this.loading = true;
+      this.isSubmitting = true; // 寮�鍚彁浜ら攣
 
-      console.log(currentBarcode);
       try {
         // 璋冪敤API鏌ヨ鐗╂枡淇℃伅
         const materialData = await this.fetchMaterialData(currentBarcode);
@@ -653,6 +654,7 @@
         }
 
         this.materials = [];
+        const newBarcodes = []; // 涓存椂瀛樺偍鏈鏂板鐨勬潯鐮�
         materialData.forEach(item => {
           this.materials.push({
             ...item,
@@ -661,10 +663,14 @@
             locationDesc: this.currentLocationDesc,
             scanTime: this.formatTime(new Date())
           });
+          newBarcodes.push(item.barcode); // 鏀堕泦鏈缁勭洏鐨勬潯鐮�
         });
-        this.orderNo = materialData[0].orderNo;
+         // 灏嗘湰娆$粍鐩樼殑鏉$爜鍔犲叆宸茬粍鐩樺垪琛�
+        this.groupedBarcodes = [...new Set([...this.groupedBarcodes, ...newBarcodes])];
 
-        this.fetchStockStatistics();
+        this.orderNo = materialData[0].orderNo;
+        await this.fetchStockStatistics(materialData[0].orderNo);
+        await this.fetchUnpalletMaterialDetails();
         // 娓呯┖鐗╂枡杈撳叆妗嗗苟淇濇寔鑱氱劍
         this.barcode = '';
         this.scanCode = ''; // 娓呯┖鎵爜缂撳瓨
@@ -683,6 +689,7 @@
         }, 100);
       } finally {
         this.loading = false;
+        this.isSubmitting = false; // 鍏抽棴鎻愪氦閿�
       }
     },
 
@@ -724,7 +731,7 @@
     // 澶勭悊鎵爜鏋緭鍏�
     handleKeyPress(event) {
       // 濡傛灉鏄墜鍔ㄨ緭鍏ユā寮忥紝涓嶅鐞嗘壂鐮佹灙閫昏緫
-      if (this.isManualInput) {
+      if (this.isManualInput || this.isSubmitting) {
         return;
       }
 
@@ -733,6 +740,7 @@
 
       // 蹇界暐鐩存帴鎸変笅鐨勫洖杞﹂敭锛堢敱handleBarcodeSubmit澶勭悊锛�
       if (key === 'Enter') {
+        event.preventDefault(); // 寮哄埗闃绘榛樿琛屼负锛岄伩鍏嶉噸澶嶈Е鍙�
         if (this.scanCode.length > 0) {
           // 闃绘榛樿鍥炶溅琛屼负锛岄伩鍏嶈〃鍗曟彁浜�
           event.preventDefault();
@@ -772,44 +780,6 @@
       }, 100);
 
       this.lastKeyTime = currentTime;
-    },
-
-    // 鍒犻櫎鐗╂枡
-    removeMaterial(index) {
-      this.$confirm('纭畾瑕佸垹闄よ繖鏉$墿鏂欒褰曞悧?', '鎻愮ず', {
-        confirmButtonText: '纭畾',
-        cancelButtonText: '鍙栨秷',
-        type: 'warning'
-      }).then(() => {
-        this.materials.splice(index, 1);
-        this.$message({
-          type: 'success',
-          message: '鍒犻櫎鎴愬姛!'
-        });
-        this.fetchStockStatistics();
-
-      }).catch(() => {
-        // 鍙栨秷鍒犻櫎
-      });
-    },
-
-    // 娓呯┖鎵�鏈夌墿鏂�
-    clearAllMaterials() {
-      if (this.materials.length === 0) return;
-
-      this.$confirm('纭畾瑕佹竻绌烘墍鏈夌墿鏂欒褰曞悧?', '鎻愮ず', {
-        confirmButtonText: '纭畾',
-        cancelButtonText: '鍙栨秷',
-        type: 'warning'
-      }).then(() => {
-        this.materials = [];
-        this.$message({
-          type: 'success',
-          message: '宸叉竻绌烘墍鏈夎褰�!'
-        });
-      }).catch(() => {
-        // 鍙栨秷娓呯┖
-      });
     },
 
     // 鏍煎紡鍖栨椂闂�

--
Gitblit v1.9.3