From 91af6caf5a797bcc912e9a22656c97775bd4a198 Mon Sep 17 00:00:00 2001 From: gaoluyang <2820782392@qq.com> Date: 星期五, 05 九月 2025 11:20:16 +0800 Subject: [PATCH] 设备保养、设备维修真机测试,bug修改 --- src/pages/equipmentManagement/repair/add.vue | 21 ++++++++++++--------- 1 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/pages/equipmentManagement/repair/add.vue b/src/pages/equipmentManagement/repair/add.vue index 9f3cd0e..8717814 100644 --- a/src/pages/equipmentManagement/repair/add.vue +++ b/src/pages/equipmentManagement/repair/add.vue @@ -13,6 +13,7 @@ placeholder="璇烽�夋嫨璁惧鍚嶇О" @click="showDevicePicker" clearable + readonly="" /> <template #right> <u-icon name="scan" @click="startScan" class="scan-icon" /> @@ -215,24 +216,26 @@ } isScanning.value = true; - showToast('鎵爜鎴愬姛锛�3绉掑悗鑷姩濉厖璁惧淇℃伅'); + showToast('鎵爜鎴愬姛'); // 3绉掑悗澶勭悊鎵爜缁撴灉 scanTimer.value = setTimeout(() => { processScanResult(scanResult); isScanning.value = false; - }, 3000); + }, 100); }; +function getDeviceIdByRegExp(url) { + // 鍖归厤deviceId=鍚庨潰鐨勬暟瀛� + const reg = /deviceId=(\d+)/; + const match = url.match(reg); + // 濡傛灉鍖归厤鍒扮粨鏋滐紝杩斿洖鏁板瓧绫诲瀷锛屽惁鍒欒繑鍥瀗ull + return match ? Number(match[1]) : null; +} // 澶勭悊鎵爜缁撴灉骞跺尮閰嶈澶� const processScanResult = (scanResult) => { - // 鍦ㄨ澶囧垪琛ㄤ腑鏌ユ壘鍖归厤鐨勮澶� - // 鍋囪浜岀淮鐮佸唴瀹规槸璁惧鍚嶇О鎴栬澶囩紪鍙� - const matchedDevice = deviceOptions.value.find(device => - device.deviceName === scanResult || - device.deviceCode === scanResult || - device.id.toString() === scanResult - ); + const deviceId = getDeviceIdByRegExp(scanResult); + const matchedDevice = deviceOptions.value.find(item => item.id == deviceId); if (matchedDevice) { // 鎵惧埌鍖归厤鐨勮澶囷紝鑷姩濉厖 -- Gitblit v1.9.3