From 0e9d4990502c0aca8f948c30ca6a7162d4db6ae2 Mon Sep 17 00:00:00 2001 From: houjunxiang Date: Sat, 17 Jan 2026 13:32:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=A4=A9=E5=B9=B3=E7=9B=91=E5=90=AC?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/analysis/sample/sample-work-detail.vue | 24 +++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/pages/analysis/sample/sample-work-detail.vue b/pages/analysis/sample/sample-work-detail.vue index d091bf7..2859075 100644 --- a/pages/analysis/sample/sample-work-detail.vue +++ b/pages/analysis/sample/sample-work-detail.vue @@ -403,12 +403,8 @@ const fieldClick = (field, key) => { let decimalPosition = field.decimalPosition if (decimalPosition == null || decimalPosition < -1) decimalPosition = -1 numKeyboardParam.decimal = decimalPosition - if (currentFillingWay.value == 'collect') { - listenDeviceData() - } else { - closeDeviceListener() - } } + const currentFillingIndex = ref(0) const fillingWay = computed(() => { if (selectedField.value.fillingWay) { @@ -420,6 +416,16 @@ const fillingWay = computed(() => { const currentFillingWay = computed(() => { return fillingWay.value[currentFillingIndex.value] || '' }) +watch( + () => currentFillingWay.value, + newVal => { + if (newVal == 'collect') { + listenDeviceData() + } else { + closeDeviceListener() + } + } +) const switchFillingWay = () => { currentFillingIndex.value = (currentFillingIndex.value + 1) % fillingWay.value.length } @@ -1047,8 +1053,11 @@ const listenDeviceData = () => { uni.$on('deviceData', res => { switch (res.deviceType) { case 'balance': + console.log(res.deviceId) + if (currentAuncel.value.id === res.deviceId) { - console.log('天平信息', res) + console.log(res) + currentAuncel.value.weightData = res.weightData currentAuncel.value.weightUnit = res.weightUnit currentAuncel.value.weightStable = res.weightStable @@ -1076,7 +1085,6 @@ const listenDeviceData = () => { //控制设备状态 uni.$on('controlDevice', res => { if (currentAuncel.value.id === res.deviceId) { - console.log('控制', res.deviceId) currentAuncel.value.id = '' currentAuncel.value.name = '' currentAuncel.value.code = '' @@ -1253,7 +1261,7 @@ onLoad(param => { onShow(() => { loadDevice() - listenDeviceData() + // listenDeviceData() }) onHide(() => {