2026-05-18 12:39:57 +08:00
|
|
|
<script setup lang="ts">
|
2026-06-26 18:06:50 +08:00
|
|
|
import { ref, onMounted } from 'vue'
|
2026-05-18 18:31:31 +08:00
|
|
|
import { fetchAlarmHistory } from '@/api/platform'
|
2026-06-26 18:06:50 +08:00
|
|
|
import type { AlarmEvent, AlarmHistoryQuery } from '@/types/platform'
|
|
|
|
|
import { formatAlarmEventValue, getAlarmBelongText, getEventCodeName, getEventTypeName } from '@/utils/alarmEvent'
|
|
|
|
|
|
|
|
|
|
type AlarmRow = AlarmEvent & {
|
|
|
|
|
belong_text: string
|
|
|
|
|
event_type_text: string
|
|
|
|
|
event_code_text: string
|
|
|
|
|
event_value_text: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const formData = ref<{
|
|
|
|
|
line_code: number | null
|
|
|
|
|
event_type: number | null
|
|
|
|
|
timeRange: string[]
|
|
|
|
|
}>({
|
|
|
|
|
line_code: null,
|
|
|
|
|
event_type: null,
|
2026-05-18 12:39:57 +08:00
|
|
|
timeRange: [],
|
|
|
|
|
})
|
|
|
|
|
|
2026-06-26 18:06:50 +08:00
|
|
|
const tableData = ref<AlarmRow[]>([])
|
2026-05-18 18:31:31 +08:00
|
|
|
const pagination = ref({
|
2026-05-18 12:39:57 +08:00
|
|
|
currentPage: 1,
|
|
|
|
|
pageSize: 10,
|
2026-05-18 18:31:31 +08:00
|
|
|
total: 0,
|
2026-05-18 12:39:57 +08:00
|
|
|
})
|
|
|
|
|
|
2026-06-26 18:06:50 +08:00
|
|
|
const loadAlarms = () => {
|
|
|
|
|
const params: AlarmHistoryQuery = {
|
2026-05-18 18:31:31 +08:00
|
|
|
page: pagination.value.currentPage,
|
|
|
|
|
size: pagination.value.pageSize,
|
2026-06-26 18:06:50 +08:00
|
|
|
}
|
|
|
|
|
if (formData.value.line_code !== null) {
|
|
|
|
|
params.line_code = formData.value.line_code
|
|
|
|
|
}
|
|
|
|
|
if (formData.value.event_type !== null) {
|
|
|
|
|
params.event_type = formData.value.event_type
|
2026-05-19 09:14:37 +08:00
|
|
|
}
|
|
|
|
|
if (formData.value.timeRange && formData.value.timeRange.length > 0) {
|
|
|
|
|
params.start_time = formData.value.timeRange[0]
|
|
|
|
|
params.end_time = formData.value.timeRange[1]
|
2026-05-18 18:31:31 +08:00
|
|
|
}
|
2026-06-26 18:06:50 +08:00
|
|
|
fetchAlarmHistory(params).then((res) => {
|
|
|
|
|
tableData.value = res.map((item) => ({
|
|
|
|
|
...item,
|
|
|
|
|
belong_text: getAlarmBelongText(item.line_code),
|
|
|
|
|
event_type_text: getEventTypeName(item.event_type),
|
|
|
|
|
event_code_text: getEventCodeName(item.event_type, item.event_code),
|
|
|
|
|
event_value_text: formatAlarmEventValue(item.event_type, item.event_value),
|
|
|
|
|
}))
|
|
|
|
|
pagination.value.total = tableData.value.length
|
2026-05-18 18:31:31 +08:00
|
|
|
})
|
2026-05-18 12:39:57 +08:00
|
|
|
}
|
|
|
|
|
|
2026-06-26 18:06:50 +08:00
|
|
|
const handleQuery = () => {
|
|
|
|
|
pagination.value.currentPage = 1
|
|
|
|
|
loadAlarms()
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-18 12:39:57 +08:00
|
|
|
const handleSizeChange = (val: number) => {
|
2026-05-18 18:31:31 +08:00
|
|
|
pagination.value.pageSize = val
|
|
|
|
|
pagination.value.currentPage = 1
|
2026-05-19 09:14:37 +08:00
|
|
|
handleQuery()
|
2026-05-18 12:39:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleCurrentChange = (val: number) => {
|
2026-05-18 18:31:31 +08:00
|
|
|
pagination.value.currentPage = val
|
2026-06-26 18:06:50 +08:00
|
|
|
loadAlarms()
|
2026-05-18 12:39:57 +08:00
|
|
|
}
|
2026-06-26 18:06:50 +08:00
|
|
|
|
2026-05-19 10:46:30 +08:00
|
|
|
const formatDate = (date: Date): string => {
|
|
|
|
|
const pad = (n: number): string => n.toString().padStart(2, '0')
|
|
|
|
|
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getDefaultTimeRange = (): [string, string] => {
|
|
|
|
|
const end = new Date()
|
|
|
|
|
const start = new Date()
|
|
|
|
|
start.setDate(start.getDate() - 7)
|
|
|
|
|
return [formatDate(start), formatDate(end)]
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-18 12:39:57 +08:00
|
|
|
onMounted(() => {
|
2026-06-26 18:06:50 +08:00
|
|
|
formData.value.line_code = null
|
|
|
|
|
formData.value.event_type = null
|
2026-05-19 10:46:30 +08:00
|
|
|
formData.value.timeRange = getDefaultTimeRange()
|
2026-06-26 18:06:50 +08:00
|
|
|
loadAlarms()
|
2026-05-18 12:39:57 +08:00
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<div class="event-report-container">
|
|
|
|
|
<div class="search-box">
|
2026-06-26 18:06:50 +08:00
|
|
|
<el-input-number v-model="formData.line_code" :min="0" :step="1" placeholder="请输入线路号" style="width: 180px" />
|
|
|
|
|
<el-input-number v-model="formData.event_type" :min="0" :step="1" placeholder="请输入事件类型" style="width: 180px; margin-left: 15px" />
|
2026-05-18 12:39:57 +08:00
|
|
|
<div>
|
|
|
|
|
<el-date-picker v-model="formData.timeRange" type="datetimerange" start-placeholder="开始时间"
|
|
|
|
|
end-placeholder="结束时间" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss"
|
|
|
|
|
style="width: 380px; margin-left: 15px" />
|
|
|
|
|
</div>
|
|
|
|
|
<el-button type="primary" style="margin-left: 15px;" @click="handleQuery">
|
|
|
|
|
查询
|
|
|
|
|
</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="table-box">
|
2026-05-26 15:11:03 +08:00
|
|
|
<el-table :data="tableData" style="width: 100%; height: calc(100vh - 260px)" header-align="center"
|
2026-05-18 12:39:57 +08:00
|
|
|
align="center">
|
2026-05-18 18:31:31 +08:00
|
|
|
<el-table-column label="序号" type="index" width="80" align="center" />
|
2026-06-26 18:06:50 +08:00
|
|
|
<el-table-column label="事件所属" prop="belong_text" align="center" />
|
|
|
|
|
<el-table-column label="事件类型" prop="event_type_text" align="center" />
|
|
|
|
|
<el-table-column label="事件代码" prop="event_code_text" align="center" min-width="140px" />
|
|
|
|
|
<el-table-column label="动作值" prop="event_value_text" align="center" />
|
2026-05-19 09:14:37 +08:00
|
|
|
<el-table-column label="事件详情" prop="content" min-width="120px" align="center" />
|
2026-06-26 18:06:50 +08:00
|
|
|
<el-table-column label="发生时间" prop="event_time" min-width="160px" align="center" />
|
2026-05-18 12:39:57 +08:00
|
|
|
</el-table>
|
|
|
|
|
<div class="pagination">
|
|
|
|
|
<el-pagination v-model:current-page="pagination.currentPage" v-model:page-size="pagination.pageSize"
|
|
|
|
|
:page-sizes="[10, 20, 30, 40]" @size-change="handleSizeChange" @current-change="handleCurrentChange"
|
2026-05-19 09:14:37 +08:00
|
|
|
:total="pagination.total" layout="prev, pager, next, sizes" />
|
2026-05-18 12:39:57 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
.event-report-container {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
2026-05-26 15:11:03 +08:00
|
|
|
padding: 15px;
|
2026-05-18 12:39:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.search-box {
|
|
|
|
|
background: #fff;
|
|
|
|
|
border-radius: 6px;
|
2026-05-26 15:11:03 +08:00
|
|
|
padding: 15px;
|
2026-05-18 12:39:57 +08:00
|
|
|
box-shadow: 0px 0px 10px rgba(219, 225, 236, 1);
|
2026-05-26 15:11:03 +08:00
|
|
|
margin-bottom: 15px;
|
2026-05-18 12:39:57 +08:00
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
2026-05-26 15:11:03 +08:00
|
|
|
height: 65px;
|
2026-05-18 12:39:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.table-box {
|
|
|
|
|
background: #fff;
|
|
|
|
|
border-radius: 4px;
|
2026-05-26 15:11:03 +08:00
|
|
|
padding: 15px;
|
2026-05-18 12:39:57 +08:00
|
|
|
box-shadow: 0 0 10px rgba(219, 225, 236, 1);
|
2026-05-26 15:11:03 +08:00
|
|
|
height: calc(100% - 80px);
|
2026-05-18 12:39:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.pagination {
|
|
|
|
|
margin-top: 15px;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: flex-start;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:deep(.el-table__header-wrapper) {
|
|
|
|
|
background-color: #f9fafe !important;
|
|
|
|
|
height: 46px;
|
|
|
|
|
line-height: 46px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:deep(.el-table__header) {
|
|
|
|
|
th {
|
|
|
|
|
background-color: #f9fafe !important;
|
|
|
|
|
font-weight: 700 !important;
|
|
|
|
|
font-size: 14px !important;
|
|
|
|
|
color: #333 !important;
|
|
|
|
|
border: none !important;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:deep(.el-table) {
|
|
|
|
|
--el-table-row-hover-bg-color: #f8f9fa !important;
|
|
|
|
|
--el-table-border-color: #f2f2f2 !important;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:deep(.el-table td) {
|
|
|
|
|
border-bottom: 1px solid #f2f2f2 !important;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:deep(.el-table__cell) {
|
|
|
|
|
color: #505050 !important;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:deep(.el-input__inner) {
|
|
|
|
|
color: #363636;
|
|
|
|
|
min-height: 40px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:deep(el-input__wrapper) {
|
|
|
|
|
min-height: 40px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:deep(.el-select__wrapper) {
|
|
|
|
|
min-height: 40px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:deep(.el-range-editor.el-input__wrapper) {
|
|
|
|
|
min-height: 40px;
|
|
|
|
|
}
|
2026-06-26 18:06:50 +08:00
|
|
|
</style>
|