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(() => {