实时数据页面绘制
This commit is contained in:
@@ -37,7 +37,15 @@
|
||||
v-for="(item, index) in deviceData.dataSetList"
|
||||
:key="index"
|
||||
></el-tab-pane>
|
||||
<el-form :inline="true" style="white-space: nowrap; margin-top: 10px">
|
||||
<el-form
|
||||
:inline="true"
|
||||
style="white-space: nowrap; margin-top: 10px"
|
||||
v-if="
|
||||
dataSet.indexOf('_trenddata') == -1 &&
|
||||
dataSet.indexOf('_realtimedata') == -1 &&
|
||||
dataSet.indexOf('_event') == -1
|
||||
"
|
||||
>
|
||||
<el-form-item label="指标">
|
||||
<el-input
|
||||
v-model="formInline.searchValue"
|
||||
@@ -46,7 +54,7 @@
|
||||
placeholder="请输入关键词"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="日期" v-if="dataSet.indexOf('_history') > -1">
|
||||
<el-form-item label="日期" v-if="dataSet.indexOf('_history') != -1">
|
||||
<DatePicker ref="datePickerRef"></DatePicker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
@@ -57,17 +65,14 @@
|
||||
style="overflow: auto"
|
||||
:style="{ height: tableHeight }"
|
||||
v-loading="tableLoading"
|
||||
v-if="dataSet.length > 1"
|
||||
v-if="
|
||||
dataSet.indexOf('_trenddata') == -1 &&
|
||||
dataSet.indexOf('_realtimedata') == -1 &&
|
||||
dataSet.indexOf('_event') == -1
|
||||
"
|
||||
>
|
||||
<!-- 卡片 -->
|
||||
<div
|
||||
class="content"
|
||||
v-if="
|
||||
dataSet.indexOf('_trenddata') == -1 &&
|
||||
dataSet.indexOf('_realtimedata') == -1 &&
|
||||
dataSet.indexOf('_event') == -1
|
||||
"
|
||||
>
|
||||
<!-- 循环渲染的card 最新数据/历史数据显示 -->
|
||||
<div class="content">
|
||||
<el-card class="box-card" v-for="(item, index) in tableData" :key="index">
|
||||
<template #header>
|
||||
<div class="clearfix">
|
||||
@@ -153,6 +158,22 @@
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="formInline.total"
|
||||
></el-pagination>
|
||||
|
||||
<!-- 趋势数据 -->
|
||||
<div style="height: calc(100vh - 200px)" v-if="dataSet.indexOf('_trenddata') != -1">
|
||||
趋势数据
|
||||
<Trend></Trend>
|
||||
</div>
|
||||
<!-- 实时数据 -->
|
||||
<div style="height: calc(100vh - 200px)" v-if="dataSet.indexOf('_realtimedata') != -1">
|
||||
实时数据
|
||||
<RealTime></RealTime>
|
||||
</div>
|
||||
<!-- 暂态事件 -->
|
||||
<div style="height: calc(100vh - 200px)" v-if="dataSet.indexOf('_event') != -1">
|
||||
暂态事件
|
||||
<Event></Event>
|
||||
</div>
|
||||
<div v-if="!tableData" style="height: 42px"></div>
|
||||
<!-- <el-tab-pane lazy label="趋势数据" name="0">
|
||||
<div style="height:calc(100vh - 330px);overflow: auto;border:1px solid red;"></div>
|
||||
@@ -178,10 +199,14 @@ import { queryByCode, queryByid, queryCsDictTree } from '@/api/system-boot/dictT
|
||||
import { getDeviceData } from '@/api/cs-device-boot/EquipmentDelivery'
|
||||
import { deviceHisData, deviceRtData } from '@/api/cs-device-boot/csGroup'
|
||||
import { getGroup } from '@/api/cs-device-boot/csGroup'
|
||||
import { ref, reactive, nextTick } from 'vue'
|
||||
import { ref, reactive, nextTick, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import DatePicker from '@/components/form/datePicker/index.vue'
|
||||
|
||||
import Trend from './tabs/trend.vue'
|
||||
import RealTime from './tabs/realtime.vue'
|
||||
import Event from './tabs/event.vue'
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
import type { UserConfig, ConfigEnv } from 'vite'
|
||||
defineOptions({
|
||||
name: 'govern/device/control'
|
||||
})
|
||||
@@ -208,6 +233,43 @@ const formInline = reactive({
|
||||
lineId: ''
|
||||
})
|
||||
const detail = ref<any>(null)
|
||||
// WebSocket
|
||||
const socket: any = ref(null)
|
||||
const url = 'wss://your-websocket-url'
|
||||
//连接websocket
|
||||
const connectWebSocket = () => {
|
||||
socket.value = new WebSocket(url)
|
||||
socket.value.onopen = () => {
|
||||
console.log('WebSocket connected')
|
||||
socket.value.isConnected = true
|
||||
}
|
||||
|
||||
socket.value.onerror = (error: any) => {
|
||||
console.error('WebSocket error:', error)
|
||||
}
|
||||
|
||||
socket.value.onmessage = (message: any) => {
|
||||
console.log('Received message:', message.data)
|
||||
}
|
||||
|
||||
socket.value.onclose = () => {
|
||||
console.log('WebSocket disconnected')
|
||||
socket.value.isConnected = false
|
||||
}
|
||||
}
|
||||
//建立连接发送消息
|
||||
const sendMessage = () => {
|
||||
if (socket.value.isConnected) {
|
||||
socket.value.send('Your message here')
|
||||
}
|
||||
}
|
||||
//关闭websocket
|
||||
const disconnectWebSocket = () => {
|
||||
if (socket.value.isConnected) {
|
||||
socket.value.close()
|
||||
}
|
||||
}
|
||||
|
||||
const getDeviceDataTrend = (e: any) => {
|
||||
detail.value = {
|
||||
lineId: formInline.lineId,
|
||||
@@ -223,6 +285,7 @@ const handleSizeChange = (val: number) => {
|
||||
formInline.pageSize = val
|
||||
handleClick()
|
||||
}
|
||||
//树节点点击事件
|
||||
const nodeClick = async (e: anyObj) => {
|
||||
if (!e) {
|
||||
loading.value = false
|
||||
@@ -241,15 +304,19 @@ const nodeClick = async (e: anyObj) => {
|
||||
} else {
|
||||
res.data.dataSetList.forEach((item: any) => {
|
||||
console.log(item.type, '777777777')
|
||||
//历史
|
||||
if (item.type === 'history') {
|
||||
item.id = item.id + '_history'
|
||||
}
|
||||
//趋势数据
|
||||
if (item.type === 'trenddata') {
|
||||
item.id = item.id + '_trenddata'
|
||||
}
|
||||
//实时数据
|
||||
if (item.type === 'realtimedata') {
|
||||
item.id = item.id + '_realtimedata'
|
||||
}
|
||||
//暂态事件
|
||||
if (item.type === 'event') {
|
||||
item.id = item.id + '_event'
|
||||
}
|
||||
@@ -263,6 +330,7 @@ const nodeClick = async (e: anyObj) => {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
//tab点击事件
|
||||
const handleClick = async (tab?: any) => {
|
||||
tableLoading.value = true
|
||||
if (tab) {
|
||||
@@ -271,7 +339,7 @@ const handleClick = async (tab?: any) => {
|
||||
}
|
||||
// setTimeout(() => {
|
||||
//查询历史模块数据
|
||||
if (dataSet.value.indexOf('_history') > -1) {
|
||||
if (dataSet.value.indexOf('_history') != -1) {
|
||||
console.log('_history')
|
||||
formInline.startTime = datePickerRef.value.timeValue[0]
|
||||
formInline.endTime = datePickerRef.value.timeValue[1]
|
||||
@@ -284,15 +352,16 @@ const handleClick = async (tab?: any) => {
|
||||
})
|
||||
}
|
||||
//查询数据趋势数据
|
||||
if (dataSet.value.indexOf('_trenddata') > -1) {
|
||||
console.log(dataSet.value.indexOf('_trenddata'), '-------')
|
||||
if (dataSet.value.indexOf('_trenddata') != -1) {
|
||||
console.log('_trenddata')
|
||||
}
|
||||
//查询实时数据
|
||||
if (dataSet.value.indexOf('_realtimedata') > -1) {
|
||||
if (dataSet.value.indexOf('_realtimedata') != -1) {
|
||||
console.log('_realtimedata')
|
||||
}
|
||||
//查询暂事件
|
||||
if (dataSet.value.indexOf('_event') > -1) {
|
||||
//查询暂态事件
|
||||
if (dataSet.value.indexOf('_event') != -1) {
|
||||
console.log('_event')
|
||||
} else {
|
||||
formInline.id = dataSet.value
|
||||
@@ -352,6 +421,9 @@ const openGroup = () => {
|
||||
})
|
||||
})
|
||||
}
|
||||
onMounted(() => {
|
||||
connectWebSocket()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user