From 4957423e351c8007d94a0cba66718c4ebd84a777 Mon Sep 17 00:00:00 2001
From: chen.llin <1442464845@qq.comm>
Date: 星期三, 14 一月 2026 20:12:19 +0800
Subject: [PATCH] rfid-3版

---
 pages/stock/stockQuery.vue  |    8 ++
 pages/AGV/agv_start.vue     |    1 
 pages/order/orderPakin2.vue |   21 +++++
 common/rfid-input-helper.js |  135 +++++++++++++++++++++++++++------
 pages/pakin/pakin.vue       |   22 ++++
 5 files changed, 156 insertions(+), 31 deletions(-)

diff --git a/common/rfid-input-helper.js b/common/rfid-input-helper.js
index 48095c8..3dc0c07 100644
--- a/common/rfid-input-helper.js
+++ b/common/rfid-input-helper.js
@@ -68,6 +68,63 @@
 }
 
 /**
+ * 鎾斁鎻愮ず闊�
+ * @param {String} type - 鎻愮ず闊崇被鍨嬶細'success'=鎴愬姛锛堟淮1澹帮級锛�'error'=閿欒锛堟淮2澹帮級锛�'warning'=璀﹀憡锛堟淮3澹帮級锛�'short'=鐭績锛堝揩閫熸淮1澹帮級
+ */
+function playBeepSound(type = 'success') {
+	// #ifdef APP-PLUS
+	try {
+		// 浣跨敤璁惧铚傞福鍣ㄦ挱鏀炬彁绀洪煶
+		if (typeof plus !== 'undefined' && plus.device && plus.device.beep) {
+			let beepCount = 1; // 榛樿鎾斁1娆�
+			
+			// 鏍规嵁绫诲瀷璁剧疆涓嶅悓鐨勬彁绀洪煶
+			switch(type) {
+				case 'success':
+					beepCount = 1; // 鎴愬姛锛氭淮1澹�
+					break;
+				case 'error':
+					beepCount = 2; // 閿欒锛氭淮2澹�
+					break;
+				case 'warning':
+					beepCount = 3; // 璀﹀憡锛氭淮3澹�
+					break;
+				case 'short':
+					beepCount = 1; // 鐭績锛氬揩閫熸淮1澹�
+					break;
+				default:
+					beepCount = 1;
+			}
+			
+			plus.device.beep(beepCount); // 鎾斁鎸囧畾娆℃暟
+			
+			// 濡傛灉鏄敊璇垨璀﹀憡锛屽彲浠ユ坊鍔犻渿鍔ㄥ弽棣�
+			if (type === 'error' || type === 'warning') {
+				if (typeof plus !== 'undefined' && plus.device && plus.device.vibrate) {
+					setTimeout(() => {
+						plus.device.vibrate(200); // 闇囧姩200ms
+					}, 100);
+				}
+			}
+		} else {
+			// 濡傛灉璁惧涓嶆敮鎸乥eep锛屽皾璇曚娇鐢╲ibrate锛堥渿鍔級浣滀负鏇夸唬
+			if (typeof plus !== 'undefined' && plus.device && plus.device.vibrate) {
+				let vibrateDuration = 100; // 榛樿闇囧姩100ms
+				if (type === 'error') {
+					vibrateDuration = 300; // 閿欒锛氶渿鍔�300ms
+				} else if (type === 'warning') {
+					vibrateDuration = 200; // 璀﹀憡锛氶渿鍔�200ms
+				}
+				plus.device.vibrate(vibrateDuration);
+			}
+		}
+	} catch (error) {
+		console.warn('[RFIDInputHelper] 鎾斁鎻愮ず闊冲け璐�:', error);
+	}
+	// #endif
+}
+
+/**
  * 璇诲彇RFID鏍囩锛堝崟鏍囩璇伙紝鏃犺繃婊わ級
  */
 function readRFIDTag() {
@@ -150,6 +207,8 @@
 				}
 				
 				console.log('[RFIDInputHelper] 鉁� 璇诲彇鍒版爣绛綞PC (闀垮害' + epc.length + '浣�):', epc);
+				// 鎾斁鎻愮ず闊筹紙婊翠竴澹帮級
+				// playBeepSound(); // 宸叉敞閲婏紝鍚庣画鑷繁鍐冲畾鏄惁鍚敤
 				// 鑷姩濉叆褰撳墠鐒︾偣杈撳叆妗嗭紙涓嶈拷鍔狅紝浣跨敤瀹為檯闀垮害锛�
 				fillCurrentInput(epc);
 				modal.toast({
@@ -176,6 +235,8 @@
 						if (originalLength !== hexOnly.length) {
 							console.log('[RFIDInputHelper] 鍘婚櫎鍓嶅0: 鍘熷闀垮害=' + originalLength + ', 鍘婚櫎鍚庨暱搴�=' + hexOnly.length);
 						}
+						// 鎾斁鎻愮ず闊筹紙婊翠竴澹帮級
+						// playBeepSound(); // 宸叉敞閲婏紝鍚庣画鑷繁鍐冲畾鏄惁鍚敤
 						fillCurrentInput(hexOnly); // 浣跨敤瀹為檯闀垮害锛屼笉杩藉姞
 						modal.toast({
 							message: '宸茶鍙栨爣绛�',
@@ -219,6 +280,8 @@
 					}
 					
 					console.log('[RFIDInputHelper] 鉁� 璇诲彇鍒版爣绛綞PC (闀垮害' + epc.length + '浣�):', epc);
+					// 鎾斁鎻愮ず闊筹紙婊翠竴澹帮級
+					// playBeepSound(); // 宸叉敞閲婏紝鍚庣画鑷繁鍐冲畾鏄惁鍚敤
 					fillCurrentInput(epc); // 浣跨敤瀹為檯闀垮害锛屼笉杩藉姞
 					modal.toast({
 						message: '宸茶鍙栨爣绛�',
@@ -269,20 +332,52 @@
 		const vm = currentPage.$vm;
 		console.log('[RFIDInputHelper] 褰撳墠椤甸潰:', currentPage.route);
 		
-		// 瀹氫箟杈撳叆妗嗗瓧娈靛拰瀵瑰簲鐨勭劍鐐圭姸鎬佸瓧娈�
+		// 瀹氫箟杈撳叆妗嗗瓧娈靛拰瀵瑰簲鐨勭劍鐐圭姸鎬佸瓧娈碉紙棰勫畾涔夌殑甯歌瀛楁锛�
 		// 鏍煎紡锛歿 瀛楁鍚�: 鐒︾偣鐘舵�佸瓧娈靛悕 }
-		const inputFieldMap = [
+		const predefinedFieldMap = [
 			{ field: 'barcode', focusField: 'barcodeFocus' },
 			{ field: 'matnr', focusField: 'matFocus' },
 			{ field: 'sourceSite', focusField: 'sourceSiteFocus' },
 			{ field: 'orderNo', focusField: 'orderNoFocus' },
 			{ field: 'targetSite', focusField: 'targetSiteFocus' },
-			{ field: 'locNo', focusField: 'locNoFocus' }
+			{ field: 'locNo', focusField: 'locNoFocus' },
+			{ field: 'batch', focusField: 'batchFocus' },
+			{ field: 'userName', focusField: 'userNameFocus' },
+			{ field: 'password', focusField: 'passwordFocus' }
 		];
+		
+		// 鑷姩妫�娴嬫墍鏈夊彲鑳界殑杈撳叆妗嗗瓧娈碉紙浠巚m.$data涓煡鎵炬墍鏈夊瓧绗︿覆绫诲瀷鐨勫睘鎬э級
+		const autoDetectedFields = [];
+		if (vm.$data) {
+			for (let key in vm.$data) {
+				// 璺宠繃浠�$寮�澶寸殑Vue鍐呴儴灞炴�э紝璺宠繃鍑芥暟锛岃烦杩噁ocus瀛楁鏈韩
+				if (key.startsWith('$') || typeof vm.$data[key] === 'function' || key.endsWith('Focus')) {
+					continue;
+				}
+				// 濡傛灉鏄瓧绗︿覆绫诲瀷锛岃涓烘槸鍙兘鐨勮緭鍏ユ瀛楁
+				if (typeof vm.$data[key] === 'string' || vm.$data[key] === null || vm.$data[key] === undefined) {
+					// 妫�鏌ユ槸鍚︽湁瀵瑰簲鐨刦ocusField锛堝瓧娈靛悕 + Focus锛�
+					const focusFieldName = key + 'Focus';
+					if (vm.$data[focusFieldName] !== undefined) {
+						autoDetectedFields.push({ field: key, focusField: focusFieldName });
+					}
+				}
+			}
+		}
+		
+		// 鍚堝苟棰勫畾涔夊瓧娈靛拰鑷姩妫�娴嬬殑瀛楁锛堝幓閲嶏級
+		const allFieldsMap = [...predefinedFieldMap];
+		for (let autoField of autoDetectedFields) {
+			// 妫�鏌ユ槸鍚﹀凡瀛樺湪
+			const exists = allFieldsMap.some(item => item.field === autoField.field);
+			if (!exists) {
+				allFieldsMap.push(autoField);
+			}
+		}
 		
 		// 璋冭瘯锛氭墦鍗版墍鏈夎緭鍏ユ鐨勭劍鐐圭姸鎬�
 		console.log('[RFIDInputHelper] ========== 妫�鏌ヨ緭鍏ユ鐒︾偣鐘舵�� ==========');
-		for (let item of inputFieldMap) {
+		for (let item of allFieldsMap) {
 			if (vm[item.field] !== undefined) {
 				const focusValue = vm[item.focusField];
 				console.log(`[RFIDInputHelper]   ${item.field}: focus=${focusValue}, value="${vm[item.field]}"`);
@@ -291,7 +386,7 @@
 		
 		// 鍙煡鎵炬湁鐒︾偣鐨勮緭鍏ユ锛堝厜鏍囨墍鍦ㄧ殑杈撳叆妗嗭級
 		let focusedField = null;
-		for (let item of inputFieldMap) {
+		for (let item of allFieldsMap) {
 			if (vm[item.field] !== undefined) {
 				// 妫�鏌ユ槸鍚︽湁鐒︾偣鐘舵�佸瓧娈碉紝骞朵笖鐒︾偣涓簍rue
 				const focusValue = vm[item.focusField];
@@ -307,31 +402,17 @@
 		// 鍙~鍏ユ湁鐒︾偣鐨勮緭鍏ユ锛屽鏋滄病鏈夌劍鐐瑰垯涓嶅~鍏�
 		if (focusedField) {
 			console.log(`[RFIDInputHelper] 濉叆鏈夌劍鐐圭殑杈撳叆妗� ${focusedField}:`, epc);
-			console.log(`[RFIDInputHelper] 杈撳叆妗嗗綋鍓嶅��: "${vm[focusedField]}"`);
-			
-			// 鍏堟竻绌鸿緭鍏ユ锛屽啀濉叆鏂板�硷紙閬垮厤杩藉姞锛�
-			vm[focusedField] = '';
-			
-			// 浣跨敤 $nextTick 纭繚娓呯┖鎿嶄綔瀹屾垚鍚庡啀濉叆鏂板��
+			vm[focusedField] = epc;
+			// 瑙﹀彂input浜嬩欢锛岀‘淇濋〉闈㈤�昏緫鑳藉搷搴�
 			if (vm.$nextTick) {
 				vm.$nextTick(() => {
-					// 濉叆鏂扮殑EPC鍊硷紙鏇挎崲锛屼笉杩藉姞锛�
-					vm[focusedField] = epc;
-					console.log(`[RFIDInputHelper] 鉁� 宸叉浛鎹㈣緭鍏ユ鍊间负: "${vm[focusedField]}"`);
-					
-					// 鍐嶆浣跨敤 $nextTick 纭繚鍊煎凡璁剧疆锛屽啀瑙﹀彂input浜嬩欢
-					vm.$nextTick(() => {
-						// 濡傛灉椤甸潰鏈夊搴旂殑input澶勭悊鏂规硶锛屽彲浠ユ墜鍔ㄨЕ鍙�
-						if (focusedField === 'barcode' && typeof vm.barcodeInput === 'function') {
-							vm.barcodeInput();
-						} else if (focusedField === 'matnr' && typeof vm.findMat === 'function') {
-							vm.findMat();
-						}
-					});
+					// 濡傛灉椤甸潰鏈夊搴旂殑input澶勭悊鏂规硶锛屽彲浠ユ墜鍔ㄨЕ鍙�
+					if (focusedField === 'barcode' && typeof vm.barcodeInput === 'function') {
+						vm.barcodeInput();
+					} else if (focusedField === 'matnr' && typeof vm.findMat === 'function') {
+						vm.findMat();
+					}
 				});
-			} else {
-				// 濡傛灉娌℃湁 $nextTick锛岀洿鎺ヨ缃�
-				vm[focusedField] = epc;
 			}
 		} else {
 			console.warn('[RFIDInputHelper] 鉁� 鏈壘鍒版湁鐒︾偣鐨勮緭鍏ユ锛屼笉濉叆浠讳綍杈撳叆妗�');
diff --git a/pages/AGV/agv_start.vue b/pages/AGV/agv_start.vue
index e0ba9c0..69e6d12 100644
--- a/pages/AGV/agv_start.vue
+++ b/pages/AGV/agv_start.vue
@@ -203,6 +203,7 @@
 				content: '',
 				barcodeFocus: true,
 				matFocus: false,
+				sourceSiteFocus: false,
 				matData: '',
 				removeNum: 0,
 				ck1: true,
diff --git a/pages/order/orderPakin2.vue b/pages/order/orderPakin2.vue
index 501ee3e..89024df 100644
--- a/pages/order/orderPakin2.vue
+++ b/pages/order/orderPakin2.vue
@@ -144,7 +144,7 @@
 					</view>
 					<view class="popup-row">
 						<text class="popup-label">鎵瑰彿</text>
-						<input class="popup-value input" type="text" v-model="batch" placeholder="杈撳叆鎵瑰彿" />
+						<input class="popup-value input" type="text" v-model="batch" placeholder="杈撳叆鎵瑰彿" @focus="onBatchFocus()" @blur="onBatchBlur()" />
 					</view>
 					<view class="popup-row">
 						<text class="popup-label">鏁伴噺</text>
@@ -208,6 +208,7 @@
 				orderNoFocus: false,
 				barcodeFocus: true,
 				matFocus: false,
+				batchFocus: false,
 				matData: '',
 				removeNum: 0,
 				isDisabled: false
@@ -243,6 +244,7 @@
 				// 璁剧疆鎵樼洏鐮佽緭鍏ユ涓虹劍鐐癸紝鍏朵粬杈撳叆妗嗗け鍘荤劍鐐�
 				this.barcodeFocus = true;
 				this.matFocus = false;
+				this.batchFocus = false;
 				if (this.orderNoFocus !== undefined) {
 					this.orderNoFocus = false;
 				}
@@ -254,11 +256,28 @@
 				// 璁剧疆鐗╂枡鐮佽緭鍏ユ涓虹劍鐐癸紝鍏朵粬杈撳叆妗嗗け鍘荤劍鐐�
 				this.matFocus = true;
 				this.barcodeFocus = false;
+				this.batchFocus = false;
 				if (this.orderNoFocus !== undefined) {
 					this.orderNoFocus = false;
 				}
 				// 娉ㄦ剰锛氬崟鏍囩璇绘棤杩囨护鍔熻兘宸叉敼涓烘寜閿Е鍙戯紙191銆�189銆�190锛夛紝涓嶅啀鍦ㄧ劍鐐规椂鑷姩瑙﹀彂
 			},
+			// 鎵瑰彿杈撳叆妗嗚幏寰楃劍鐐�
+			onBatchFocus() {
+				console.log('[orderPakin2] 鎵瑰彿杈撳叆妗嗚幏寰楃劍鐐�');
+				// 璁剧疆鎵瑰彿杈撳叆妗嗕负鐒︾偣锛屽叾浠栬緭鍏ユ澶卞幓鐒︾偣
+				this.batchFocus = true;
+				this.barcodeFocus = false;
+				this.matFocus = false;
+				if (this.orderNoFocus !== undefined) {
+					this.orderNoFocus = false;
+				}
+			},
+			// 鎵瑰彿杈撳叆妗嗗け鍘荤劍鐐�
+			onBatchBlur() {
+				console.log('[orderPakin2] 鎵瑰彿杈撳叆妗嗗け鍘荤劍鐐�');
+				this.batchFocus = false;
+			},
 			messageToggle(type) {
 				this.msgType1 = type;
 				this.$refs.message.open();
diff --git a/pages/pakin/pakin.vue b/pages/pakin/pakin.vue
index cf1df7c..ef7264a 100644
--- a/pages/pakin/pakin.vue
+++ b/pages/pakin/pakin.vue
@@ -126,7 +126,7 @@
 					</view>
 					<view class="popup-row">
 						<text class="popup-label">鎵瑰彿</text>
-						<input class="popup-value input" type="text" v-model="batch" placeholder="杈撳叆鎵瑰彿" />
+						<input class="popup-value input" type="text" v-model="batch" placeholder="杈撳叆鎵瑰彿" @focus="onBatchFocus()" @blur="onBatchBlur()" />
 					</view>
 					<view class="popup-row">
 						<text class="popup-label">鏁伴噺</text>
@@ -190,6 +190,7 @@
 				content: '',
 				barcodeFocus: true,
 				matFocus: false,
+				batchFocus: false,
 				matData: '',
 				removeNum: 0,
 				ck1: true,
@@ -218,9 +219,10 @@
 			// 鎵樼洏鐮佽緭鍏ユ鑾峰緱鐒︾偣锛堜繚鐣欐柟娉曪紝浣嗕笉鑷姩瑙﹀彂鎵弿锛�
 			onBarcodeFocus() {
 				console.log('[pakin] 鎵樼洏鐮佽緭鍏ユ鑾峰緱鐒︾偣');
-				// 璁剧疆鎵樼洏鐮佽緭鍏ユ涓虹劍鐐癸紝鐗╂枡鐮佸け鍘荤劍鐐�
+				// 璁剧疆鎵樼洏鐮佽緭鍏ユ涓虹劍鐐癸紝鐗╂枡鐮佸拰鎵瑰彿澶卞幓鐒︾偣
 				this.barcodeFocus = true;
 				this.matFocus = false;
+				this.batchFocus = false;
 				// 娉ㄦ剰锛氬崟鏍囩璇绘棤杩囨护鍔熻兘宸叉敼涓烘寜閿Е鍙戯紙191銆�189銆�190锛夛紝涓嶅啀鍦ㄧ劍鐐规椂鑷姩瑙﹀彂
 			},
 			// 鎵樼洏鐮佽緭鍏ユ澶卞幓鐒︾偣鏃跺仠姝FID鎵弿锛堝彲閫夛級
@@ -235,11 +237,25 @@
 			// 鐗╂枡鐮佽緭鍏ユ鑾峰緱鐒︾偣锛堜繚鐣欐柟娉曪紝浣嗕笉鑷姩瑙﹀彂鎵弿锛�
 			onMatnrFocus() {
 				console.log('[pakin] 鐗╂枡鐮佽緭鍏ユ鑾峰緱鐒︾偣');
-				// 璁剧疆鐗╂枡鐮佽緭鍏ユ涓虹劍鐐癸紝鎵樼洏鐮佸け鍘荤劍鐐�
+				// 璁剧疆鐗╂枡鐮佽緭鍏ユ涓虹劍鐐癸紝鎵樼洏鐮佸拰鎵瑰彿澶卞幓鐒︾偣
 				this.matFocus = true;
 				this.barcodeFocus = false;
+				this.batchFocus = false;
 				// 娉ㄦ剰锛氬崟鏍囩璇绘棤杩囨护鍔熻兘宸叉敼涓烘寜閿Е鍙戯紙191銆�189銆�190锛夛紝涓嶅啀鍦ㄧ劍鐐规椂鑷姩瑙﹀彂
 			},
+			// 鎵瑰彿杈撳叆妗嗚幏寰楃劍鐐�
+			onBatchFocus() {
+				console.log('[pakin] 鎵瑰彿杈撳叆妗嗚幏寰楃劍鐐�');
+				// 璁剧疆鎵瑰彿杈撳叆妗嗕负鐒︾偣锛屽叾浠栬緭鍏ユ澶卞幓鐒︾偣
+				this.batchFocus = true;
+				this.barcodeFocus = false;
+				this.matFocus = false;
+			},
+			// 鎵瑰彿杈撳叆妗嗗け鍘荤劍鐐�
+			onBatchBlur() {
+				console.log('[pakin] 鎵瑰彿杈撳叆妗嗗け鍘荤劍鐐�');
+				this.batchFocus = false;
+			},
 			clearBarcode() {
 				this.barcode = '';
 				this.barcodeFocus = false;
diff --git a/pages/stock/stockQuery.vue b/pages/stock/stockQuery.vue
index 51d6575..2e93f1d 100644
--- a/pages/stock/stockQuery.vue
+++ b/pages/stock/stockQuery.vue
@@ -122,6 +122,8 @@
 				token: '',
 				locNo: '',
 				matnr: '',
+				locNoFocus: false,
+				matFocus: false,
 				dataList: [],
 				loading: false,
 				msgType: '',
@@ -142,11 +144,17 @@
 			// 搴撲綅鍙疯緭鍏ユ鑾峰緱鐒︾偣锛堜繚鐣欐柟娉曪紝浣嗕笉鑷姩瑙﹀彂鎵弿锛�
 			onLocNoFocus() {
 				console.log('[stockQuery] 搴撲綅鍙疯緭鍏ユ鑾峰緱鐒︾偣');
+				// 璁剧疆搴撲綅鍙疯緭鍏ユ涓虹劍鐐癸紝鐗╂枡鍙峰け鍘荤劍鐐�
+				this.locNoFocus = true;
+				this.matFocus = false;
 				// 娉ㄦ剰锛氬崟鏍囩璇绘棤杩囨护鍔熻兘宸叉敼涓烘寜閿Е鍙戯紙191銆�189銆�190锛夛紝涓嶅啀鍦ㄧ劍鐐规椂鑷姩瑙﹀彂
 			},
 			// 鐗╂枡鍙疯緭鍏ユ鑾峰緱鐒︾偣锛堜繚鐣欐柟娉曪紝浣嗕笉鑷姩瑙﹀彂鎵弿锛�
 			onMatnrFocus() {
 				console.log('[stockQuery] 鐗╂枡鍙疯緭鍏ユ鑾峰緱鐒︾偣');
+				// 璁剧疆鐗╂枡鍙疯緭鍏ユ涓虹劍鐐癸紝搴撲綅鍙峰け鍘荤劍鐐�
+				this.matFocus = true;
+				this.locNoFocus = false;
 				// 娉ㄦ剰锛氬崟鏍囩璇绘棤杩囨护鍔熻兘宸叉敼涓烘寜閿Е鍙戯紙191銆�189銆�190锛夛紝涓嶅啀鍦ㄧ劍鐐规椂鑷姩瑙﹀彂
 			},
 			// 鎼滅储鐗╂枡

--
Gitblit v1.9.1