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

253 lines
7.7 KiB
Vue
Raw Normal View History

<template>
<div>
<!--暂态事件统计 -->
<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 - ${headerHeight / 2}px + ${fullscreen ? 0 : 28}px )`
}"
/>
<Table
ref="tableRef"
@cell-click="cellClickEvent"
:height="`calc(${prop.height} / 2 - ${headerHeight / 2}px + ${fullscreen ? 0 : 28}px )`"
isGroup
></Table>
<TransientStatisticsDetail ref="transientStatisticsDetailRef"></TransientStatisticsDetail>
</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 MyEchart from '@/components/echarts/MyEchart.vue'
import { useConfig } from '@/stores/config'
2025-11-13 14:11:26 +08:00
import TransientStatisticsDetail from '@/components/cockpit/transientStatistics/components/transientStatisticsDetail.vue'
import TableHeader from '@/components/table/header/index.vue'
2025-11-25 10:14:50 +08:00
import { netEventEcharts } from '@/api/harmonic-boot/cockpit/cockpit'
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)
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
}
})
const config = useConfig()
2025-11-25 10:14:50 +08:00
const data = ref()
2025-11-25 10:14:50 +08:00
const echartList = ref()
const eventEcharts = () => {
netEventEcharts({
searchBeginTime: tableStore.table.params.searchBeginTime || prop.timeValue?.[0],
searchEndTime: tableStore.table.params.searchEndTime || prop.timeValue?.[1]
}).then(res => {
// 整理接口数据为图表所需格式
2025-11-26 15:37:56 +08:00
const rawData = res.data || {}
2025-11-25 10:14:50 +08:00
data.value = [
{
2025-11-25 10:14:50 +08:00
name: '电压中断',
value: rawData.eventOff || 0
},
{
2025-11-25 10:14:50 +08:00
name: '电压暂降',
value: rawData.eventDown || 0
},
{
2025-11-25 10:14:50 +08:00
name: '电压暂升',
value: rawData.eventUp || 0
}
2025-11-26 15:37:56 +08:00
]
2025-11-25 10:14:50 +08:00
echartList.value = {
title: {},
tooltip: {
trigger: 'item'
},
legend: {
orient: 'vertical',
top: 'center',
right: '5%',
formatter: function (e: any) {
return e + ' ' + data.value.filter((item: any) => item.name == e)[0].value + '次'
}
},
xAxis: {
show: false
},
yAxis: {
show: false
},
grid: {
left: '10px',
right: '20px'
},
color: ['#FF9100', '#FFBF00', config.layout.elementUiPrimary[0]],
options: {
dataZoom: null,
title: [
{
text: '暂态事件统计',
left: 'center'
},
{
2025-11-26 15:37:56 +08:00
text: rawData.eventOff + rawData.eventDown + rawData.eventUp + '次',
2025-11-25 10:14:50 +08:00
left: 'center',
top: 'center'
}
2025-11-25 10:14:50 +08:00
],
series: [
{
type: 'pie',
center: 'center',
radius: ['50%', '70%'],
label: {
show: false,
position: 'outside'
},
name: '事件统计',
data: data.value
}
]
}
2025-11-25 10:14:50 +08:00
}
})
}
const transientStatisticsDetailRef = ref()
2025-11-25 10:14:50 +08:00
const tableStore: any = new TableStore({
2025-11-25 10:14:50 +08:00
url: '/cs-harmonic-boot/csevent/netEventTable',
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-25 10:14:50 +08:00
field: 'eventOff',
minWidth: '70',
2025-11-26 15:37:56 +08:00
sortable: true,
render: 'customTemplate',
customTemplate: (row: any) => {
2025-11-25 10:14:50 +08:00
return `<span style='cursor: pointer;text-decoration: underline;'>${row.eventOff}</span>`
}
},
{
title: '电压暂降(次)',
2025-11-25 10:14:50 +08:00
field: 'eventDown',
minWidth: '80',
2025-11-26 15:37:56 +08:00
sortable: true,
render: 'customTemplate',
customTemplate: (row: any) => {
2025-11-25 10:14:50 +08:00
return `<span style='cursor: pointer;text-decoration: underline;'>${row.eventDown}</span>`
}
},
{
title: '电压暂升(次)',
2025-11-25 10:14:50 +08:00
field: 'eventUp',
minWidth: '80',
2025-11-26 15:37:56 +08:00
sortable: true,
render: 'customTemplate',
customTemplate: (row: any) => {
2025-11-25 10:14:50 +08:00
return `<span style='cursor: pointer;text-decoration: underline;'>${row.eventUp}</span>`
}
}
],
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-25 10:14:50 +08:00
eventEcharts()
}
})
const tableRef = ref()
provide('tableRef', tableRef)
provide('tableStore', tableStore)
// 点击行
const cellClickEvent = ({ row, column }: any) => {
if (column.field != 'name') {
2025-11-26 15:37:56 +08:00
transientStatisticsDetailRef.value.open(
row,
tableStore.table.params.searchBeginTime || prop.timeValue?.[0],
tableStore.table.params.searchEndTime || prop.timeValue?.[1]
)
}
}
onMounted(() => {
setTimeout(() => {
tableStore.index()
}, 200)
})
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
}
)
</script>
<style lang="scss" scoped></style>