diff --git a/src/views/govern/device/control/index.vue b/src/views/govern/device/control/index.vue index 7da9282..c5362f8 100644 --- a/src/views/govern/device/control/index.vue +++ b/src/views/govern/device/control/index.vue @@ -263,7 +263,11 @@ - + { const realTrendRef = ref() //谐波频谱 const harmonicSpectrumRef = ref() +const changeTrendType = (val: any) => { + activeTrendName.value = val * 1 + handleTrend() +} //实时趋势 -const handleTrend = () => { +const activeTrendName: any = ref(0) +const handleTrend = async () => { realTimeFlag.value = false sonTab.value = 1 clearInterval(timer.value) clearInterval(realDataTimer.value) - getHarmRealData(lineId.value, 0).then((res: any) => { + await getHarmRealData(lineId.value, activeTrendName.value).then((res: any) => { if (res.code == 'A0000') { + ElMessage.success('装置应答成功') mqttRef.value.on('message', (topic: any, message: any) => { // console.log('mqtt接收到消息', message,topic) console.log('mqtt接收到消息', JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message))))) - let obj = JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message)))) + let obj = JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message)))) || {} realTrendRef.value && realTrendRef.value.setRealTrendData(obj) }) + } else { + ElMessage.success('装置应答失败') } }) - getOverLimitData(lineId.value).then((res: any) => { + await getOverLimitData(lineId.value).then((res: any) => { console.log(res, '获取国标限制') + if(res.code=='A0000'){ + realTrendRef.value && realTrendRef.value.setOverLimitData(res.data) + } }) - realTrendRef.value && realTrendRef.value.open({ devId: deviceId.value, lineId: lineId.value }) + realTrendRef.value && + realTrendRef.value.open({ devId: deviceId.value, lineId: lineId.value, activeTrendName: activeTrendName.value }) } //谐波频谱 const handleHarmonicSpectrum = () => { @@ -607,14 +623,18 @@ const handleClick = async (tab?: any) => { //新的实时数据 //1.调用接口 mqtt推送数据 await getBasicRealData(lineId.value).then((res: any) => { - console.log(res, '获取基础实时数据') + if (res.code == 'A0000') { + ElMessage.success('装置应答成功') + } else { + ElMessage.success('装置应答失败') + } }) //2.建立mqtt通讯 const mqttMessage = ref({}) //每隔30s调用一下接口,通知后台推送mqtt消息 - realDataTimer.value = setInterval(() => { + realDataTimer.value = setInterval(() => { getBasicRealData(lineId.value).then((res: any) => { console.log(res, '获取基础实时数据') }) @@ -629,6 +649,7 @@ const handleClick = async (tab?: any) => { }) mqttRef.value.on('message', (topic: any, message: any) => { + mqttMessage.value = {} // console.log('mqtt接收到消息', message,topic) console.log('mqtt接收到消息', JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message))))) let obj = JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message)))) diff --git a/src/views/govern/device/control/tabs/components/realtrend.vue b/src/views/govern/device/control/tabs/components/realtrend.vue index e48114c..72372ff 100644 --- a/src/views/govern/device/control/tabs/components/realtrend.vue +++ b/src/views/govern/device/control/tabs/components/realtrend.vue @@ -1,9 +1,9 @@