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

508 lines
15 KiB
Vue
Raw Normal View History

2024-10-21 19:00:52 +08:00
<!-- 实时数据 - 谐波频谱页面 -->
2024-07-22 10:35:01 +08:00
<template>
2024-10-14 20:39:01 +08:00
<div class="realtrend" v-loading="loading">
<div class="select" v-if="!loading">
2024-11-27 16:32:13 +08:00
<div class="mr10">谐波次数 </div>
2024-12-09 16:30:40 +08:00
<el-select v-model="selectValue" style="width: 100px" @change="selectChange">
2024-11-27 16:01:08 +08:00
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</div>
2024-10-21 19:00:52 +08:00
<el-tabs type="border-card" v-if="tabsList.length != 0" v-model="activeName" @tab-click="handleClick">
2024-07-31 15:23:48 +08:00
<el-tab-pane v-for="(item, index) in tabsList" :label="item.groupName" :name="index" :key="index">
2024-10-14 20:39:01 +08:00
<div>
2024-07-31 10:42:04 +08:00
<div class="realtrend_top">
2024-10-14 15:09:58 +08:00
<!-- <div class="thead">
2024-07-31 10:42:04 +08:00
<ul v-for="(table, tableIndex) in newTableList" :key="tableIndex">
<li>
{{ table[0].value }}
</li>
</ul>
</div>
2024-10-14 15:09:58 +08:00
<div class="table">
2024-07-31 10:42:04 +08:00
<ul v-for="(table, tableIndex) in newTableList" :key="tableIndex">
<span v-for="(key, keys) in table">
<li v-if="keys != 0">
{{ key?.value }}
2024-10-14 20:39:01 +08:00
</li>
2024-07-31 10:42:04 +08:00
</span>
</ul>
2024-10-14 15:09:58 +08:00
</div> -->
2024-10-14 20:39:01 +08:00
<div class="realtrend_table" v-if="Object.keys(tableData).length != 0">
2024-10-14 15:09:58 +08:00
<div class="thead_left">
2024-12-09 16:30:40 +08:00
<p style=" font-weight: 700; background-color: #F3F6F9;">次数()</p>
2024-10-22 15:01:41 +08:00
<p>{{ item.groupName }}{{ item.unit ? '(' + item.unit + ')' : '' }}</p>
2024-12-09 16:30:40 +08:00
<p>国标限值{{ item.unit ? '(' + item.unit + ')' : '' }}</p>
2024-10-14 15:09:58 +08:00
</div>
<div class="thead_right">
<div class="right_cell" v-for="(value, key, index) in tableData" :key="index">
2024-12-09 16:30:40 +08:00
<p v-if="item.groupName.includes('间谐波')" style="background-color: #F3F6F9;">
{{ Number(String(key).replace('data', ' ')) - 0.5 }}
2024-10-22 14:00:39 +08:00
</p>
2024-12-09 16:30:40 +08:00
<p v-else style="background-color: #F3F6F9;">
<span>{{ String(key).replace('data', ' ') }}</span>
2024-10-14 15:09:58 +08:00
</p>
2024-10-14 20:39:01 +08:00
<p>
<span v-if="
String(key).includes('data') &&
String(key) != 'dataLevel' &&
String(key) != 'dataTime'
">
2024-10-14 15:09:58 +08:00
{{ value }}
</span>
</p>
2024-12-09 16:30:40 +08:00
<p>
<span v-if="
String(key).includes('data') &&
String(key) != 'dataLevel' &&
String(key) != 'dataTime'
">
{{ gbData[index]?.value || '/' }}
</span>
</p>
2024-10-14 15:09:58 +08:00
</div>
2024-12-09 16:30:40 +08:00
2024-10-14 15:09:58 +08:00
</div>
2024-12-09 16:30:40 +08:00
2024-07-31 10:42:04 +08:00
</div>
</div>
2024-10-14 20:39:01 +08:00
<div class="tab_info" v-if="Object.keys(tableData).length != 0">
2024-07-31 10:42:04 +08:00
<div class="charts">
<MyEchart ref="barCharts" :options="echartsData" :isInterVal="true"></MyEchart>
2024-07-31 10:42:04 +08:00
</div>
</div>
2024-10-14 20:39:01 +08:00
<el-empty v-else style="margin: 0 auto" />
2024-07-31 10:42:04 +08:00
</div>
</el-tab-pane>
2024-07-22 10:35:01 +08:00
</el-tabs>
2024-10-21 19:00:52 +08:00
<!-- <el-empty v-else/> -->
2024-07-22 10:35:01 +08:00
</div>
</template>
<script lang="ts" setup>
import { ref, onMounted, defineEmits } from 'vue'
import { VxeGridProps } from 'vxe-table'
2024-07-22 10:35:01 +08:00
import { defaultAttribute } from '@/components/table/defaultAttribute'
import MyEchart from '@/components/echarts/MyEchart.vue'
2024-07-31 15:23:48 +08:00
const activeName = ref(0)
2024-10-14 20:39:01 +08:00
const emit = defineEmits(['changeTrendType'])
2024-07-31 10:42:04 +08:00
const tableList: any = []
const selectValue = ref('1')
const options = [
2024-11-27 16:32:13 +08:00
{
value: '3',
label: '全部',
},
{
value: '1',
label: '奇次',
},
{
value: '2',
label: '偶次',
},
]
2024-07-22 10:35:01 +08:00
interface RowVO {
[key: string]: any
}
//谐波电压含有率
const gridOptions = ref<VxeGridProps<RowVO>>({
border: true,
showOverflow: true,
showHeader: false,
columns: [],
data: [],
columnConfig: {
resizable: true
},
align: 'center'
})
gridOptions.value = { ...defaultAttribute, ...gridOptions.value }
2024-07-31 10:42:04 +08:00
2024-10-21 19:00:52 +08:00
const tabsList: any = ref([])
const loading: any = ref(true)
2024-07-31 10:42:04 +08:00
//接收参数
const params = ref({})
2024-10-15 15:30:01 +08:00
const open = async (val: any) => {
2024-10-14 20:39:01 +08:00
loading.value = true
2024-10-21 19:00:52 +08:00
//获取指标tab
tabsList.value = [
{
id: '6d5470f509ca271d7108a86e83bb283f',
groupName: '谐波电压含有率',
thdDataVOS: null,
2024-10-22 14:00:39 +08:00
thdDataTdVODatas: null,
unit: '%'
2024-10-21 19:00:52 +08:00
},
{
id: '8dc260f16280184e2b57d26668dc00b1',
groupName: '谐波电流幅值',
thdDataVOS: null,
2024-10-22 14:00:39 +08:00
thdDataTdVODatas: null,
unit: 'A'
2024-10-21 19:00:52 +08:00
},
{
id: 'ae31115b83f02f03a0d3bd65cb017121',
groupName: '间谐波电压含有率',
thdDataVOS: null,
2024-10-22 14:00:39 +08:00
thdDataTdVODatas: null,
unit: '%'
2024-07-31 10:42:04 +08:00
}
2024-10-21 19:00:52 +08:00
]
if (tabsList.value.length != 0) {
// activeName.value = tabsList.value[0]?.id
activeName.value = val.activeTrendName || 0
}
params.value = { groupId: tabsList.value[activeName.value]?.id, ...val }
2024-10-14 20:39:01 +08:00
init()
2024-10-21 19:00:52 +08:00
2024-10-29 16:30:32 +08:00
// setTimeout(() => {
// loading.value = false
// }, 1500)
2024-07-31 10:42:04 +08:00
return
}
//根据指标tab查询实时趋势
//echarts数据
const chartsData: any = ref([])
const chartsYxiasData: any = ref([])
2024-07-22 10:35:01 +08:00
2024-10-22 14:00:39 +08:00
const echartsData: any = ref()
2024-10-14 15:09:58 +08:00
const barCharts = ref()
2024-12-09 16:30:40 +08:00
const gbData = ref([])
2024-07-22 10:35:01 +08:00
//加载echarts
const init = () => {
2024-10-14 20:39:01 +08:00
let trendData: any = []
for (let key in tableData.value) {
trendData.push({
name: key,
value: tableData.value[key],
count: String(key).replace('data', '')
})
}
2024-12-09 16:30:40 +08:00
gbData.value = []
2024-10-14 20:39:01 +08:00
for (let key in limitData.value) {
2024-12-09 16:30:40 +08:00
gbData.value.push({
2024-10-14 20:39:01 +08:00
name: key,
value: limitData.value[key]
})
}
if (selectValue.value == '1') {
2024-12-09 16:30:40 +08:00
gbData.value = gbData.value.filter((_, index: number) => index % 2 !== 0)
} else if (selectValue.value == '2') {
2024-12-09 16:30:40 +08:00
gbData.value = gbData.value.filter((_, index: number) => index % 2 == 0)
}
2024-07-31 10:42:04 +08:00
let xAxisList: any = []
chartsData.value.map((item: any, index: any) => {
2024-07-31 15:23:48 +08:00
chartsYxiasData.value.map((vv: any, vvs: any) => {
2024-07-31 10:42:04 +08:00
if (item.phase == vv.phase) {
2024-07-31 15:23:48 +08:00
if (vvs == 0) {
vv.gbList.push(item.internationalValue)
}
2024-07-31 10:42:04 +08:00
vv.phaseList.push(item.statisticalData)
}
})
xAxisList.push(item.frequency + '次')
})
xAxisList = [...new Set(xAxisList)]
echartsData.value = {
2024-10-22 14:00:39 +08:00
color: ['#2E8B57', '#DAA520'],
xAxis: {
name: '次数',
data: trendData.map((item: any) => {
return (activeName.value == 2 ? item.count - 0.5 : item.count) + '次'
2024-10-22 14:00:39 +08:00
})
},
yAxis: {
name: tabsList.value[activeName.value].unit
},
series: []
2024-07-31 10:42:04 +08:00
}
2024-10-14 20:39:01 +08:00
let list: any = [
2024-12-09 16:30:40 +08:00
trendData.map((item: any) => {
2024-10-14 20:39:01 +08:00
return item.value
}),
2024-12-09 16:30:40 +08:00
gbData.value.map((item: any) => {
2024-10-14 20:39:01 +08:00
return item.value
2024-12-09 16:30:40 +08:00
}),
2024-10-14 20:39:01 +08:00
]
2024-12-09 16:30:40 +08:00
let legendList = [tabsList.value[activeName.value]?.groupName, '国标限值',]
2024-10-22 14:00:39 +08:00
// echartsData.value.legend.data = legendList
2024-07-31 10:42:04 +08:00
list.map((item: any, index: any) => {
2024-10-22 14:00:39 +08:00
echartsData.value.series.push({
2024-10-14 20:39:01 +08:00
name: legendList[index],
2024-07-31 10:42:04 +08:00
type: 'bar',
2024-10-14 20:39:01 +08:00
data: item
2024-07-31 10:42:04 +08:00
})
})
2024-10-14 15:09:58 +08:00
if (barCharts.value) {
barCharts.value[activeName.value]?.initChart()
loading.value = false
} else {
loading.value = true
2024-10-14 15:09:58 +08:00
}
2024-07-31 15:23:48 +08:00
return
2024-07-22 10:35:01 +08:00
}
const handleClick = (tab: any, event: any) => {
tableData.value = []
echartsData.value = {}
2024-10-22 15:01:41 +08:00
loading.value = true
2024-07-31 15:23:48 +08:00
params.value.groupId = tabsList.value[tab.index].id
2024-10-14 20:39:01 +08:00
emit('changeTrendType', tab.index)
activeName.value = tab.index
2024-07-22 10:35:01 +08:00
init()
}
2024-10-14 15:09:58 +08:00
//获取mqtt传送的实时数据
const mqttMessage: any = ref()
const tableData: any = ref({})
const setRealTrendData = (val: any) => {
2024-10-24 16:18:52 +08:00
mqttMessage.value = {}
if (!val) {
2024-10-22 15:01:41 +08:00
return
}
2024-10-22 14:00:39 +08:00
loading.value = true
2024-10-14 20:39:01 +08:00
tableData.value = {}
2024-10-14 15:09:58 +08:00
mqttMessage.value = val
for (let key in val) {
if (String(key).includes('data') && String(key) != 'dataLevel' && String(key) != 'dataTime') {
const numberPart = parseInt(key.replace('data', ''));
if (selectValue.value != '3') {
if (selectValue.value == '2') {
if (activeName.value == 2) {
if (numberPart % 2 !== 0) {
tableData.value[key] = val[key]
}
} else {
if (numberPart % 2 === 0) {
tableData.value[key] = val[key]
}
}
} else {
if (activeName.value == 2) {
if (numberPart % 2 === 0) {
tableData.value[key] = val[key]
}
} else {
if (numberPart % 2 !== 0) {
tableData.value[key] = val[key]
}
}
}
} else {
tableData.value[key] = val[key]
}
2024-10-14 20:39:01 +08:00
}
}
if (!tabsList.value[activeName.value].groupName.includes('间谐波')) {
2024-10-24 16:18:52 +08:00
delete tableData.value.data1
} else {
console.log('不删除')
}
2024-10-23 14:37:11 +08:00
if (Object.keys(tableData.value).length != 0) {
2024-10-21 19:00:52 +08:00
init()
2024-10-24 16:18:52 +08:00
loading.value = false
2024-10-21 19:00:52 +08:00
} else {
emit('changeTrendType', activeName.value)
}
2024-10-14 20:39:01 +08:00
}
2024-12-09 16:30:40 +08:00
const selectChange=(val:any)=>{
loading.value=true
// setTimeout(() => {
// loading.value=false
// },3000)
}
2024-10-14 20:39:01 +08:00
//获取国标限值
const limitData: any = ref()
const setOverLimitData = (val: any) => {
limitData.value = {}
for (let key in val) {
if (activeName.value == 0) {
if (String(key).includes('uharm')) {
if (key.startsWith('uharm')) {
limitData.value[key] = val[key];
}
}
} else if (activeName.value == 1) {
if (String(key).includes('iharm')) {
limitData.value[key] = val[key]
}
} else {
if (String(key).includes('inuharm')) {
limitData.value[key] = val[key]
}
2024-10-14 15:09:58 +08:00
}
2024-10-14 15:09:58 +08:00
}
2024-10-14 15:09:58 +08:00
}
onMounted(() => { })
2024-10-14 20:39:01 +08:00
defineExpose({ open, setRealTrendData, setOverLimitData })
2024-07-22 10:35:01 +08:00
</script>
<style lang="scss" scoped>
.realtrend {
width: 100%;
height: 100%;
position: relative;
.select {
position: absolute;
2024-12-23 11:30:28 +08:00
top: -36px;
2024-11-27 16:01:08 +08:00
display: flex;
align-items: center;
font-size: 14px;
}
2024-09-27 16:22:34 +08:00
2024-07-31 10:42:04 +08:00
.realtrend_top {
2024-07-22 10:35:01 +08:00
width: 100%;
height: auto;
2024-07-31 10:42:04 +08:00
display: flex;
justify-content: space-between;
align-items: center;
2024-09-27 16:22:34 +08:00
2024-07-31 10:42:04 +08:00
.table {
flex: 1;
// min-height: 80px;
cursor: pointer;
min-height: 90px;
max-height: 170px;
border: 1px solid #eee;
overflow-x: auto;
overflow-y: hidden;
position: relative;
2024-09-27 16:22:34 +08:00
2024-07-31 10:42:04 +08:00
ul {
width: auto;
2024-07-22 10:35:01 +08:00
height: 40px;
display: flex;
2024-09-27 16:22:34 +08:00
2024-07-31 10:42:04 +08:00
li {
flex: none;
width: 100px;
2024-07-22 10:35:01 +08:00
line-height: 40px;
2024-07-31 10:42:04 +08:00
border: 1px solid #eee;
2024-07-22 10:35:01 +08:00
text-align: center;
2024-07-31 10:42:04 +08:00
list-style: none;
2024-07-22 10:35:01 +08:00
}
2024-07-31 10:42:04 +08:00
}
2024-09-27 16:22:34 +08:00
2024-07-31 10:42:04 +08:00
ul:nth-child(1) {
li {
font-weight: 800;
background: #f4f6f9;
2024-07-22 10:35:01 +08:00
}
}
}
2024-09-27 16:22:34 +08:00
// .table::-webkit-scrollbar {
// display: none;
// }
2024-10-14 15:09:58 +08:00
.realtrend_table {
2024-10-14 15:09:58 +08:00
width: 100%;
2024-10-14 20:39:01 +08:00
height: auto;
max-height: 150px;
2024-10-14 15:09:58 +08:00
display: flex;
2024-10-14 20:39:01 +08:00
border: 2px solid #eee;
cursor: pointer;
2024-12-09 16:30:40 +08:00
font-size: 13px;
2024-10-14 15:09:58 +08:00
.thead_left {
2024-10-14 20:39:01 +08:00
width: 150px;
2024-10-14 15:09:58 +08:00
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
line-height: 50px;
2024-12-09 16:30:40 +08:00
2024-10-29 15:46:35 +08:00
padding-bottom: 5px;
2024-10-14 20:39:01 +08:00
p {
width: 100%;
height: 100%;
text-align: center;
border: 1px solid #eee;
2024-12-09 16:30:40 +08:00
line-height: 38px;
2024-10-14 20:39:01 +08:00
margin: 0 !important;
}
2024-10-14 15:09:58 +08:00
}
2024-10-14 15:09:58 +08:00
.thead_right {
flex: 1;
align-items: center;
overflow-x: auto;
2024-10-14 20:39:01 +08:00
overflow-y: hidden;
2024-10-14 15:09:58 +08:00
display: flex;
padding-bottom: 5px;
2024-10-14 15:09:58 +08:00
.right_cell {
width: 100%;
display: flex;
flex-direction: column;
2024-10-14 15:09:58 +08:00
p {
flex: none;
min-width: 60px;
2024-10-14 15:09:58 +08:00
height: 100%;
2024-10-14 20:39:01 +08:00
text-align: center;
border: 1px solid #eee;
2024-12-09 16:30:40 +08:00
line-height: 38px;
2024-10-14 20:39:01 +08:00
margin: 0 !important;
}
2024-10-14 20:39:01 +08:00
p:nth-child(1) {
font-weight: 800;
2024-10-14 15:09:58 +08:00
}
}
}
}
2024-07-22 10:35:01 +08:00
}
}
2024-09-27 16:22:34 +08:00
2024-07-22 10:35:01 +08:00
.reverse-table .vxe-body--row .vxe-body--column:first-child {
background-color: #f8f8f9;
}
2024-09-27 16:22:34 +08:00
2024-07-22 10:35:01 +08:00
::v-deep .vxe-table--render-wrapper {
height: 90px !important;
max-height: 90px !important;
overflow-x: auto !important;
min-height: 0 !important;
}
2024-09-27 16:22:34 +08:00
2024-07-22 10:35:01 +08:00
::v-deep .body--wrapper {
height: 90px !important;
max-height: 90px !important;
min-height: 0 !important;
}
2024-09-27 16:22:34 +08:00
2024-07-22 10:35:01 +08:00
.tab_info {
width: 100%;
2024-10-22 15:01:41 +08:00
// height: calc(100vh - 450px);
2024-07-22 10:35:01 +08:00
// overflow: auto;
// padding-bottom: 20px;
.charts {
width: 100%;
margin-top: 10px;
2024-10-22 15:01:41 +08:00
height: calc(100vh - 560px);
2024-07-22 10:35:01 +08:00
}
}
:deep(.el-select) {
min-width: 100px;
}
2024-07-22 10:35:01 +08:00
</style>