Files
admin-govern/src/views/govern/device/control/tabs/realtime.vue

706 lines
24 KiB
Vue
Raw Normal View History

2024-07-03 19:31:43 +08:00
<template>
<div class="view">
<div class="view_top">
<!-- 左侧仪表盘 -->
<div class="view_top_left">
2024-07-22 10:35:01 +08:00
<div class="left_charts_title">电压有效值</div>
<div class="left_charts"><MyEchart ref="pieChart1" :options="echartsDataV1"></MyEchart></div>
<div class="left_charts"><MyEchart ref="pieChart2" :options="echartsDataV2"></MyEchart></div>
<div class="left_charts"><MyEchart ref="pieChart3" :options="echartsDataV3"></MyEchart></div>
2024-07-03 19:31:43 +08:00
</div>
<div class="view_top_mid">
2024-07-22 10:35:01 +08:00
<div class="mid_charts_title">基波电压/电流幅值(相位)</div>
<div class="mid_charts"><MyEchart :options="echartsData1"></MyEchart></div>
2024-07-03 19:31:43 +08:00
</div>
<!-- 右侧仪表盘 -->
<div class="view_top_right">
2024-07-23 17:28:31 +08:00
<div class="right_charts_title">电流有效值</div>
2024-07-22 10:35:01 +08:00
<div class="right_charts"><MyEchart ref="pieChart4" :options="echartsDataA1"></MyEchart></div>
<div class="right_charts"><MyEchart ref="pieChart5" :options="echartsDataA2"></MyEchart></div>
<div class="right_charts"><MyEchart ref="pieChart6" :options="echartsDataA3"></MyEchart></div>
2024-07-03 19:31:43 +08:00
</div>
</div>
<div class="view_bot" v-loading="loading">
2024-08-01 16:37:24 +08:00
<div class="view_bot_tables">
2024-07-22 10:35:01 +08:00
<!-- 表格数据 -->
<div v-if="tableData.length != 0">
<!-- div设计table -->
2024-07-31 16:23:34 +08:00
<div class="table_container">
<div class="table" v-for="(item, index) in columnsDataTop" :key="index">
<div class="table_info">
<!-- 单层表头 -->
<div class="thead">
<div class="thead_top">
{{ item[0].showName ? item[0].showName : '' }}({{ item[0].unit }})
</div>
<div class="thead_bot">
<div class="thead_bot_cell" v-for="(vv, key) in item" :key="key">
{{ vv.phase == 'M' ? '' : vv.phase + '相 ' }}
</div>
</div>
</div>
<!-- 有合并表头的数据 -->
<div class="tbody">
<div class="tbody_cell" v-for="(vv, key) in item" :key="key">
{{
tableData.find(item => {
return item.anotherName == vv.showName && item.phase == vv.phase
})?.statisticalData
? tableData.find(item => {
return item.anotherName == vv.showName && item.phase == vv.phase
})?.statisticalData
: '/'
}}
</div>
2024-07-22 10:35:01 +08:00
</div>
</div>
</div>
2024-07-31 16:23:34 +08:00
</div>
<div class="table_container">
<div class="table" v-for="(item, index) in columnsDataBot" :key="index">
<div class="table_info">
<!-- 单层表头 -->
<div class="thead">
<div class="thead_top">
{{ item[0].showName ? item[0].showName : '' }}({{ item[0].unit }})
</div>
<div class="thead_bot">
<div class="thead_bot_cell" v-for="(vv, key) in item" :key="key">
{{ vv.phase == 'M' ? '' : vv.phase + '相 ' }}
</div>
</div>
</div>
<!-- 有合并表头的数据 -->
<div class="tbody">
<div class="tbody_cell" v-for="(vv, key) in item" :key="key">
{{
tableData.find((item: any) => {
2024-07-31 16:23:34 +08:00
return item.anotherName == vv.showName && item.phase == vv.phase
})?.statisticalData
? tableData.find((item: any) => {
2024-07-31 16:23:34 +08:00
return item.anotherName == vv.showName && item.phase == vv.phase
})?.statisticalData
: '/'
}}
</div>
</div>
2024-07-22 10:35:01 +08:00
</div>
</div>
</div>
</div>
2024-07-31 16:23:34 +08:00
<div v-else style="border: 1px solid #eee">
2024-07-31 10:42:04 +08:00
<el-empty description="暂无数据" />
</div>
2024-07-03 19:31:43 +08:00
</div>
</div>
</div>
</template>
<script lang="ts" setup>
import { ref, onMounted } from 'vue'
import MyEchart from '@/components/echarts/MyEchart.vue'
2024-07-22 10:35:01 +08:00
import { getRealTimeTableList } from '@/api/cs-device-boot/EquipmentDelivery'
2024-07-03 19:31:43 +08:00
import * as echarts from 'echarts'
const pieChartRef: any = ref()
2024-07-22 10:35:01 +08:00
const pieChart1: any = ref()
const pieChart2: any = ref()
const pieChart3: any = ref()
const pieChart4: any = ref()
const pieChart5: any = ref()
const pieChart6: any = ref()
2024-07-03 19:31:43 +08:00
const echartsData: any = ref({})
const echartsData1: any = ref({})
2024-07-22 10:35:01 +08:00
//电压有效值
const echartsDataV1: any = ref({})
const echartsDataV2: any = ref({})
const echartsDataV3: any = ref({})
//电流有效值
const echartsDataA1: any = ref({})
const echartsDataA2: any = ref({})
const echartsDataA3: any = ref({})
2024-08-01 16:37:24 +08:00
//渲染中相角图
const initRadioCharts = () => {
2024-07-03 19:31:43 +08:00
//中间指针图
echartsData1.value = {
options: {
grid: {
top: 230
},
title: {
text: '',
x: 'center'
},
tooltip: {
formatter: '{a} <br/>{c} {b}'
},
legend: [],
series: [
2024-08-01 16:37:24 +08:00
// 外圈电压 内圈电流
2024-07-03 19:31:43 +08:00
{
name: '基波电流相位',
type: 'gauge',
// 表盘最小值
min: 180,
// 表盘最大值
max: -180,
// 表盘分割数
splitNumber: 12,
// 圆心位置
center: ['50%', '50%'],
// 半径
radius: '50%',
startAngle: 180,
endAngle: -179.99,
// 指针方向
clockWise: true,
title: false,
// 表盘外框
axisLine: {
show: true,
lineStyle: {
color: [
2024-07-23 17:28:31 +08:00
[0.25, '#9D322D'],
[0.5, '#9D322D'],
[0.75, '#9D322D'],
[1, '#9D322D']
2024-07-03 19:31:43 +08:00
],
width: 2
}
},
// 表盘细分数
axisTick: {
show: true,
splitNumber: 5,
length: 4,
lineStyle: {
2024-07-23 17:28:31 +08:00
color: '#9D322D',
2024-07-03 19:31:43 +08:00
width: 1,
type: 'solid'
}
},
// 分割线
splitLine: {
show: true,
length: 10,
lineStyle: {
2024-07-23 17:28:31 +08:00
color: '#9D322D',
2024-07-03 19:31:43 +08:00
width: 2,
type: 'solid'
}
},
// 分割线标识
axisLabel: {
show: true,
distance: 5,
formatter: function (v) {
switch (v + '') {
case '-180':
return ''
default:
return v
}
}
},
// 指针设置
pointer: {
length: '80%',
width: 3
},
detail: {
show: false
},
data: [
{
2024-09-27 16:22:34 +08:00
value: 0,
2024-07-03 19:31:43 +08:00
name: 'A相',
itemStyle: {
2024-09-13 18:35:02 +08:00
color: '#FFCC00'
2024-07-03 19:31:43 +08:00
}
},
{
2024-09-27 16:22:34 +08:00
value: 0,
2024-07-03 19:31:43 +08:00
name: 'B相',
itemStyle: {
2024-09-13 18:35:02 +08:00
color: '#009900'
2024-07-03 19:31:43 +08:00
}
},
{
2024-09-27 16:22:34 +08:00
value: 0,
2024-07-03 19:31:43 +08:00
name: 'C相',
itemStyle: {
2024-09-13 18:35:02 +08:00
color: '#CC0000'
2024-07-03 19:31:43 +08:00
}
}
]
},
{
name: '基波电压相位',
type: 'gauge',
// 表盘最小值
min: 180,
// 表盘最大值
max: -180,
// 表盘分割数
splitNumber: 12,
// 圆心位置
center: ['50%', '50%'],
// 半径
radius: '85%',
startAngle: 180,
endAngle: -179.99,
// 指针方向
clockWise: true,
title: false,
// 表盘外框
axisLine: {
show: true,
lineStyle: {
color: [
2024-07-22 10:35:01 +08:00
[0.25, '#9D322D'],
2024-07-03 19:31:43 +08:00
[0.5, '#9D322D'],
[0.75, '#9D322D'],
[1, '#9D322D']
],
width: 1.5
}
},
// 表盘细分数
axisTick: {
show: true,
splitNumber: 5,
length: 6,
lineStyle: {
color: '#9D322D',
width: 1,
type: 'solid'
}
},
// 分割线
splitLine: {
show: true,
length: 10,
lineStyle: {
color: '#9D322D',
width: 2,
type: 'solid'
}
},
// 分割线标识
axisLabel: {
show: true,
distance: 5,
formatter: function (v) {
switch (v + '') {
case '-180':
return ''
default:
return v
}
}
},
// 指针设置
pointer: {
length: '90%',
width: 6
},
detail: {
show: false
},
data: [
{
2024-09-27 16:22:34 +08:00
value: 0,
2024-07-03 19:31:43 +08:00
name: 'A相',
itemStyle: {
2024-09-14 10:32:01 +08:00
color: '#FFCC00'
2024-07-03 19:31:43 +08:00
}
},
{
2024-09-27 16:22:34 +08:00
value: 0,
2024-07-03 19:31:43 +08:00
name: 'B相',
itemStyle: {
2024-09-14 10:32:01 +08:00
color: '#009900'
2024-07-03 19:31:43 +08:00
}
},
{
2024-09-27 16:22:34 +08:00
value: 0,
2024-07-03 19:31:43 +08:00
name: 'C相',
itemStyle: {
2024-09-14 10:32:01 +08:00
color: '#CC0000'
2024-07-03 19:31:43 +08:00
}
}
]
}
]
}
}
2024-08-01 16:37:24 +08:00
//电流相角
echartsData1.value.options.series[0].data.map((item: any) => {
iRadioList.value.map((vv: any) => {
if (item.name.includes(vv.phase)) {
item.value = vv.statisticalData
}
})
})
//电压相角
echartsData1.value.options.series[1].data.map((item: any) => {
vRadioList.value.map((vv: any) => {
if (item.name.includes(vv.phase)) {
item.value = vv.statisticalData
}
})
})
2024-07-03 19:31:43 +08:00
for (var i = 0; i < echartsData1.value.options.series.length; i++) {
echartsData1.value.options.series[i].type = 'gauge'
echartsData1.value.options.series[i].startAngle = 90
echartsData1.value.options.series[i].endAngle = -270
echartsData1.value.options.series[i].center = ['50%', '50%']
}
}
2024-08-01 16:37:24 +08:00
//渲染echarts
const init = () => {
echartsData.value = {
options: {
tooltip: {},
series: [
{
type: 'gauge',
startAngle: 180,
endAngle: 0,
min: 0,
max: 300,
radius: '150%',
center: ['55%', '76%'],
splitNumber: 3, //刻度数量
axisLine: {
show: true,
lineStyle: {
width: 10,
shadowBlur: 0,
color: [
[0.3, '#91c7a1'],
[0.7, '#63869e'],
[1, '#002B6A']
]
}
},
itemStyle: {
normal: {
shadowBlur: 10
}
},
//标题位置
title: {
fontWeight: 'bolder',
fontSize: 12,
offsetCenter: ['-130%', '-20%']
},
//数值位置
detail: {
fontSize: 12,
formatter: '{value}',
offsetCenter: ['0%', '25%']
},
data: [
{
2024-09-27 16:22:34 +08:00
value: 0,
2024-08-01 16:37:24 +08:00
name: 'A相'
}
]
}
]
}
}
echartsDataV1.value = echartsData.value
echartsDataV2.value = echartsData.value
echartsDataV3.value = echartsData.value
echartsDataA1.value = echartsData.value
echartsDataA2.value = echartsData.value
echartsDataA3.value = echartsData.value
}
2024-07-22 10:35:01 +08:00
//接收父组件传递的table数据
const dataList: any = ref([])
const listV: any = ref([])
const listA: any = ref([])
const loading = ref(false)
//定义表格所需要的数据
const tableData: any = ref([])
const columnsData: any = ref([])
const getColumns = () => {
getRealTimeTableList().then(res => {
columnsData.value = res.data
2024-09-14 10:32:01 +08:00
getTableData(dataList.value)
2024-07-22 10:35:01 +08:00
})
}
//处理表格数据
2024-07-31 16:23:34 +08:00
const columnsDataTop: any = ref([])
const columnsDataBot: any = ref([])
2024-07-22 10:35:01 +08:00
const getTableData = (list: any) => {
2024-07-31 16:23:34 +08:00
loading.value = true
2024-07-22 10:35:01 +08:00
tableData.value = list
2024-07-31 16:23:34 +08:00
columnsDataTop.value = []
columnsDataBot.value = []
2024-09-14 10:32:01 +08:00
console.log('🚀 ~ columnsData.value.map ~ columnsData.value:', columnsData.value)
2024-07-31 16:23:34 +08:00
columnsData.value.map((item: any, index: any) => {
2024-07-22 10:35:01 +08:00
item.map((vv: any) => {
vv.statisticalData = list.find((kk: any) => {
return kk.anotherName == vv.showName && kk.phase == vv.phase
})?.statisticalData
2024-07-03 19:31:43 +08:00
})
2024-07-31 16:23:34 +08:00
if (index < 4) {
2024-09-14 10:32:01 +08:00
columnsDataTop.value.push(item)
2024-07-31 16:23:34 +08:00
}
if (index >= 4) {
columnsDataBot.value.push(item)
}
loading.value = false
2024-07-22 10:35:01 +08:00
})
2024-07-03 19:31:43 +08:00
}
2024-08-01 16:37:24 +08:00
//电流相角数组&电压相角数组
const iRadioList: any = ref([]),
vRadioList: any = ref([])
2024-07-22 10:35:01 +08:00
//获取实时数据
2024-09-14 10:32:01 +08:00
const getRealTimeData = async (val: any) => {
2024-08-01 16:37:24 +08:00
iRadioList.value = []
vRadioList.value = []
val.map((item: any) => {
//基波电流相角
if (item.statisticalName == 'Pq_FundIAng') {
iRadioList.value.push(item)
}
//相电压基波有效值相角
if (item.statisticalName == 'Pq_FundUAng') {
vRadioList.value.push(item)
}
})
initRadioCharts()
2024-07-31 16:23:34 +08:00
loading.value = true
2024-07-31 10:42:04 +08:00
if (val.length != 0) {
dataList.value = val
2024-09-14 10:32:01 +08:00
await getColumns()
2024-07-31 10:42:04 +08:00
dataList.value.map((item: any, index: any) => {
if (item.anotherName == '相电压总有效值') {
listV.value.push(item)
}
if (item.anotherName == '线电压总有效值') {
listA.value.push(item)
}
})
2024-09-25 16:31:45 +08:00
console.log(listA.value, listV.value, '++++++++++++494')
2024-07-31 10:42:04 +08:00
echartsDataV1.value.options.series[0].data = [
{
2024-09-14 10:32:01 +08:00
name: 'A相',
value:
2024-07-31 10:42:04 +08:00
listV.value.find((item: any) => {
return item.phase == 'A'
2024-09-14 10:32:01 +08:00
})?.statisticalData || 0
2024-07-31 10:42:04 +08:00
}
]
pieChart1.value.initChart()
2024-09-14 10:32:01 +08:00
2024-07-31 10:42:04 +08:00
echartsDataV2.value.options.series[0].data = [
{
2024-09-14 10:32:01 +08:00
name: 'B相',
value:
2024-07-31 10:42:04 +08:00
listV.value.find((item: any) => {
return item.phase == 'B'
2024-09-14 10:32:01 +08:00
})?.statisticalData || 0
2024-07-31 10:42:04 +08:00
}
]
pieChart2.value.initChart()
echartsDataV3.value.options.series[0].data = [
{
2024-09-14 10:32:01 +08:00
name: 'C相',
value:
2024-07-31 10:42:04 +08:00
listV.value.find((item: any) => {
return item.phase == 'C'
2024-09-14 10:32:01 +08:00
})?.statisticalData || 0
2024-07-31 10:42:04 +08:00
}
]
pieChart3.value.initChart()
echartsDataA1.value.options.series[0].data = [
{
2024-09-14 10:32:01 +08:00
name: 'AB相',
value:
2024-07-31 10:42:04 +08:00
listA.value.find((item: any) => {
return item.phase == 'AB'
2024-09-14 10:32:01 +08:00
})?.statisticalData || 0
2024-07-31 10:42:04 +08:00
}
]
pieChart4.value.initChart()
echartsDataA2.value.options.series[0].data = [
{
2024-09-14 10:32:01 +08:00
name: 'BC相',
value:
2024-07-31 10:42:04 +08:00
listA.value.find((item: any) => {
return item.phase == 'BC'
2024-09-14 10:32:01 +08:00
})?.statisticalData || 0
2024-07-31 10:42:04 +08:00
}
]
pieChart5.value.initChart()
echartsDataA3.value.options.series[0].data = [
{
2024-09-14 10:32:01 +08:00
name: 'CA相',
value:
2024-07-31 10:42:04 +08:00
listA.value.find((item: any) => {
return item.phase == 'CA'
2024-09-14 10:32:01 +08:00
})?.statisticalData || 0
2024-07-31 10:42:04 +08:00
}
]
pieChart6.value.initChart()
} else {
init()
}
2024-07-22 10:35:01 +08:00
}
defineExpose({ getRealTimeData })
2024-07-03 19:31:43 +08:00
onMounted(() => {
init()
2024-08-01 16:37:24 +08:00
initRadioCharts()
2024-07-03 19:31:43 +08:00
})
</script>
<style lang="scss" scoped>
.view {
width: 100%;
height: 100%;
padding-bottom: 200px;
box-sizing: border-box;
overflow: auto;
.view_top {
width: 100%;
height: auto;
display: flex;
justify-content: space-between;
//border: 1px solid #eee;
// padding: 10px;
2024-07-03 19:31:43 +08:00
.view_top_left,
.view_top_right {
width: 30%;
height: 100%;
2024-07-22 10:35:01 +08:00
padding: 10px;
2024-07-03 19:31:43 +08:00
display: flex;
flex-direction: column;
align-items: center;
2024-07-22 10:35:01 +08:00
border: 1px solid #eee;
2024-07-03 19:31:43 +08:00
.left_charts,
.right_charts {
flex: none;
width: 100%;
height: 120px;
2024-07-22 10:35:01 +08:00
margin-bottom: 16px;
2024-07-03 19:31:43 +08:00
padding: 10px;
}
}
.view_top_mid {
flex: 1;
border: 1px solid #eee;
margin: 0 10px;
padding: 10px;
2024-07-22 10:35:01 +08:00
height: 450px;
2024-07-03 19:31:43 +08:00
.mid_charts {
width: 100%;
height: 100%;
}
}
2024-07-22 10:35:01 +08:00
.left_charts_title,
.mid_charts_title,
.right_charts_title {
width: 100%;
height: 20px;
text-align: left;
font-weight: 800;
font-weight: 16px;
line-height: 20px;
}
2024-07-03 19:31:43 +08:00
}
.view_bot {
min-height: 300px;
margin: 10px 0 20px 0;
.view_bot_tables {
margin-bottom: 10px;
height: auto;
2024-07-31 16:23:34 +08:00
min-height: 120px;
2024-07-03 19:31:43 +08:00
}
}
}
.view::-webkit-scrollbar {
display: none;
}
2024-07-31 16:23:34 +08:00
.table_container {
2024-07-22 10:35:01 +08:00
width: 100%;
2024-07-31 16:23:34 +08:00
height: auto;
2024-07-22 10:35:01 +08:00
display: flex;
2024-07-31 16:23:34 +08:00
align-items: center;
justify-content: center;
.table {
flex: 1;
.table_info {
2024-07-22 10:35:01 +08:00
width: 100%;
2024-07-31 16:23:34 +08:00
height: 120px;
// border: 1px solid #eee;
2024-07-31 16:23:34 +08:00
border-bottom: 2px solid #eee;
margin-bottom: 20px;
display: flex;
flex-direction: column;
2024-07-22 10:35:01 +08:00
}
2024-07-31 16:23:34 +08:00
.thead {
2024-07-22 10:35:01 +08:00
width: 100%;
2024-07-31 16:23:34 +08:00
height: auto;
background: #f4f6f9;
text-align: center;
2024-07-22 10:35:01 +08:00
display: flex;
2024-07-31 16:23:34 +08:00
flex-direction: column;
.thead_top {
width: 100%;
height: 40px;
line-height: 40px;
2024-07-22 10:35:01 +08:00
border: 1px solid #eee;
2024-07-31 16:23:34 +08:00
color: #111;
font-size: 14px;
font-weight: 800;
}
.thead_bot {
width: 100%;
height: 40px;
line-height: 40px;
display: flex;
color: #111;
font-size: 14px;
font-weight: 800;
.thead_bot_cell {
flex: 1;
border: 1px solid #eee;
}
2024-07-22 10:35:01 +08:00
}
}
2024-07-31 16:23:34 +08:00
.tbody {
2024-07-22 10:35:01 +08:00
flex: 1;
2024-07-31 16:23:34 +08:00
display: flex;
2024-07-22 10:35:01 +08:00
text-align: center;
2024-07-31 16:23:34 +08:00
.tbody_cell {
flex: 1;
text-align: center;
line-height: 40px;
border: 1px solid #eee;
border-bottom: 0;
}
}
.tbody:hover {
background: #f4f6f9;
2024-07-22 10:35:01 +08:00
}
}
}
2024-08-01 16:37:24 +08:00
.table_container:hover {
2024-07-31 16:23:34 +08:00
.table {
2024-08-01 16:37:24 +08:00
.tbody {
2024-07-31 16:23:34 +08:00
background: #f4f6f9;
2024-08-01 16:37:24 +08:00
}
}
2024-07-31 16:23:34 +08:00
}
2024-07-03 19:31:43 +08:00
</style>