emcp/frontend/src/views/eventReport/index.vue

199 lines
6.2 KiB
Vue
Raw Normal View History

2026-05-18 12:39:57 +08:00
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
2026-05-18 18:31:31 +08:00
import { fetchAlarmHistory } from '@/api/platform'
2026-05-19 10:46:30 +08:00
const formData: any = ref({
2026-05-18 18:31:31 +08:00
no: null,
type: '',
2026-05-18 12:39:57 +08:00
timeRange: [],
})
2026-05-18 18:31:31 +08:00
const tableData: any = ref([])
2026-05-18 12:39:57 +08:00
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
})
const handleQuery = () => {
2026-05-18 18:31:31 +08:00
const params: any = {
page: pagination.value.currentPage,
size: pagination.value.pageSize,
2026-05-19 09:14:37 +08:00
type: formData.value.type,
}
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
}
fetchAlarmHistory(params).then((res: any) => {
tableData.value = res
})
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-05-19 09:14:37 +08:00
handleQuery()
2026-05-18 12:39:57 +08:00
}
function init() {
2026-05-18 18:31:31 +08:00
const params: any = {
page: pagination.value.currentPage,
size: pagination.value.pageSize,
2026-05-19 10:46:30 +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
}
fetchAlarmHistory(params).then((res: any) => {
tableData.value = res
})
2026-05-18 12:39:57 +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-05-18 18:31:31 +08:00
formData.value.no = null
formData.value.type = ''
2026-05-19 10:46:30 +08:00
formData.value.timeRange = getDefaultTimeRange()
2026-05-18 12:39:57 +08:00
init()
})
</script>
<template>
<div class="event-report-container">
<div class="search-box">
2026-05-19 09:14:37 +08:00
<!-- <el-select v-model="formData.no" placeholder="所属线路" style="width: 180px">
2026-05-18 12:39:57 +08:00
<el-option label="线路一" value="线路一" />
<el-option label="线路二" value="线路二" />
2026-05-19 09:14:37 +08:00
</el-select> -->
<!-- <el-select v-model="formData.type" placeholder="事件类型" style="width: 180px; margin-left: 15px">
2026-05-18 12:39:57 +08:00
<el-option label="操作事件" value="操作事件" />
<el-option label="报警事件" value="报警事件" />
2026-05-19 09:14:37 +08:00
</el-select> -->
<el-input v-model="formData.type" placeholder="请输入事件类型" style="width: 180px" />
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">
<el-table :data="tableData" style="width: 100%; height: calc(100vh - 280px)" header-align="center"
align="center">
2026-05-18 18:31:31 +08:00
<el-table-column label="序号" type="index" width="80" align="center" />
<el-table-column label="事件所属" prop="belong">
<template #default="scope">
<span v-if="scope.row.alarm_type === 'line_alarm'">线路{{ scope.row.no }}</span>
<span v-else-if="scope.row.alarm_type === 'ai_alarm'">通道{{ scope.row.no }}</span>
<span v-else-if="scope.row.alarm_type === 'operate_alarm'">{{ scope.row.no }}</span>
</template>
</el-table-column>
<el-table-column label="事件类型" prop="type" align="center" />
2026-05-19 09:14:37 +08:00
<el-table-column label="事件等级" prop="level" width="80" align="center" />
<el-table-column label="事件详情" prop="content" min-width="120px" align="center" />
<el-table-column label="发生时间" prop="time" min-width="100px" 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%;
padding: 20px;
}
.search-box {
background: #fff;
border-radius: 6px;
padding: 20px;
box-shadow: 0px 0px 10px rgba(219, 225, 236, 1);
margin-bottom: 20px;
display: flex;
align-items: center;
height: 80px;
}
.table-box {
background: #fff;
border-radius: 4px;
padding: 20px;
box-shadow: 0 0 10px rgba(219, 225, 236, 1);
height: calc(100% - 100px);
}
.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;
}
</style>