From deb12fd2b06ccc821104aa475a8fb784c39dfb2c Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期一, 02 二月 2026 19:01:00 +0800
Subject: [PATCH] 添加音频播放和优化调拨明细查询方法

---
 项目代码/WIDESEA_WMSClient/src/extension/inbound/extend/Pallet.vue |   88 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 88 insertions(+), 0 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 5c9a1b6..2630979 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"
@@ -218,6 +218,15 @@
       isSubmitting: false,
       palletGroupedBarcodes: {},
 
+      // 闊抽閰嶇疆
+      audioConfig: {
+        successPath: '/assets/audio/success.mp3', // 瀵瑰簲 public 涓嬬殑璺緞
+        errorPath: '/assets/audio/error.mp3'
+     },
+      // 缂撳瓨闊抽瀹炰緥锛岄伩鍏嶉噸澶嶅垱寤�
+      successAudio: null,
+      errorAudio: null,
+
       totalStockSum: 0,
       totalStockCount: 0,
       uniqueUnit: '',
@@ -337,9 +346,84 @@
     // 纭繚缁勪欢閿�姣佹椂绉婚櫎鐩戝惉
     this.removeKeyPressListener();
     this.clearAllTimers();
+
+     this.removeKeyPressListener();
+     this.clearAllTimers();
+  
+   //閿�姣侀煶棰戝疄渚�
+    this.successAudio = null;
+    this.errorAudio = null;
   },
   
   methods: {
+
+    /**
+   * 鍒濆鍖栭煶棰戝疄渚嬶紙鎳掑姞杞斤紝鍙垱寤轰竴娆★級
+   * @param {String} type - 闊抽绫诲瀷锛歴uccess/error
+   * @returns {Audio} 闊抽瀹炰緥
+   */
+  initAudioInstance(type) {
+    if (type === 'success' && this.successAudio) {
+      return this.successAudio;
+    }
+    if (type === 'error' && this.errorAudio) {
+      return this.errorAudio;
+    }
+    
+    const audioPath = type === 'success' 
+      ? this.audioConfig.successPath 
+      : this.audioConfig.errorPath;
+    
+    const audioInstance = new Audio(audioPath);
+    
+    // 缂撳瓨闊抽瀹炰緥
+    if (type === 'success') {
+      this.successAudio = audioInstance;
+    } else {
+      this.errorAudio = audioInstance;
+    }
+    
+    // 闊抽鍔犺浇澶辫触鍥炶皟锛堝彲閫夛紝鐢ㄤ簬璋冭瘯锛�
+    audioInstance.onerror = (err) => {
+      console.error(`銆�${type} 闊抽銆戝姞杞藉け璐, err);
+    };
+    
+    return audioInstance;
+  },
+  
+  /**
+   * 鎾斁闊抽
+   * @param {String} type - 闊抽绫诲瀷锛歴uccess/error
+   */
+  playAudio(type) {
+    try {
+      const audioInstance = this.initAudioInstance(type);
+      
+      // 閲嶇疆鎾斁杩涘害锛堥伩鍏嶉噸澶嶆挱鏀炬椂闊抽鏈粨鏉燂級
+      audioInstance.currentTime = 0;
+      
+      // 鎾斁闊抽锛堣繑鍥� Promise 澶勭悊鎾斁缁撴灉锛屽吋瀹归儴鍒嗘祻瑙堝櫒闄愬埗锛�
+      audioInstance.play().catch((err) => {
+        console.warn('闊抽鎾斁澶辫触锛堝彲鑳芥槸娴忚鍣ㄨ嚜鍔ㄦ挱鏀剧瓥鐣ラ檺鍒讹級', err);
+      });
+    } catch (err) {
+      console.error('鎾斁闊抽鏃跺彂鐢熷紓甯�', err);
+    }
+  },
+  
+  /**
+   * 鎾斁鎴愬姛闊抽
+   */
+  playSuccessAudio() {
+    this.playAudio('success');
+  },
+  
+  /**
+   * 鎾斁澶辫触闊抽
+   */
+  playErrorAudio() {
+    this.playAudio('error');
+  },
     // 娣诲姞閿洏浜嬩欢鐩戝惉
     addKeyPressListener() {
       if (!this.keyPressListenerAdded) {
@@ -717,6 +801,7 @@
         this.error = `鏉$爜 ${currentBarcode} 宸茶褰撳墠鎵樼洏缁勭洏锛岃鍕块噸澶嶆搷浣渀;
         this.barcode = '';
         this.focusBarcodeInput();
+        this.playErrorAudio();
         return;
       }
 
@@ -726,6 +811,7 @@
         .then(valid => {
           if (!valid) {
             this.isSubmitting = false;
+            this.playErrorAudio();
             return;
           }
           
@@ -792,6 +878,8 @@
           this.scanCode = '';
           this.isScanning = false;
 
+          this.playSuccessAudio();
+
           setTimeout(() => {
             this.focusBarcodeInput();
           }, 100);

--
Gitblit v1.9.3