Files
admin-govern/src/components/cockpit/exceedanceLevel/index.vue

237 lines
7.6 KiB
Vue
Raw Normal View History

<template>
<div>
<!--指标越限程度 -->
2025-11-13 14:11:26 +08:00
<TableHeader :showReset="false" @selectChange="selectChange" datePicker v-if="fullscreen"></TableHeader>
<my-echart
class="tall"
:options="echartList"
:style="{ width: prop.width, height: `calc(${prop.height} / 2 )` }"
/>
2025-11-13 14:11:26 +08:00
<Table
ref="tableRef"
@cell-click="cellClickEvent"
:height="`calc(${prop.height} / 2 - ${headerHeight}px + ${fullscreen ? 0 : 56}px )`"
isGroup
></Table>
<!-- 指标日趋势图 -->
2025-11-17 09:51:31 +08:00
<DailyTrendChart v-if="dialogTrendChart" ref="dailyTrendChartRef" @close="dialogTrendChart = false" />
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'
import MyEchart from '@/components/echarts/MyEchart.vue'
import { getTimeOfTheMonth } from '@/utils/formatTime'
import DailyTrendChart from '@/components/cockpit/exceedanceLevel/components/dailyTrendChart.vue'
import { useRoute } from 'vue-router'
import { useTimeCacheStore } from '@/stores/timeCache'
const prop = defineProps({
2025-11-14 14:09:34 +08:00
w: { type: [String, Number] },
h: { type: [String, Number] },
width: { type: [String, Number] },
height: { type: [String, Number] },
timeKey: { type: [String, Number] },
timeValue: { type: Object }
})
const headerHeight = ref(57)
2025-11-17 09:51:31 +08:00
const dialogTrendChart = ref(false)
const selectChange = (showSelect: any, height: any, datePickerValue?: any) => {
headerHeight.value = height
2025-11-14 14:09:34 +08:00
if (datePickerValue && datePickerValue.timeValue) {
// 更新时间参数
tableStore.table.params.searchBeginTime = datePickerValue.timeValue[0]
tableStore.table.params.searchEndTime = datePickerValue.timeValue[1]
}
}
// 计算是否全屏展示
const fullscreen = computed(() => {
const w = Number(prop.w)
const h = Number(prop.h)
if (!isNaN(w) && !isNaN(h) && w === 12 && h === 6) {
// 执行相应逻辑
return true
} else {
return false
}
})
2025-11-13 14:11:26 +08:00
const echartList = ref()
const dailyTrendChartRef = ref()
const tableStore: any = new TableStore({
2025-11-13 14:11:26 +08:00
url: '/harmonic-boot/limitRateDetailD/limitExtentData',
method: 'POST',
showPage: false,
column: [
{
field: 'index',
title: '序号',
2025-10-21 16:11:00 +08:00
width: '80',
formatter: (row: any) => {
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
}
},
{
title: '指标名称',
field: 'name',
minWidth: '90'
},
{
title: '越限最大值',
2025-11-13 14:11:26 +08:00
field: 'maxValue',
minWidth: '60',
render: 'customTemplate',
customTemplate: (row: any) => {
2025-11-14 16:18:38 +08:00
const extentValue =
row.maxValue !== null && row.maxValue !== undefined && row.maxValue !== ''
? Math.floor(row.maxValue * 100) / 100
: '/'
return `<span style='cursor: pointer;text-decoration: underline;'>${extentValue}</span>`
}
},
{
title: '国标限值',
2025-11-13 14:11:26 +08:00
field: 'internationalValue',
minWidth: '60'
},
{
title: '越限程度(%)',
2025-11-13 14:11:26 +08:00
field: 'extent',
2025-11-14 16:18:38 +08:00
minWidth: '60',
render: 'customTemplate',
customTemplate: (row: any) => {
// 保留两个小数
const extentValue =
row.extent !== null && row.extent !== undefined && row.extent !== ''
? Math.floor(row.extent * 100) / 100
: '/'
return `<span>${extentValue}</span>`
}
},
{
title: '发生日期',
2025-11-13 14:11:26 +08:00
field: 'time',
2025-11-14 09:34:39 +08:00
minWidth: '60',
render: 'customTemplate',
customTemplate: (row: any) => {
2025-11-14 14:09:34 +08:00
if (row.time !== null && row.time !== undefined && row.time !== '') {
2025-11-14 09:34:39 +08:00
return `<span>${row.time}</span>`
} else {
return `<span>/</span>`
}
}
},
{
title: '越限最高监测点',
2025-11-13 14:11:26 +08:00
field: 'lineName',
2025-11-14 09:34:39 +08:00
minWidth: '90',
render: 'customTemplate',
customTemplate: (row: any) => {
if (row.lineName !== null && row.lineName !== undefined && row.lineName !== '') {
return `<span>${row.lineName}</span>`
} else {
return `<span>/</span>`
}
}
}
],
2025-11-13 14:11:26 +08:00
beforeSearchFun: () => {
2025-11-14 14:09:34 +08:00
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
},
loadCallback: () => {
2025-11-13 14:11:26 +08:00
// 定义 x 轴标签顺序
const xAxisLabels = ['闪变', '谐波电压', '谐波电流', '电压偏差', '三相不平衡']
2025-11-14 09:34:39 +08:00
// 根据指标名称顺序提取对应的 extent 数据
2025-11-13 14:11:26 +08:00
const chartData = xAxisLabels.map(label => {
// 在表格数据中查找对应指标名称的数据项
const item = tableStore.table.data.find((row: any) => row.name === label)
2025-11-14 16:18:38 +08:00
// 如果找到对应项,则返回 extent 值,否则返回 0并保留两位小数
const extentValue = item ? item.extent || 0 : 0
return Math.round(extentValue * 100) / 100
2025-11-13 14:11:26 +08:00
})
echartList.value = {
title: {
text: '指标越限严重度'
},
2025-11-13 14:11:26 +08:00
xAxis: {
data: xAxisLabels
},
2025-11-13 14:11:26 +08:00
yAxis: {
2025-11-14 09:34:39 +08:00
name: '%' // 给X轴加单位
// interval: 20
},
2025-11-13 14:11:26 +08:00
grid: {
left: '10px',
right: '20px'
},
2025-11-13 14:11:26 +08:00
options: {
series: [
{
type: 'bar',
name: '越限占比',
data: chartData,
barMaxWidth: 30
}
]
}
2025-11-13 14:11:26 +08:00
}
}
})
const tableRef = ref()
provide('tableRef', tableRef)
provide('tableStore', tableStore)
// 点击行
const cellClickEvent = ({ row, column }: any) => {
2025-11-17 09:51:31 +08:00
dialogTrendChart.value = true
2025-11-14 09:34:39 +08:00
if (column.field == 'maxValue' && row.lineId) {
2025-11-17 09:51:31 +08:00
nextTick(() => {
dailyTrendChartRef.value.open(row)
})
}
}
onMounted(() => {
tableStore.index()
})
watch(
() => prop.timeKey,
val => {
tableStore.index()
}
)
watch(
2025-11-14 14:09:34 +08:00
() => prop.timeValue,
(newVal, oldVal) => {
2025-11-14 14:09:34 +08:00
// 当外部时间值变化时,更新表格的时间参数
if (newVal && (!oldVal || newVal[0] !== oldVal[0] || newVal[1] !== oldVal[1])) {
tableStore.table.params.searchBeginTime = newVal[0]
tableStore.table.params.searchEndTime = newVal[1]
tableStore.index()
}
},
{
2025-11-14 14:09:34 +08:00
deep: true
}
)
const addMenu = () => {}
</script>
<style lang="scss" scoped></style>