告警接口
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -22,12 +22,40 @@ import {
|
||||
const { RangePicker } = DatePicker;
|
||||
const { Text } = Typography;
|
||||
|
||||
// 级别 + 状态颜色
|
||||
const levelColor = { 1: '#F53F3F', 2: '#FF7D00', 3: '#F7BA1E', 4: '#165DFF' };
|
||||
const levelText = { 1: '严重', 2: '重要', 3: '一般', 4: '提示' };
|
||||
// ====================== 你提供的枚举 ======================
|
||||
const alarmTypeMap = {
|
||||
1: '设备故障',
|
||||
2: '数据异常',
|
||||
3: '通信中断',
|
||||
4: '性能告警',
|
||||
5: '安全告警',
|
||||
6: '环境告警'
|
||||
};
|
||||
|
||||
const statusColor = { 0: '#F7BA1E', 1: '#165DFF', 2: '#00B42A' };
|
||||
const statusText = { 0: '待处理', 1: '处理中', 2: '已关闭' };
|
||||
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;
|
||||
}, {});
|
||||
|
||||
export default function AlarmCenterPage() {
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -106,7 +134,7 @@ export default function AlarmCenterPage() {
|
||||
// ====================== 处理告警 ======================
|
||||
const doHandle = async () => {
|
||||
try {
|
||||
await handleAlarm({ id: currentAlarm.id, handleStatus: 2, handleRemark: '已处理' });
|
||||
await handleAlarm({ id: currentAlarm.id, handleStatus: 3, handleRemark: '已处理' });
|
||||
message.success('处理成功');
|
||||
setDrawerVisible(false);
|
||||
fetchList();
|
||||
@@ -159,6 +187,12 @@ export default function AlarmCenterPage() {
|
||||
dataIndex: 'deviceName',
|
||||
width: 160
|
||||
},
|
||||
{
|
||||
title: '告警类型',
|
||||
dataIndex: 'alarmType',
|
||||
width: 120,
|
||||
render: (t) => alarmTypeMap[t] || '-'
|
||||
},
|
||||
{
|
||||
title: '告警级别',
|
||||
dataIndex: 'alarmLevel',
|
||||
@@ -179,12 +213,19 @@ export default function AlarmCenterPage() {
|
||||
title: '处理状态',
|
||||
dataIndex: 'handleStatus',
|
||||
width: 110,
|
||||
render: (s) => (
|
||||
<span style={{ color: statusColor[s], display: 'flex', alignItems: 'center' }}>
|
||||
<span style={{ width: 6, height: 6, borderRadius: '50%', background: statusColor[s], marginRight: 8 }}></span>
|
||||
{statusText[s]}
|
||||
</span>
|
||||
)
|
||||
render: (s) => {
|
||||
let color = 'default';
|
||||
const text = handleStatusMap[s] || '-';
|
||||
// 1:待处理 2:处理中 3:已关闭 4:已忽略
|
||||
switch (s) {
|
||||
case 1: color = 'orange'; break; // 待处理
|
||||
case 2: color = 'blue'; break; // 处理中
|
||||
case 3: color = 'green'; break; // 已关闭
|
||||
case 4: color = 'default'; break; // 已忽略
|
||||
default: break;
|
||||
}
|
||||
return <Tag color={color}>{text}</Tag>;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
@@ -205,7 +246,7 @@ export default function AlarmCenterPage() {
|
||||
{ type: '提示', value: statData.levelStats?.[4] || 0 },
|
||||
].filter(i => i.value > 0),
|
||||
angleField: 'value', colorField: 'type',
|
||||
color: ['#F53F3F', '#FF7D00', '#F7BA1E', '#165DFF'],
|
||||
color: ['#FF4D4F', '#FA8C16', '#FADB14', '#1890FF'],
|
||||
radius: 0.8, innerRadius: 0.6, label: false
|
||||
};
|
||||
|
||||
@@ -240,9 +281,10 @@ export default function AlarmCenterPage() {
|
||||
onChange={v => setQueryParams({ ...queryParams, handleStatus: v })}
|
||||
options={[
|
||||
{ value: '', label: '全部' },
|
||||
{ value: 0, label: '待处理' },
|
||||
{ value: 1, label: '处理中' },
|
||||
{ value: 2, label: '已关闭' },
|
||||
{ value: 1, label: '待处理' },
|
||||
{ value: 2, label: '处理中' },
|
||||
{ value: 3, label: '已关闭' },
|
||||
{ value: 4, label: '已忽略' },
|
||||
]}
|
||||
/>
|
||||
</Col>
|
||||
@@ -297,12 +339,12 @@ export default function AlarmCenterPage() {
|
||||
<Row align="middle" gutter={16}>
|
||||
<Col>
|
||||
<div style={{ width: 48, height: 48, background: '#FFF1F0', borderRadius: '50%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
|
||||
<BellOutlined style={{ fontSize: 24, color: '#F53F3F' }} />
|
||||
<BellOutlined style={{ fontSize: 24, color: '#FF4D4F' }} />
|
||||
</div>
|
||||
</Col>
|
||||
<Col style={{ overflow: 'hidden' }}>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>告警总数</div>
|
||||
<div style={{ fontSize: 28, fontWeight: 700, color: '#F53F3F', lineHeight: '36px' }}>
|
||||
<div style={{ fontSize: 28, fontWeight: 700, color: '#FF4D4F', lineHeight: '36px' }}>
|
||||
{statData.total || 0}
|
||||
</div>
|
||||
</Col>
|
||||
@@ -315,12 +357,12 @@ export default function AlarmCenterPage() {
|
||||
<Row align="middle" gutter={16}>
|
||||
<Col>
|
||||
<div style={{ width: 48, height: 48, background: '#FFF1F0', borderRadius: '50%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
|
||||
<ExclamationCircleOutlined style={{ fontSize: 24, color: '#F53F3F' }} />
|
||||
<ExclamationCircleOutlined style={{ fontSize: 24, color: '#FF4D4F' }} />
|
||||
</div>
|
||||
</Col>
|
||||
<Col style={{ overflow: 'hidden' }}>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>严重告警</div>
|
||||
<div style={{ fontSize: 28, fontWeight: 700, color: '#F53F3F', lineHeight: '36px' }}>
|
||||
<div style={{ fontSize: 28, fontWeight: 700, color: '#FF4D4F', lineHeight: '36px' }}>
|
||||
{statData.levelStats?.[1] || 0}
|
||||
</div>
|
||||
</Col>
|
||||
@@ -333,12 +375,12 @@ export default function AlarmCenterPage() {
|
||||
<Row align="middle" gutter={16}>
|
||||
<Col>
|
||||
<div style={{ width: 48, height: 48, background: '#FFF7E8', borderRadius: '50%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
|
||||
<ClockCircleOutlined style={{ fontSize: 24, color: '#FF7D00' }} />
|
||||
<ClockCircleOutlined style={{ fontSize: 24, color: '#FA8C16' }} />
|
||||
</div>
|
||||
</Col>
|
||||
<Col style={{ overflow: 'hidden' }}>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>待处理</div>
|
||||
<div style={{ fontSize: 28, fontWeight: 700, color: '#FF7D00', lineHeight: '36px' }}>
|
||||
<div style={{ fontSize: 28, fontWeight: 700, color: '#FA8C16', lineHeight: '36px' }}>
|
||||
{statData.pending || 0}
|
||||
</div>
|
||||
</Col>
|
||||
@@ -351,12 +393,12 @@ export default function AlarmCenterPage() {
|
||||
<Row align="middle" gutter={16}>
|
||||
<Col>
|
||||
<div style={{ width: 48, height: 48, background: '#E8F3FF', borderRadius: '50%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
|
||||
<ReloadOutlined style={{ fontSize: 24, color: '#165DFF' }} />
|
||||
<ReloadOutlined style={{ fontSize: 24, color: '#1890FF' }} />
|
||||
</div>
|
||||
</Col>
|
||||
<Col style={{ overflow: 'hidden' }}>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>处理中</div>
|
||||
<div style={{ fontSize: 28, fontWeight: 700, color: '#165DFF', lineHeight: '36px' }}>
|
||||
<div style={{ fontSize: 28, fontWeight: 700, color: '#1890FF', lineHeight: '36px' }}>
|
||||
{statData.processing || 0}
|
||||
</div>
|
||||
</Col>
|
||||
@@ -425,7 +467,7 @@ export default function AlarmCenterPage() {
|
||||
]}
|
||||
xField="date"
|
||||
yField={['严重']}
|
||||
color={['#F53F3F']}
|
||||
color={['#FF4D4F']}
|
||||
smooth
|
||||
height={220}
|
||||
/>
|
||||
@@ -453,7 +495,7 @@ export default function AlarmCenterPage() {
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
{/* 告警详情抽屉 —— 按设计稿完整实现 */}
|
||||
{/* 告警详情抽屉 */}
|
||||
<Drawer
|
||||
title="告警详情"
|
||||
open={drawerVisible}
|
||||
@@ -467,7 +509,7 @@ export default function AlarmCenterPage() {
|
||||
{/* 告警头部 */}
|
||||
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 16 }}>
|
||||
<div style={{ width: 40, height: 40, background: '#FFF1F0', borderRadius: '50%', display: 'flex', justifyContent: 'center', alignItems: 'center', marginRight: 12 }}>
|
||||
<ExclamationCircleOutlined style={{ fontSize: 20, color: '#F53F3F' }} />
|
||||
<ExclamationCircleOutlined style={{ fontSize: 20, color: '#FF4D4F' }} />
|
||||
</div>
|
||||
<div style={{ flex: 1 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
||||
@@ -483,10 +525,22 @@ export default function AlarmCenterPage() {
|
||||
{/* 告警基础信息 */}
|
||||
<Descriptions column={1} bordered size="small" style={{ marginBottom: 16 }}>
|
||||
<Descriptions.Item label="来源设备">{currentAlarm.deviceName || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="设备类型">{currentAlarm.deviceType || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="告警类型">{alarmTypeMap[currentAlarm.alarmType] || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="发生时间">{dayjs(currentAlarm.alarmTime).format('YYYY-MM-DD HH:mm:ss')}</Descriptions.Item>
|
||||
<Descriptions.Item label="处理状态">
|
||||
<Tag color={statusColor[currentAlarm.handleStatus]}>{statusText[currentAlarm.handleStatus]}</Tag>
|
||||
{(() => {
|
||||
let color = 'default';
|
||||
const status = currentAlarm.handleStatus;
|
||||
// 1:待处理 2:处理中 3:已关闭 4:已忽略
|
||||
switch (status) {
|
||||
case 1: color = 'orange'; break;
|
||||
case 2: color = 'blue'; break;
|
||||
case 3: color = 'green'; break;
|
||||
case 4: color = 'default'; break;
|
||||
default: break;
|
||||
}
|
||||
return <Tag color={color}>{handleStatusMap[status] || '-'}</Tag>;
|
||||
})()}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="负责人">{currentAlarm.handleUserName || '-'}</Descriptions.Item>
|
||||
</Descriptions>
|
||||
@@ -513,7 +567,7 @@ export default function AlarmCenterPage() {
|
||||
<Space>
|
||||
<svg t="1778634297838" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9839" width="16" height="16"><path d="M761.984 1009.28H253.696C138.368 1009.28 44.8 915.712 44.8 800.384V292.096C44.8 176.768 138.368 83.2 253.696 83.2h508.288c115.328 0 208.896 93.568 208.896 208.896v508.288c0 115.328-93.568 208.896-208.896 208.896z" fill="#00E560" p-id="9840"></path><path d="M507.776 265.856c-72.576 0-139.776 20.352-193.536 54.528-54.272 34.432-94.592 83.2-113.408 139.264-7.552 22.528-11.648 46.464-11.648 71.04 0 92.16 56.448 172.928 142.208 220.544 7.68 4.224 11.648 13.44 8.32 21.632-6.4 15.616-14.592 30.592-24.32 44.672-3.072 4.352 0.768 10.368 6.016 8.96 29.44-7.808 56.96-19.072 81.92-33.28 9.088-5.248 19.456-6.912 29.696-4.864 23.936 4.736 49.024 7.296 74.88 7.296 176 0 318.592-118.656 318.592-264.832 0-146.304-142.72-264.96-318.72-264.96z" fill="#FFFFFF" p-id="9841"></path></svg>
|
||||
<span>短信</span>
|
||||
<Switch checked={currentAlarm.notifySms === 1} />
|
||||
<Switch checked={currentAlarm.notifySms === 1} disabled />
|
||||
</Space>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
@@ -521,7 +575,7 @@ export default function AlarmCenterPage() {
|
||||
<svg t="1778634173765" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8764" width="16" height="16"><path d="M512.003 79C272.855 79 79 272.855 79 512.003 79 751.145 272.855 945 512.003 945 751.145 945 945 751.145 945 512.003 945 272.855 751.145 79 512.003 79z m200.075 375.014c-0.867 3.764-3.117 9.347-6.234 16.012h0.087l-0.347 0.648c-18.183 38.86-65.631 115.108-65.631 115.108l-0.215-0.52-13.856 24.147h66.8L565.063 779l29.002-115.368h-52.598l18.27-76.29c-14.76 3.55-32.253 8.436-52.945 15.1 0 0-27.967 16.36-80.607-31.5 0 0-35.501-31.29-14.891-39.078 8.744-3.33 42.466-7.573 69.004-11.122 35.93-4.845 57.965-7.441 57.965-7.441s-110.607 1.643-136.841-2.468c-26.237-4.11-59.525-47.905-66.626-86.377 0 0-10.953-21.117 23.595-11.122 34.547 10 177.535 38.95 177.535 38.95s-185.933-56.992-198.36-70.929c-12.381-13.846-36.406-75.902-33.289-113.981 0 0 1.343-9.521 11.127-6.926 0 0 137.49 62.75 231.475 97.152 94.028 34.403 175.76 51.885 165.2 96.414z" fill="#3AA2EB" p-id="8765"></path></svg>
|
||||
{/*<NotificationOutlined />*/}
|
||||
<span>钉钉</span>
|
||||
<Switch checked={currentAlarm.notifyTelegram === 1} />
|
||||
<Switch checked={currentAlarm.notifyTelegram === 1} disabled />
|
||||
</Space>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
@@ -529,7 +583,7 @@ export default function AlarmCenterPage() {
|
||||
<svg t="1778634149974" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7716" width="16" height="16"><path d="M512 512m-448 0a448 448 0 1 0 896 0 448 448 0 1 0-896 0Z" fill="#608BE9" p-id="7717"></path><path d="M192 302m32 0l576 0q32 0 32 32l0 356q0 32-32 32l-576 0q-32 0-32-32l0-356q0-32 32-32Z" fill="#EAEDF5" p-id="7718"></path><path d="M224 722h576c17.673 0 32-14.327 32-32v-58C660.96 493.333 554.294 424 512 424c-42.294 0-148.96 69.333-320 208v58c0 17.673 14.327 32 32 32z" fill="#CCDAF7" p-id="7719"></path><path d="M224 302h576c17.673 0 32 14.327 32 32v58C651.35 517.333 544.683 580 512 580c-32.683 0-139.35-62.667-320-188v-58c0-17.673 14.327-32 32-32z" fill="#FFFFFF" p-id="7720"></path></svg>
|
||||
{/*<NotificationOutlined />*/}
|
||||
<span>邮件</span>
|
||||
<Switch checked={currentAlarm.notifyEmail === 1} />
|
||||
<Switch checked={currentAlarm.notifyEmail === 1} disabled />
|
||||
</Space>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
Reference in New Issue
Block a user