实时数据问题修改
This commit is contained in:
@@ -167,19 +167,21 @@
|
|||||||
返回
|
返回
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<!-- style="height: calc(100vh - 300px)" -->
|
||||||
style="height: calc(100vh - 300px)"
|
<!-- <div
|
||||||
|
style="height: 100%;"
|
||||||
v-if="
|
v-if="
|
||||||
dataSet.indexOf('_trenddata') == -1 &&
|
dataSet.indexOf('_trenddata') == -1 &&
|
||||||
dataSet.indexOf('_realtimedata') == -1 &&
|
dataSet.indexOf('_realtimedata') == -1 &&
|
||||||
dataSet.indexOf('_event') == -1 &&
|
dataSet.indexOf('_event') == -1 &&
|
||||||
tableData.length == 0
|
tableData.length == 0
|
||||||
"
|
"
|
||||||
v-loading="tableLoading"
|
></div> -->
|
||||||
></div>
|
<!-- v-loading="tableLoading" -->
|
||||||
<div
|
<div
|
||||||
style="overflow: auto"
|
style="overflow: auto"
|
||||||
:style="{ height: tableHeight }"
|
:style="{ height: tableHeight }"
|
||||||
|
v-loading="tableLoading"
|
||||||
v-if="
|
v-if="
|
||||||
dataSet.indexOf('_trenddata') == -1 &&
|
dataSet.indexOf('_trenddata') == -1 &&
|
||||||
dataSet.indexOf('_realtimedata') == -1 &&
|
dataSet.indexOf('_realtimedata') == -1 &&
|
||||||
@@ -188,7 +190,7 @@
|
|||||||
"
|
"
|
||||||
>
|
>
|
||||||
<!-- 循环渲染的card 最新数据/历史数据显示 -->
|
<!-- 循环渲染的card 最新数据/历史数据显示 -->
|
||||||
<div class="content" v-loading="tableLoading">
|
<div class="content">
|
||||||
<el-card class="box-card" v-for="(item, index) in tableData" :key="index">
|
<el-card class="box-card" v-for="(item, index) in tableData" :key="index">
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="clearfix">
|
<div class="clearfix">
|
||||||
@@ -285,11 +287,7 @@
|
|||||||
></el-pagination>
|
></el-pagination>
|
||||||
|
|
||||||
<!-- 趋势数据 -->
|
<!-- 趋势数据 -->
|
||||||
<div
|
<div style="height: calc(100vh - 340px)" v-if="dataSet.indexOf('_trenddata') != -1">
|
||||||
style="height: calc(100vh - 340px)"
|
|
||||||
v-if="dataSet.indexOf('_trenddata') != -1"
|
|
||||||
v-loading="tableLoading"
|
|
||||||
>
|
|
||||||
<Trend ref="trendRef"></Trend>
|
<Trend ref="trendRef"></Trend>
|
||||||
</div>
|
</div>
|
||||||
<!-- 实时数据 -->
|
<!-- 实时数据 -->
|
||||||
@@ -455,16 +453,15 @@ const handleTrend = async () => {
|
|||||||
})
|
})
|
||||||
}, 30000)
|
}, 30000)
|
||||||
mqttRef.value.on('message', (topic: any, message: any) => {
|
mqttRef.value.on('message', (topic: any, message: any) => {
|
||||||
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)))) || {}
|
||||||
if ((obj.hasOwnProperty('data1') || obj.hasOwnProperty('data2')) && obj.dataTime) {
|
if ((obj.hasOwnProperty('data1') || obj.hasOwnProperty('data2')) && obj.dataTime) {
|
||||||
console.log('进来聊聊吗')
|
|
||||||
trendDataTime.value = obj.dataTime
|
trendDataTime.value = obj.dataTime
|
||||||
realTrendRef.value && realTrendRef.value.setRealTrendData(obj)
|
realTrendRef.value && realTrendRef.value.setRealTrendData(obj)
|
||||||
tableLoading.value = false
|
tableLoading.value = false
|
||||||
|
console.log(
|
||||||
|
'谐波频谱---mqtt接收到消息',
|
||||||
|
JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message))))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
// else {
|
// else {
|
||||||
// trendDataTime.value = obj.dataTime
|
// trendDataTime.value = obj.dataTime
|
||||||
@@ -795,8 +792,8 @@ const getRealDataMqttMsg = async () => {
|
|||||||
obj[i] = obj[i].toFixed(2)
|
obj[i] = obj[i].toFixed(2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mqttMessage.value = obj
|
if (obj.hasOwnProperty('pA') && obj.hasOwnProperty('pB')) {
|
||||||
if (mqttMessage.value.hasOwnProperty('pA') && mqttMessage.value.hasOwnProperty('pB')) {
|
mqttMessage.value = obj
|
||||||
//更新实时数据主页面值
|
//更新实时数据主页面值
|
||||||
realTimeFlag.value && realTimeRef.value && realTimeRef.value.setRealData(mqttMessage.value)
|
realTimeFlag.value && realTimeRef.value && realTimeRef.value.setRealData(mqttMessage.value)
|
||||||
//更新实时趋势折线图数据
|
//更新实时趋势折线图数据
|
||||||
@@ -839,11 +836,14 @@ const realDataTimer: any = ref()
|
|||||||
const mqttMessage = ref<any>({})
|
const mqttMessage = ref<any>({})
|
||||||
const handleClick = async (tab?: any) => {
|
const handleClick = async (tab?: any) => {
|
||||||
if (realDataTimer.value) {
|
if (realDataTimer.value) {
|
||||||
window.clearInterval(realDataTimer.value)
|
clearInterval(realDataTimer.value)
|
||||||
}
|
}
|
||||||
if (trendTimer.value) {
|
if (trendTimer.value) {
|
||||||
window.clearInterval(trendTimer.value)
|
clearInterval(trendTimer.value)
|
||||||
}
|
}
|
||||||
|
sonTab.value = null
|
||||||
|
activeTrendName.value = 0
|
||||||
|
mqttMessage.value = {}
|
||||||
tableLoading.value = true
|
tableLoading.value = true
|
||||||
//点击tab时更新dataSet最新值
|
//点击tab时更新dataSet最新值
|
||||||
if (tab && tab.props && tab.props.name && dataSet.value != tab.props.name) {
|
if (tab && tab.props && tab.props.name && dataSet.value != tab.props.name) {
|
||||||
@@ -896,6 +896,7 @@ const handleClick = async (tab?: any) => {
|
|||||||
}
|
}
|
||||||
//查询实时数据
|
//查询实时数据
|
||||||
if (dataSet.value.includes('_realtimedata')) {
|
if (dataSet.value.includes('_realtimedata')) {
|
||||||
|
tableLoading.value = true
|
||||||
//查询实时数据显示实时录波、实时趋势、谐波频谱
|
//查询实时数据显示实时录波、实时趋势、谐波频谱
|
||||||
realTimeFlag.value = true
|
realTimeFlag.value = true
|
||||||
connectMqtt()
|
connectMqtt()
|
||||||
@@ -950,9 +951,9 @@ const handleClick = async (tab?: any) => {
|
|||||||
if (trendTimer.value) {
|
if (trendTimer.value) {
|
||||||
window.clearInterval(trendTimer.value)
|
window.clearInterval(trendTimer.value)
|
||||||
}
|
}
|
||||||
// if (mqttRef.value) {
|
if (mqttRef.value) {
|
||||||
// mqttRef.value.end()
|
mqttRef.value.end()
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//模版下载
|
//模版下载
|
||||||
|
|||||||
@@ -124,9 +124,9 @@ const open = async (val: any) => {
|
|||||||
params.value = { groupId: tabsList.value[activeName.value]?.id, ...val }
|
params.value = { groupId: tabsList.value[activeName.value]?.id, ...val }
|
||||||
init()
|
init()
|
||||||
|
|
||||||
setTimeout(() => {
|
// setTimeout(() => {
|
||||||
loading.value = false
|
// loading.value = false
|
||||||
}, 1500)
|
// }, 1500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//根据指标tab查询实时趋势
|
//根据指标tab查询实时趋势
|
||||||
@@ -199,6 +199,9 @@ const init = () => {
|
|||||||
})
|
})
|
||||||
if (barCharts.value) {
|
if (barCharts.value) {
|
||||||
barCharts.value[activeName.value]?.initChart()
|
barCharts.value[activeName.value]?.initChart()
|
||||||
|
loading.value=false
|
||||||
|
}else{
|
||||||
|
loading.value=true
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user