diff --git a/pages/100J/HBY100-J.vue b/pages/100J/HBY100-J.vue index 6197ce3..7e0df3d 100644 --- a/pages/100J/HBY100-J.vue +++ b/pages/100J/HBY100-J.vue @@ -570,13 +570,12 @@ // 报警模式,选中,首次上报值,或者切换设备按键上报值 const enable = siren_alarm.enable ?? 0; // 报警开关:1=开,0=关 const mode = siren_alarm.mode ?? 0; // 模式:0/1/2/3/4/5/6 - if (these.formData.sta_VoiceType != 7) { + if (String(these.formData.sta_VoiceType) !== '7') { if (enable === 1) { - // 开启状态 these.formData.sta_VoiceType = mode + ''; } else { - // 关闭状态:赋值-1,表示关闭 - these.formData.sta_VoiceType = mode + ''; + const m = Number(mode); + these.formData.sta_VoiceType = m === 7 ? '-1' : m + ''; } } else { // 播放语音,上报消息 @@ -600,21 +599,15 @@ } // 强制报警按键解除报警状态,app同步 } else if (funcType === '12') { - const enable_alarm = data.voice_strobe_alarm ?? - 0; // 报警开关:1=开,0=关 - const mode_alarm = data.mode ?? 0; // 模式:0/1/2/3/4/5/6 + const enable_alarm = data.voice_strobe_alarm ?? 0; + const mode_alarm = data.mode ?? 0; if (enable_alarm === 1) { - // 开启状 these.deviceInfo.voiceStrobeAlarm = 1; - these.formData.sta_VoiceType = mode_alarm + '' - // 强制报警中,自定义语音,解除报警时,状态需要改变成未播放的状态的 - } else if (mode_alarm == 7 && enable_alarm == 0) { - these.formData.sta_VoiceType !== 7 + these.formData.sta_VoiceType = mode_alarm + ''; } else { - // 关闭状态:赋值-1,表示关闭 these.deviceInfo.voiceStrobeAlarm = -1; - // 模式还是选中的,模式,解除也是 - these.formData.sta_VoiceType = mode_alarm + '' + const m = Number(mode_alarm); + these.formData.sta_VoiceType = m === 7 ? '-1' : m + ''; } } // 警示灯模式选中切换 @@ -814,10 +807,12 @@ // 关闭状态 that.formData.sta_LightType = '-1'; } - if (this.formData.sta_VoiceType === '7' || res.data.alarmMode == 7) { - this.formData.sta_VoiceType = (res.data.voiceStrobeAlarm ?? 0) + ''; + const alarmOnDetail = res.data.voiceStrobeAlarm === 1; + const amDetail = res.data.alarmMode != null ? Number(res.data.alarmMode) : 0; + if (alarmOnDetail) { + this.formData.sta_VoiceType = amDetail + ''; } else { - this.formData.sta_VoiceType = res.data.alarmMode + '' + this.formData.sta_VoiceType = amDetail === 7 ? '-1' : amDetail + ''; } } }) @@ -1158,7 +1153,8 @@ title: isClose ? '声光报警已解除' : '强制报警已开启', icon: 'none' }); - if (isClose && this.formData.sta_VoiceType === '7') { + // 解除后「播放语音」行与 mode7 绑定,需退出高亮(兼容 sta_VoiceType 为数字 7) + if (isClose && String(this.formData.sta_VoiceType) === '7') { this.formData.sta_VoiceType = '-1'; } } else { @@ -1384,7 +1380,9 @@ this.formData.sta_VoiceType = (parsedData.alarmMode ?? 0) + ''; } else { this.$set(this.deviceInfo, 'voiceStrobeAlarm', -1); - this.formData.sta_VoiceType = (parsedData.alarmMode ?? 0) + ''; + const am = Number(parsedData.alarmMode ?? 0); + // 报警已关:设备仍可能带 mode7,避免「播放语音」仍显示为开启 + this.formData.sta_VoiceType = am === 7 ? '-1' : am + ''; } } // 0x0A 爆闪模式:警示灯开关/模式 @@ -1410,7 +1408,8 @@ this.formData.sta_VoiceType = (parsedData.alarmMode ?? 0) + ''; } else { this.$set(this.deviceInfo, 'voiceStrobeAlarm', -1); - this.formData.sta_VoiceType = (parsedData.alarmMode ?? 0) + ''; + const am = Number(parsedData.alarmMode ?? 0); + this.formData.sta_VoiceType = am === 7 ? '-1' : am + ''; } } if (parsedData.voiceBroadcast !== undefined) {