2025-07-29 08:33:04 +08:00
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<!-- 全局暂降事件 -->
|
2025-07-31 15:55:33 +08:00
|
|
|
<el-drawer v-model="drawer" title="暂降事件" size="1050px" :before-close="handleClose">
|
2025-07-29 08:33:04 +08:00
|
|
|
<div :style="height">
|
|
|
|
|
<vxe-table
|
|
|
|
|
v-bind="defaultAttribute"
|
|
|
|
|
v-loading="isLoading"
|
|
|
|
|
height="100%"
|
|
|
|
|
ref="xTable1Ref"
|
|
|
|
|
:data="eventList"
|
|
|
|
|
>
|
|
|
|
|
<vxe-column type="seq" width="70px" title="序号"></vxe-column>
|
|
|
|
|
<vxe-column field="time" width="180px" sortable title="发生时刻"></vxe-column>
|
|
|
|
|
<vxe-column field="lineName" title="监测点"></vxe-column>
|
2025-07-31 15:55:33 +08:00
|
|
|
<vxe-column field="powerCompany" title="变电站" width="100px"></vxe-column>
|
|
|
|
|
<vxe-column field="powerCompany" title="供电公司" width="100px"></vxe-column>
|
|
|
|
|
<vxe-column field="persistTime" width="120px" sortable title="持续时间(s)">
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
{{ Math.floor(row.persistTime * 1000) / 1000 }}
|
|
|
|
|
</template>
|
|
|
|
|
</vxe-column>
|
2025-07-29 08:33:04 +08:00
|
|
|
<vxe-column field="eventValue" width="160px" sortable title="暂降(骤升)幅值(%)">
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
{{ Math.floor(row.eventValue * 10000) / 100 }}
|
|
|
|
|
</template>
|
|
|
|
|
</vxe-column>
|
2025-07-31 15:55:33 +08:00
|
|
|
<vxe-column field="eventType" width="100px" title="暂降类型">
|
2025-07-29 08:33:04 +08:00
|
|
|
<template #default="{ row }">
|
2025-07-30 15:17:28 +08:00
|
|
|
{{ event.filter(item => item.id == row.eventType)[0]?.name || '/' }}
|
2025-07-29 08:33:04 +08:00
|
|
|
</template>
|
|
|
|
|
</vxe-column>
|
|
|
|
|
</vxe-table>
|
|
|
|
|
</div>
|
|
|
|
|
</el-drawer>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { ref, reactive, onMounted } from 'vue'
|
|
|
|
|
import { defaultAttribute } from '@/components/table/defaultAttribute'
|
|
|
|
|
import { mainHeight } from '@/utils/layout'
|
|
|
|
|
import { useDictData } from '@/stores/dictData'
|
|
|
|
|
import MQTT from '@/utils/mqtt'
|
|
|
|
|
const dictData = useDictData()
|
2025-07-30 15:17:28 +08:00
|
|
|
const event = dictData.getBasicData('Event_Statis')
|
2025-07-29 08:33:04 +08:00
|
|
|
import { useAdminInfo } from '@/stores/adminInfo'
|
|
|
|
|
const adminInfo = useAdminInfo()
|
|
|
|
|
const height = mainHeight(-20)
|
|
|
|
|
const drawer = ref(false)
|
|
|
|
|
const isLoading = ref(false)
|
|
|
|
|
const eventList = ref([])
|
|
|
|
|
const open = () => {
|
|
|
|
|
drawer.value = true
|
|
|
|
|
}
|
|
|
|
|
const handleClose = (done: any) => {
|
|
|
|
|
drawer.value = false
|
|
|
|
|
done()
|
|
|
|
|
}
|
|
|
|
|
const init = async () => {
|
|
|
|
|
const mqttClient = new MQTT('/sendEvent')
|
|
|
|
|
// 设置消息接收回调
|
|
|
|
|
try {
|
|
|
|
|
await mqttClient.init()
|
|
|
|
|
|
|
|
|
|
// 订阅主题
|
|
|
|
|
await mqttClient.subscribe()
|
|
|
|
|
// 设置消息接收回调
|
|
|
|
|
mqttClient.onMessage((topic, message) => {
|
|
|
|
|
const msg = JSON.parse(message.toString())
|
2025-07-30 15:17:28 +08:00
|
|
|
console.log("🚀 ~ init ~ msg:", msg)
|
2025-07-29 08:33:04 +08:00
|
|
|
if (msg.deptList.includes(adminInfo.$state.deptId)) {
|
|
|
|
|
drawer.value = true
|
|
|
|
|
isLoading.value = true
|
|
|
|
|
eventList.value.unshift(msg)
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
isLoading.value = false
|
|
|
|
|
}, 500)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('MQTT 初始化失败:', error)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
// startMqtt('/sendEvent', (topic, message) => {
|
|
|
|
|
// const msg = JSON.parse(message.toString())
|
|
|
|
|
// console.log(msg)
|
|
|
|
|
// })
|
|
|
|
|
init()
|
|
|
|
|
})
|
|
|
|
|
defineExpose({
|
|
|
|
|
open,
|
|
|
|
|
eventList
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
<style lang="scss" scoped></style>
|