告警接口

This commit is contained in:
mmc
2026-05-13 09:28:34 +08:00
parent 348aa391ff
commit d349903ed6
3 changed files with 162 additions and 72 deletions

View File

@@ -14,11 +14,40 @@ import {
const { Option } = Select;
// 配置
const levelColor = { 1: '#F53F3F', 2: '#FF7D00', 3: '#F7BA1E', 4: '#165DFF' };
const levelText = { 1: '严重', 2: '重要', 3: '一般', 4: '提示' };
const statusText = { 0: '待处理', 1: '处理中', 2: '已关闭' };
const statusColor = { 0: '#F7BA1E', 1: '#165DFF', 2: '#00B42A' };
// ====================== 枚举配置 ======================
const alarmTypeMap = {
1: '设备故障',
2: '数据异常',
3: '通信中断',
4: '性能告警',
5: '安全告警',
6: '环境告警'
};
const alarmLevelConfig = {
1: { description: '严重', color: '#FF4D4F' },
2: { description: '重要', color: '#FA8C16' },
3: { description: '一般', color: '#FADB14' },
4: { description: '提示', color: '#1890FF' }
};
const handleStatusMap = {
1: '待处理',
2: '处理中',
3: '已关闭',
4: '已忽略'
};
// 自动生成颜色/文字映射
const levelColor = Object.keys(alarmLevelConfig).reduce((map, key) => {
map[key] = alarmLevelConfig[key].color;
return map;
}, {});
const levelText = Object.keys(alarmLevelConfig).reduce((map, key) => {
map[key] = alarmLevelConfig[key].description;
return map;
}, {});
const AlarmHistory = () => {
const [form] = Form.useForm();
@@ -109,12 +138,15 @@ const AlarmHistory = () => {
{
title: '处理状态',
width: 110,
render: (r) => (
<span style={{ color: statusColor[r.handleStatus], display: 'flex', alignItems: 'center' }}>
<span style={{ width: 6, height: 6, borderRadius: '50%', background: statusColor[r.handleStatus], marginRight: 8 }}></span>
{statusText[r.handleStatus]}
</span>
)
render: (r) => {
const s = r.handleStatus;
let color = 'default';
if (s === 1) color = 'orange';
if (s === 2) color = 'blue';
if (s === 3) color = 'green';
if (s === 4) color = 'default';
return <Tag color={color}>{handleStatusMap[s] || '-'}</Tag>;
}
},
{
title: '操作',
@@ -148,9 +180,10 @@ const AlarmHistory = () => {
<Form.Item name="handleStatus" label="处理状态">
<Select placeholder="全部" style={{ width: 130 }} allowClear>
<Option value={0}>待处理</Option>
<Option value={1}>处理中</Option>
<Option value={2}>已关闭</Option>
<Option value={1}>待处理</Option>
<Option value={2}>处理中</Option>
<Option value={3}>已关闭</Option>
<Option value={4}>已忽略</Option>
</Select>
</Form.Item>
@@ -207,9 +240,15 @@ const AlarmHistory = () => {
</Tag>
</Descriptions.Item>
<Descriptions.Item label="处理状态">
<span style={{ color: statusColor[currentAlarm?.handleStatus] }}>
{statusText[currentAlarm?.handleStatus]}
</span>
{(() => {
const s = currentAlarm?.handleStatus;
let color = 'default';
if (s === 1) color = 'orange';
if (s === 2) color = 'blue';
if (s === 3) color = 'green';
if (s === 4) color = 'default';
return <Tag color={color}>{handleStatusMap[s] || '-'}</Tag>;
})()}
</Descriptions.Item>
<Descriptions.Item label="处理人">{currentAlarm?.handleUserName || '-'}</Descriptions.Item>
<Descriptions.Item label="处理时间">
@@ -217,8 +256,6 @@ const AlarmHistory = () => {
</Descriptions.Item>
<Descriptions.Item label="处理备注">{currentAlarm?.handleRemark || '-'}</Descriptions.Item>
<Descriptions.Item label="根因分析">{currentAlarm?.rootCause || '-'}</Descriptions.Item>
{/* 新增:推荐处理措施 */}
<Descriptions.Item label="推荐处理措施">
{currentAlarm?.handleSuggestion || '-'}
</Descriptions.Item>