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

249 lines
7.7 KiB
Vue
Raw Normal View History

<template>
<div>
<!--指标越限程度 -->
2026-04-24 09:13:48 +08:00
<TableHeader ref="TableHeaderRef" :showReset="false" @selectChange="selectChange" datePicker
:timeKeyList="prop.timeKey" v-if="fullscreen"></TableHeader>
<my-echart class="tall" :options="echartList"
:style="{ width: prop.width, height: `calc(${prop.height} / 2 )` }" />
<Table ref="tableRef" @cell-click="cellClickEvent"
:height="`calc(${prop.height} / 2 - ${headerHeight}px + ${fullscreen ? 0 : 56}px )`" isGroup></Table>
<!-- 指标日趋势图 -->
2026-02-04 09:35:24 +08:00
<HarmonicRatio ref="harmonicRatioRef" v-if="dialogFlag" @close="onHarmonicRatioClose" :showIndex="false" />
<!-- <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'
2026-02-04 09:35:24 +08:00
import { ElMessage, ElMessageBox } from 'element-plus'
import DailyTrendChart from '@/components/cockpit/exceedanceLevel/components/dailyTrendChart.vue'
2025-12-04 19:47:31 +08:00
import { getTime } from '@/utils/formatTime'
2026-02-04 09:35:24 +08:00
import HarmonicRatio from '@/components/cockpit/overLimitStatistics/components/harmonicRatio.vue'
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: Array as () => string[] },
2025-12-04 19:47:31 +08:00
timeValue: { type: Object },
interval: { type: Number }
})
2025-12-04 19:47:31 +08:00
const TableHeaderRef = ref()
const headerHeight = ref(57)
2026-02-04 09:35:24 +08:00
const harmonicRatioRef: any = ref(null)
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-12-01 09:33:12 +08:00
url: '/cs-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',
2025-12-09 15:21:42 +08:00
minWidth: '70',
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-12-09 15:21:42 +08:00
minWidth: '70',
formatter: (row: any) => {
2026-02-04 09:35:24 +08:00
return Math.floor(row.cellValue * 100) / 100
2025-11-14 16:18:38 +08:00
}
},
{
2025-11-18 14:54:52 +08:00
title: '越限时间',
2025-11-13 14:11:26 +08:00
field: 'time',
2025-11-14 09:34:39 +08:00
minWidth: '60',
formatter: (row: any) => {
return row.cellValue || '/'
2025-11-14 09:34:39 +08:00
}
},
{
title: '越限最高监测点',
2025-11-13 14:11:26 +08:00
field: 'lineName',
2025-11-14 09:34:39 +08:00
minWidth: '90',
formatter: (row: any) => {
return row.cellValue || '/'
2025-11-14 09:34:39 +08:00
}
}
],
2025-11-13 14:11:26 +08:00
beforeSearchFun: () => {
2025-12-04 19:47:31 +08:00
setTime()
},
loadCallback: () => {
2025-11-13 14:11:26 +08:00
// 定义 x 轴标签顺序
2026-02-04 09:35:24 +08:00
2025-11-13 14:11:26 +08:00
echartList.value = {
title: {
text: '指标越限严重度'
},
2025-11-13 14:11:26 +08:00
xAxis: {
2026-02-04 09:35:24 +08:00
data: tableStore.table.data.map((item: any) => item.name)
},
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: '越限占比',
2026-04-24 09:13:48 +08:00
data: tableStore.table.data.map((item: any) => Math.floor(item.extent * 100) / 100),
2025-11-13 14:11:26 +08:00
barMaxWidth: 30
}
]
}
2025-11-13 14:11:26 +08:00
}
}
})
const tableRef = ref()
provide('tableRef', tableRef)
provide('tableStore', tableStore)
2026-02-04 09:35:24 +08:00
const codeMap = [
2026-04-24 09:13:48 +08:00
{ key: '闪变', code: 'flickerOvertime' },
{ key: '电压偏差', code: 'voltageDevOvertime' },
{ key: '三相', code: 'ubalanceOvertime' },
{ key: '谐波电压', code: 'uharm' },
{ key: '谐波电流', code: 'iharm' },
2026-02-04 09:35:24 +08:00
];
// 点击行
const cellClickEvent = ({ row, column }: any) => {
2025-11-17 09:51:31 +08:00
dialogTrendChart.value = true
2026-04-24 09:13:48 +08:00
if (column.field == 'maxValue') {
if (row.lineId == null) {
ElMessage.info('暂无越限监测点!')
} else {
nextTick(() => {
// dailyTrendChartRef.value.open(row)
dialogFlag.value = true
nextTick(() => {
const code = codeMap.find(item => row.name.includes(item.key))?.code || '';
harmonicRatioRef.value.openDialog(row, code, column.title.replace(/次/g, ""))
})
})
2026-02-04 09:35:24 +08:00
}
}
}
2025-12-04 19:47:31 +08:00
const setTime = () => {
const time = getTime(
(TableHeaderRef.value?.datePickerRef.interval || prop.interval) ?? 0,
prop.timeKey,
fullscreen.value
? [tableStore.table.params.searchBeginTime, tableStore.table.params.searchEndTime]
: prop.timeValue
)
if (Array.isArray(time)) {
tableStore.table.params.searchBeginTime = time[0]
tableStore.table.params.searchEndTime = time[1]
TableHeaderRef.value?.setInterval(time[2] - 0)
TableHeaderRef.value?.setTimeInterval([time[0], time[1]])
} else {
console.warn('获取时间失败time 不是一个有效数组')
}
}
2026-04-24 09:13:48 +08:00
const dialogFlag = ref(false)
2026-02-04 09:35:24 +08:00
// 谐波弹窗关闭时的回调
const onHarmonicRatioClose = () => {
2026-04-24 09:13:48 +08:00
dialogFlag.value = false
2026-02-04 09:35:24 +08:00
// 重新打开指标越限详情弹窗
}
2025-12-04 19:47:31 +08:00
onMounted(() => {
tableStore.index()
})
watch(
() => prop.timeKey,
val => {
tableStore.index()
}
)
watch(
2025-11-14 14:09:34 +08:00
() => prop.timeValue,
(newVal, oldVal) => {
2025-12-04 19:47:31 +08:00
tableStore.index()
},
{
2025-11-14 14:09:34 +08:00
deep: true
}
)
2026-04-24 09:13:48 +08:00
const addMenu = () => { }
</script>
<style lang="scss" scoped></style>