77 lines
5.7 KiB
Vue
77 lines
5.7 KiB
Vue
<template>
|
||
<BasicLayout>
|
||
<template #wrapper>
|
||
<el-card class="box-card">
|
||
<template #header><div class="page-heading"><h2>预警管理</h2><p>先开始处理,再记录现场结果完成预警。</p></div></template>
|
||
<el-form ref="queryForm" :model="query" :inline="true">
|
||
<el-form-item label="状态" prop="status"><el-select v-model="query.status" clearable placeholder="全部状态" style="width:130px"><el-option label="待处理" value="open" /><el-option label="处理中" value="acknowledged" /><el-option label="已完成" value="closed" /></el-select></el-form-item>
|
||
<el-form-item label="风险" prop="severity"><el-select v-model="query.severity" clearable placeholder="全部风险" style="width:130px"><el-option v-for="item in severities" :key="item.value" :label="item.label" :value="item.value" /></el-select></el-form-item>
|
||
<el-form-item label="地点" prop="location"><el-input v-model="query.location" clearable placeholder="请输入地点" @keyup.enter="search" /></el-form-item>
|
||
<el-form-item><el-button type="primary" @click="search">搜索</el-button><el-button @click="reset">重置</el-button></el-form-item>
|
||
</el-form>
|
||
<el-alert v-if="error" :title="error" type="error" show-icon :closable="false" class="state-alert" />
|
||
<el-table v-loading="loading" :data="items" border row-key="id" @row-dblclick="openDetail">
|
||
<el-table-column prop="createdAt" label="创建时间" min-width="180"><template #default="scope">{{ parseTime(scope.row.createdAt) }}</template></el-table-column>
|
||
<el-table-column prop="summary" label="预警事项" min-width="200" show-overflow-tooltip />
|
||
<el-table-column prop="location" label="地点" min-width="140" show-overflow-tooltip />
|
||
<el-table-column label="风险" width="90"><template #default="scope"><el-tag :type="severityType(scope.row.severity)">{{ severityName(scope.row.severity) }}</el-tag></template></el-table-column>
|
||
<el-table-column label="状态" width="90"><template #default="scope"><el-tag :type="statusType(scope.row.status)">{{ statusName(scope.row.status) }}</el-tag></template></el-table-column>
|
||
<el-table-column prop="eventCount" label="关联事件" width="100" />
|
||
<el-table-column label="操作" width="90"><template #default="scope"><el-button type="primary" link @click="openDetail(scope.row)">详情</el-button></template></el-table-column>
|
||
<template #empty><el-empty description="暂无预警" /></template>
|
||
</el-table>
|
||
<pagination v-show="total > 0" v-model:current-page="query.pageIndex" v-model:page-size="query.pageSize" :total="total" @pagination="load" />
|
||
</el-card>
|
||
|
||
<el-drawer v-model="drawer" title="预警详情" size="min(720px, 100%)">
|
||
<div v-loading="detailLoading">
|
||
<el-alert v-if="detailError" :title="detailError" type="error" show-icon :closable="false" class="state-alert" />
|
||
<BellAlertDetail v-if="detail && lifecycle" :detail="detail" :lifecycle="lifecycle" @changed="reloadDetail" @go-event="goEvent" />
|
||
</div>
|
||
</el-drawer>
|
||
</template>
|
||
</BasicLayout>
|
||
</template>
|
||
|
||
<script>
|
||
import { getAlert, listAlerts } from '@/api/bell/alert'
|
||
import { getAlertLifecycle } from '@/api/bell/alert-lifecycle'
|
||
import BellAlertDetail from './detail.vue'
|
||
|
||
export default {
|
||
name: 'BellAlerts',
|
||
components: { BellAlertDetail },
|
||
data() {
|
||
return {
|
||
loading: false, detailLoading: false, error: '', detailError: '', items: [], total: 0,
|
||
drawer: false, detail: null, lifecycle: null, activeId: '',
|
||
severities: [{ label: '低', value: 'low' }, { label: '中', value: 'medium' }, { label: '高', value: 'high' }, { label: '紧急', value: 'critical' }],
|
||
query: { pageIndex: 1, pageSize: 10, status: '', severity: '', location: '' }
|
||
}
|
||
},
|
||
created() { this.load().then(() => { if (this.$route.query.alertId) this.openDetail({ id: this.$route.query.alertId }) }) },
|
||
methods: {
|
||
async load() {
|
||
this.loading = true; this.error = ''
|
||
try { const response = await listAlerts(this.query); this.items = response.data.list || []; this.total = response.data.count || 0 } catch (error) { this.error = error.message || '预警加载失败' } finally { this.loading = false }
|
||
},
|
||
search() { this.query.pageIndex = 1; this.load() },
|
||
reset() { this.$refs.queryForm.resetFields(); this.search() },
|
||
async openDetail(row) {
|
||
this.drawer = true; this.detailLoading = true; this.detailError = ''; this.detail = null; this.lifecycle = null; this.activeId = row.id
|
||
try { const [detailResponse, lifecycleResponse] = await Promise.all([getAlert(row.id), getAlertLifecycle(row.id)]); this.detail = detailResponse.data; this.lifecycle = lifecycleResponse.data.detail } catch (error) { this.detailError = error.message || '预警详情加载失败' } finally { this.detailLoading = false }
|
||
},
|
||
async reloadDetail() { await this.openDetail({ id: this.activeId }); await this.load() },
|
||
goEvent(id) { this.drawer = false; this.$router.push({ path: '/bell/events', query: { eventId: id }}) },
|
||
severityName(value) { return { low: '低', medium: '中', high: '高', critical: '紧急' }[value] || value },
|
||
severityType(value) { return { low: 'info', medium: 'primary', high: 'warning', critical: 'danger' }[value] || 'info' },
|
||
statusName(value) { return { open: '待处理', acknowledged: '处理中', closed: '已完成' }[value] || value },
|
||
statusType(value) { return { open: 'danger', acknowledged: 'warning', closed: 'success' }[value] || 'info' }
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style scoped>
|
||
.page-heading h2{margin:0}.page-heading p{margin:6px 0 0;color:var(--el-text-color-secondary)}.state-alert{margin-bottom:16px}h3{font-size:16px;margin:22px 0 10px}
|
||
</style>
|