2025-10-20 13:25:30 +08:00
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<!--监测点列表 -->
|
2025-11-07 10:32:55 +08:00
|
|
|
<TableHeader :showReset="false" @selectChange="selectChange" datePicker v-if="fullscreen"></TableHeader>
|
|
|
|
|
<Table ref="tableRef" @cell-click="cellClickEvent" :height="`calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px )`"></Table>
|
2025-10-20 13:25:30 +08:00
|
|
|
<!-- 指标越限详情 -->
|
|
|
|
|
<OverLimitDetails ref="OverLimitDetailsRef" />
|
|
|
|
|
</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 { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
|
|
import { getTimeOfTheMonth } from '@/utils/formatTime'
|
|
|
|
|
import { ElTag } from 'element-plus'
|
2025-11-13 14:11:26 +08:00
|
|
|
import OverLimitDetails from '@/components/cockpit/monitoringPointList/components/overLimitDetails.vue'
|
2025-11-07 10:32:55 +08:00
|
|
|
import TableHeader from '@/components/table/header/index.vue'
|
|
|
|
|
import { useRoute } from 'vue-router'
|
|
|
|
|
import { useTimeCacheStore } from '@/stores/timeCache'
|
|
|
|
|
|
2025-10-20 13:25:30 +08:00
|
|
|
const prop = defineProps({
|
2025-11-07 10:32:55 +08:00
|
|
|
w: { type: String },
|
|
|
|
|
h: { type: String },
|
2025-10-20 13:25:30 +08:00
|
|
|
width: { type: String },
|
|
|
|
|
height: { type: String },
|
|
|
|
|
timeKey: { type: String },
|
|
|
|
|
timeValue: { type: Object }
|
|
|
|
|
})
|
2025-11-07 10:32:55 +08:00
|
|
|
|
|
|
|
|
const headerHeight = ref(57)
|
|
|
|
|
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
const timeCacheStore = useTimeCacheStore()
|
|
|
|
|
|
|
|
|
|
const selectChange = (showSelect: any, height: any, datePickerValue?: any) => {
|
|
|
|
|
headerHeight.value = height
|
|
|
|
|
|
|
|
|
|
// 如果有传入 datePicker 的值
|
|
|
|
|
if (datePickerValue) {
|
|
|
|
|
// 更新表格参数
|
|
|
|
|
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-10-20 13:25:30 +08:00
|
|
|
const OverLimitDetailsRef = ref()
|
|
|
|
|
const tableStore: any = new TableStore({
|
|
|
|
|
url: '/user-boot/role/selectRoleDetail?id=0',
|
|
|
|
|
method: 'POST',
|
|
|
|
|
|
|
|
|
|
showPage: false,
|
|
|
|
|
exportName: '主要监测点列表',
|
|
|
|
|
column: [
|
|
|
|
|
{
|
|
|
|
|
field: 'index',
|
|
|
|
|
title: '序号',
|
2025-10-21 16:11:00 +08:00
|
|
|
width: '80',
|
2025-10-20 13:25:30 +08:00
|
|
|
formatter: (row: any) => {
|
|
|
|
|
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '治理对象名称',
|
|
|
|
|
field: 'name',
|
|
|
|
|
minWidth: '80'
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
title: '电压等级',
|
|
|
|
|
field: 'type',
|
|
|
|
|
minWidth: '70'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '治理设备详情',
|
|
|
|
|
field: 'type1',
|
|
|
|
|
minWidth: '70'
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
title: '治理前报告',
|
|
|
|
|
field: 'type2',
|
|
|
|
|
minWidth: '80',
|
|
|
|
|
render: 'customTemplate',
|
|
|
|
|
customTemplate: (row: any) => {
|
2025-11-07 10:32:55 +08:00
|
|
|
return `<span style='cursor: pointer;text-decoration: underline;' onclick="handleReportClick('${row.name}')">${row.type2}</span>`
|
|
|
|
|
}
|
2025-10-20 13:25:30 +08:00
|
|
|
},
|
|
|
|
|
{ title: '监测点名称', field: 'type3', minWidth: '70' },
|
|
|
|
|
{ title: '监测类型', field: 'type4', minWidth: '60' },
|
|
|
|
|
{
|
|
|
|
|
title: '监测点状态',
|
|
|
|
|
field: 'type5',
|
|
|
|
|
minWidth: '60',
|
|
|
|
|
render: 'customTemplate',
|
|
|
|
|
customTemplate: (row: any) => {
|
|
|
|
|
return `<span style='color: ${row.type5 === '中断' ? '#FF0000' : ''}'>${row.type5}</span>`
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{ title: '最新数据时间', field: 'type6', minWidth: '140' }
|
|
|
|
|
],
|
|
|
|
|
beforeSearchFun: () => {
|
2025-11-07 10:32:55 +08:00
|
|
|
// 尝试从缓存获取时间值
|
|
|
|
|
let beginTime, endTime
|
|
|
|
|
|
|
|
|
|
if (fullscreen.value) {
|
|
|
|
|
const cached = timeCacheStore.getCache(route.path)
|
|
|
|
|
if (cached && cached.timeValue) {
|
|
|
|
|
beginTime = cached.timeValue[0]
|
|
|
|
|
endTime = cached.timeValue[1]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 如果缓存中没有则使用默认值
|
|
|
|
|
tableStore.table.params.searchBeginTime = beginTime || prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0]
|
|
|
|
|
|
|
|
|
|
tableStore.table.params.searchEndTime = endTime || prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
|
2025-10-20 13:25:30 +08:00
|
|
|
},
|
|
|
|
|
loadCallback: () => {
|
|
|
|
|
tableStore.table.data = [
|
|
|
|
|
{
|
|
|
|
|
name: '1#变压器',
|
|
|
|
|
type: '0.38kV',
|
|
|
|
|
type1: '250A APF',
|
|
|
|
|
type2: '报告.doc',
|
|
|
|
|
type3: '1#变压器 电网侧',
|
|
|
|
|
type4: '电网侧',
|
|
|
|
|
type5: '运行',
|
|
|
|
|
type6: '2025-04-11 18:16:00'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '1#变压器',
|
|
|
|
|
type: '0.38kV',
|
|
|
|
|
type1: '250A APF',
|
|
|
|
|
type2: '报告.doc',
|
|
|
|
|
type3: '1#变压器 负载侧',
|
|
|
|
|
type4: '负载侧',
|
|
|
|
|
type5: '运行',
|
|
|
|
|
type6: '2025-04-11 18:16:00'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '2#变压器',
|
|
|
|
|
type: '0.38kV',
|
|
|
|
|
type1: '100A SVG',
|
|
|
|
|
type2: '/',
|
|
|
|
|
type3: '1#变压器 电网侧',
|
|
|
|
|
type4: '电网侧',
|
|
|
|
|
type5: '运行',
|
|
|
|
|
type6: '2025-04-11 18:16:00'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '2#变压器',
|
|
|
|
|
type: '0.38kV',
|
|
|
|
|
type1: '100A SVG',
|
|
|
|
|
type2: '/',
|
|
|
|
|
type3: '1#变压器 负载侧',
|
|
|
|
|
type4: '负载侧',
|
|
|
|
|
type5: '中断',
|
|
|
|
|
type6: '2025-04-11 18:16:00'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
tableStore.table.height = `calc(${prop.height} - 80px)`
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const tableRef = ref()
|
|
|
|
|
provide('tableRef', tableRef)
|
|
|
|
|
tableStore.table.params.type = ''
|
|
|
|
|
tableStore.table.params.searchValue = ''
|
|
|
|
|
provide('tableStore', tableStore)
|
|
|
|
|
|
|
|
|
|
// 点击行
|
|
|
|
|
const cellClickEvent = ({ row, column }: any) => {
|
|
|
|
|
if (column.field == 'name') {
|
|
|
|
|
console.log(row)
|
|
|
|
|
OverLimitDetailsRef.value.open(row)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
tableStore.index()
|
|
|
|
|
})
|
|
|
|
|
watch(
|
|
|
|
|
() => prop.timeKey,
|
|
|
|
|
val => {
|
|
|
|
|
tableStore.index()
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
watch(
|
|
|
|
|
() => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告)
|
|
|
|
|
(newVal, oldVal) => {
|
|
|
|
|
tableStore.index()
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
deep: true // 若 timeValue 是对象/数组,需开启深度监听
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
2025-10-28 11:23:17 +08:00
|
|
|
const handleReportClick = (id: string) => {
|
2025-11-07 10:32:55 +08:00
|
|
|
const row = tableStore.table.data.find((item: any) => item.id === id)
|
|
|
|
|
if (row && row.type2 !== '/') {
|
|
|
|
|
// 示例:触发下载逻辑(根据你注释掉的代码)
|
|
|
|
|
// getFileZip({ eventId: id }).then(res => {
|
|
|
|
|
// let blob = new Blob([res], { type: 'application/zip' })
|
|
|
|
|
// const url = window.URL.createObjectURL(blob)
|
|
|
|
|
// const link = document.createElement('a')
|
|
|
|
|
// link.href = url
|
|
|
|
|
// link.download = row.wavePath?.split('/')[2] || '报告文件.zip'
|
|
|
|
|
// link.click()
|
|
|
|
|
// })
|
|
|
|
|
console.log('点击了报告:', row.type2)
|
|
|
|
|
} else {
|
|
|
|
|
ElMessage.warning('暂无报告可下载')
|
|
|
|
|
}
|
2025-10-28 11:23:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 挂载到 window 供 HTML 调用
|
|
|
|
|
window.handleReportClick = handleReportClick
|
|
|
|
|
|
|
|
|
|
// 组件销毁时清理全局方法
|
|
|
|
|
onBeforeUnmount(() => {
|
2025-11-07 10:32:55 +08:00
|
|
|
delete window.handleReportClick
|
2025-10-28 11:23:17 +08:00
|
|
|
})
|
2025-10-20 13:25:30 +08:00
|
|
|
</script>
|
|
|
|
|
<style lang="scss" scoped></style>
|