告警数据
This commit is contained in:
@@ -1,33 +1,34 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import {
|
||||
Card, Table, Tag, Badge, Space, Button,
|
||||
Modal, Descriptions, Form, Select, Input, Pagination, message
|
||||
Card, Table, Tag, Space, Button,
|
||||
Drawer, Descriptions, Form, Select, Pagination, message
|
||||
} from 'antd';
|
||||
import { EyeOutlined, SearchOutlined } from '@ant-design/icons';
|
||||
import { EyeOutlined, NotificationOutlined } from '@ant-design/icons';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
// 引入你的告警接口
|
||||
// 接口
|
||||
import {
|
||||
getAlarmList,
|
||||
getAlarmDetail
|
||||
} from '../../api/alarmApi.js';
|
||||
|
||||
const { Option } = Select;
|
||||
const { Search } = Input;
|
||||
|
||||
// 级别 + 状态映射(和主页面保持一致)
|
||||
// 配置
|
||||
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 AlarmHistory = () => {
|
||||
const [form] = Form.useForm();
|
||||
|
||||
// 弹窗
|
||||
const [detailVisible, setDetailVisible] = useState(false);
|
||||
// 抽屉
|
||||
const [drawerVisible, setDrawerVisible] = useState(false);
|
||||
const [currentAlarm, setCurrentAlarm] = useState(null);
|
||||
const [detailLoading, setDetailLoading] = useState(false);
|
||||
|
||||
// 列表 + 分页
|
||||
// 列表
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [alarmList, setAlarmList] = useState([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
@@ -36,69 +37,64 @@ const AlarmHistory = () => {
|
||||
|
||||
// 查询条件
|
||||
const [queryParams, setQueryParams] = useState({
|
||||
deviceName: '',
|
||||
alarmLevel: '',
|
||||
handleStatus: '',
|
||||
timeRange: 'all'
|
||||
});
|
||||
|
||||
// 获取告警历史列表
|
||||
// 获取列表
|
||||
const fetchList = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await getAlarmList({
|
||||
pageNum,
|
||||
pageSize,
|
||||
...queryParams
|
||||
});
|
||||
if (res.code === 200) {
|
||||
const res = await getAlarmList({ pageNum, pageSize, ...queryParams });
|
||||
if (res.code === 0) {
|
||||
setAlarmList(res.rows || []);
|
||||
setTotal(res.total || 0);
|
||||
}
|
||||
} catch (err) {
|
||||
message.error('加载历史记录失败');
|
||||
message.error('加载失败');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 获取详情
|
||||
// 查看详情(打开抽屉)
|
||||
const showDetail = async (id) => {
|
||||
setDetailLoading(true);
|
||||
try {
|
||||
const res = await getAlarmDetail(id);
|
||||
if (res.code === 200) {
|
||||
setCurrentAlarm(res.data);
|
||||
setDetailVisible(true);
|
||||
setDrawerVisible(true);
|
||||
} else {
|
||||
message.error('获取详情失败');
|
||||
}
|
||||
} catch (err) {
|
||||
message.error('获取详情失败');
|
||||
message.error('请求异常');
|
||||
} finally {
|
||||
setDetailLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 搜索
|
||||
const handleSearch = (values) => {
|
||||
setQueryParams({ ...values });
|
||||
setQueryParams(values);
|
||||
setPageNum(1);
|
||||
};
|
||||
|
||||
// 加载
|
||||
useEffect(() => {
|
||||
fetchList();
|
||||
}, [pageNum, pageSize, queryParams]);
|
||||
|
||||
// 表格列
|
||||
const columns = [
|
||||
{ title: '告警编号', dataIndex: 'alarmNo', width: 180 },
|
||||
{
|
||||
title: '告警时间',
|
||||
dataIndex: 'createTime',
|
||||
dataIndex: 'alarmTime',
|
||||
width: 190,
|
||||
sorter: true
|
||||
},
|
||||
{
|
||||
title: '设备名称',
|
||||
dataIndex: 'deviceName',
|
||||
ellipsis: true
|
||||
render: (t) => t ? dayjs(t).format('YYYY-MM-DD HH:mm:ss') : '-'
|
||||
},
|
||||
{ title: '设备名称', dataIndex: 'deviceName', ellipsis: true },
|
||||
{
|
||||
title: '告警级别',
|
||||
width: 100,
|
||||
@@ -108,24 +104,22 @@ const AlarmHistory = () => {
|
||||
</Tag>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: '告警内容',
|
||||
dataIndex: 'content',
|
||||
ellipsis: true
|
||||
},
|
||||
{ title: '告警标题', dataIndex: 'alarmTitle', ellipsis: true, width: 180 },
|
||||
{ title: '告警内容', dataIndex: 'alarmContent', ellipsis: true },
|
||||
{
|
||||
title: '处理状态',
|
||||
width: 100,
|
||||
width: 110,
|
||||
render: (r) => (
|
||||
<Badge
|
||||
status={r.handleStatus === 2 ? 'success' : r.handleStatus === 1 ? 'processing' : 'warning'}
|
||||
text={statusText[r.handleStatus]}
|
||||
/>
|
||||
<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>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
render: (_, r) => (
|
||||
<Button type="link" icon={<EyeOutlined />} onClick={() => showDetail(r.id)}>
|
||||
查看详情
|
||||
@@ -135,21 +129,14 @@ const AlarmHistory = () => {
|
||||
];
|
||||
|
||||
return (
|
||||
<div style={{ padding: 24 }}>
|
||||
<Card
|
||||
title="告警历史"
|
||||
style={{ borderRadius: 8 }}
|
||||
extra={<span style={{ color: '#888' }}>历史告警记录</span>}
|
||||
>
|
||||
{/* 筛选栏 */}
|
||||
<div style={{ padding: 24, background: '#f5f7fa', minHeight: '100vh' }}>
|
||||
<Card title="告警历史" style={{ borderRadius: 8 }}>
|
||||
<Form
|
||||
form={form}
|
||||
layout="inline"
|
||||
onFinish={handleSearch}
|
||||
style={{ marginBottom: 16, flexWrap: 'wrap', gap: 16 }}
|
||||
>
|
||||
|
||||
|
||||
<Form.Item name="alarmLevel" label="告警级别">
|
||||
<Select placeholder="全部" style={{ width: 130 }} allowClear>
|
||||
<Option value={1}>严重</Option>
|
||||
@@ -175,7 +162,6 @@ const AlarmHistory = () => {
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
||||
{/* 表格 */}
|
||||
<Table
|
||||
rowKey="id"
|
||||
columns={columns}
|
||||
@@ -185,16 +171,12 @@ const AlarmHistory = () => {
|
||||
scroll={{ x: 'max-content' }}
|
||||
/>
|
||||
|
||||
{/* 分页 */}
|
||||
<div style={{ textAlign: 'center', marginTop: 16 }}>
|
||||
<Pagination
|
||||
current={pageNum}
|
||||
pageSize={pageSize}
|
||||
total={total}
|
||||
onChange={(p, s) => {
|
||||
setPageNum(p);
|
||||
setPageSize(s);
|
||||
}}
|
||||
onChange={(p, s) => { setPageNum(p); setPageSize(s); }}
|
||||
showSizeChanger
|
||||
showQuickJumper
|
||||
showTotal={(total) => `共 ${total} 条`}
|
||||
@@ -202,39 +184,75 @@ const AlarmHistory = () => {
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
{/* 详情弹窗 */}
|
||||
<Modal
|
||||
title="告警历史详情"
|
||||
open={detailVisible}
|
||||
onCancel={() => setDetailVisible(false)}
|
||||
footer={null}
|
||||
width={580}
|
||||
{/* 右侧详情抽屉 —— 新版设计稿样式 */}
|
||||
<Drawer
|
||||
title="告警详情"
|
||||
open={drawerVisible}
|
||||
onClose={() => setDrawerVisible(false)}
|
||||
width={650}
|
||||
destroyOnClose
|
||||
>
|
||||
<Descriptions column={1} bordered size="small" loading={detailLoading}>
|
||||
<Descriptions.Item label="告警编号">{currentAlarm?.alarmNo || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="告警标题">{currentAlarm?.alarmTitle || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="告警内容">{currentAlarm?.alarmContent || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="设备ID">{currentAlarm?.deviceId || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="设备名称">{currentAlarm?.deviceName || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="告警时间">
|
||||
{currentAlarm?.alarmTime ? dayjs(currentAlarm.alarmTime).format('YYYY-MM-DD HH:mm:ss') : '-'}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="告警级别">
|
||||
<Tag color={levelColor[currentAlarm?.alarmLevel]} style={{ border: 'none', color: '#fff' }}>
|
||||
{levelText[currentAlarm?.alarmLevel]}
|
||||
</Tag>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="处理状态">
|
||||
<span style={{ color: statusColor[currentAlarm?.handleStatus] }}>
|
||||
{statusText[currentAlarm?.handleStatus]}
|
||||
</span>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="处理人">{currentAlarm?.handleUserName || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="处理时间">
|
||||
{currentAlarm?.handleTime ? dayjs(currentAlarm.handleTime).format('YYYY-MM-DD HH:mm:ss') : '-'}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="处理备注">{currentAlarm?.handleRemark || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="根因分析">{currentAlarm?.rootCause || '-'}</Descriptions.Item>
|
||||
|
||||
{/* 新增:推荐处理措施 */}
|
||||
<Descriptions.Item label="推荐处理措施">
|
||||
{currentAlarm?.handleSuggestion || '-'}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
|
||||
{/* 通知订阅模块 */}
|
||||
{currentAlarm && (
|
||||
<Descriptions column={1} bordered size="small">
|
||||
<Descriptions.Item label="告警ID">{currentAlarm.id}</Descriptions.Item>
|
||||
<Descriptions.Item label="告警时间">{currentAlarm.createTime}</Descriptions.Item>
|
||||
<Descriptions.Item label="设备ID">{currentAlarm.deviceId}</Descriptions.Item>
|
||||
<Descriptions.Item label="设备名称">{currentAlarm.deviceName || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="告警内容">{currentAlarm.content}</Descriptions.Item>
|
||||
<Descriptions.Item label="告警级别">
|
||||
<Tag color={levelColor[currentAlarm.alarmLevel]} style={{ border: 'none', color: '#fff' }}>
|
||||
{levelText[currentAlarm.alarmLevel]}
|
||||
</Tag>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="处理状态">
|
||||
<Badge
|
||||
status={currentAlarm.handleStatus === 2 ? 'success' : currentAlarm.handleStatus === 1 ? 'processing' : 'warning'}
|
||||
text={statusText[currentAlarm.handleStatus]}
|
||||
/>
|
||||
</Descriptions.Item>
|
||||
{currentAlarm.handleRemark && (
|
||||
<Descriptions.Item label="处理备注">{currentAlarm.handleRemark}</Descriptions.Item>
|
||||
)}
|
||||
</Descriptions>
|
||||
<Card size="small" title="通知订阅" style={{ marginTop: 16 }}>
|
||||
<Space style={{ width: '100%' }}>
|
||||
<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>
|
||||
<Tag color={currentAlarm.notifySms === 1 ? 'green' : 'default'}>
|
||||
{currentAlarm.notifySms === 1 ? '已开启' : '已关闭'}
|
||||
</Tag>
|
||||
</Space>
|
||||
<Space>
|
||||
<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>
|
||||
<span>钉钉</span>
|
||||
<Tag color={currentAlarm.notifyTelegram === 1 ? 'green' : 'default'}>
|
||||
{currentAlarm.notifyTelegram === 1 ? '已开启' : '已关闭'}
|
||||
</Tag>
|
||||
</Space>
|
||||
<Space>
|
||||
<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>
|
||||
<span>邮件:</span>
|
||||
<Tag color={currentAlarm.notifyEmail === 1 ? 'green' : 'default'}>
|
||||
{currentAlarm.notifyEmail === 1 ? '已开启' : '已关闭'}
|
||||
</Tag>
|
||||
</Space>
|
||||
</Space>
|
||||
</Card>
|
||||
)}
|
||||
</Modal>
|
||||
</Drawer>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import {
|
||||
Card, Row, Col, Select, DatePicker, Input, Button, Space, Table, Tag,
|
||||
Typography, Modal, Form, message, Pagination, Spin, Empty, Divider, Switch
|
||||
Typography, message, Pagination, Spin, Drawer, Descriptions, Switch
|
||||
} from 'antd';
|
||||
import {
|
||||
BellOutlined, ClockCircleOutlined, CheckCircleOutlined, ExclamationCircleOutlined,
|
||||
SearchOutlined, ReloadOutlined, CloseOutlined, InfoCircleOutlined,
|
||||
FileTextOutlined, LineChartOutlined, PieChartOutlined, BarChartOutlined,
|
||||
SearchOutlined, ReloadOutlined, FileTextOutlined, NotificationOutlined
|
||||
} from '@ant-design/icons';
|
||||
import { Line, Pie, Bar } from '@ant-design/charts';
|
||||
import dayjs from 'dayjs';
|
||||
@@ -21,7 +20,7 @@ import {
|
||||
} from '../../api/alarmApi.js';
|
||||
|
||||
const { RangePicker } = DatePicker;
|
||||
const { Text, Title } = Typography;
|
||||
const { Text } = Typography;
|
||||
|
||||
// 级别 + 状态颜色
|
||||
const levelColor = { 1: '#F53F3F', 2: '#FF7D00', 3: '#F7BA1E', 4: '#165DFF' };
|
||||
@@ -31,7 +30,6 @@ const statusColor = { 0: '#F7BA1E', 1: '#165DFF', 2: '#00B42A' };
|
||||
const statusText = { 0: '待处理', 1: '处理中', 2: '已关闭' };
|
||||
|
||||
export default function AlarmCenterPage() {
|
||||
const [form] = Form.useForm();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [detailLoading, setDetailLoading] = useState(false);
|
||||
|
||||
@@ -50,11 +48,11 @@ export default function AlarmCenterPage() {
|
||||
endTime: '',
|
||||
});
|
||||
|
||||
// 详情
|
||||
const [detailVisible, setDetailVisible] = useState(false);
|
||||
// 抽屉
|
||||
const [drawerVisible, setDrawerVisible] = useState(false);
|
||||
const [currentAlarm, setCurrentAlarm] = useState(null);
|
||||
|
||||
// 统计(精准匹配后端接口)
|
||||
// 统计
|
||||
const [statData, setStatData] = useState({
|
||||
total: 0,
|
||||
levelStats: {},
|
||||
@@ -68,7 +66,7 @@ export default function AlarmCenterPage() {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await getAlarmList({ pageNum, pageSize, ...queryParams });
|
||||
if (res.code === 200) {
|
||||
if (res.code === 0) {
|
||||
setAlarmList(res.rows || []);
|
||||
setTotal(res.total || 0);
|
||||
}
|
||||
@@ -94,9 +92,9 @@ export default function AlarmCenterPage() {
|
||||
setDetailLoading(true);
|
||||
try {
|
||||
const res = await getAlarmDetail(id);
|
||||
if (res.code === 200) {
|
||||
if (res.code === 0 || res.code === 200) {
|
||||
setCurrentAlarm(res.data);
|
||||
setDetailVisible(true);
|
||||
setDrawerVisible(true);
|
||||
}
|
||||
} catch (err) {
|
||||
message.error('加载详情失败');
|
||||
@@ -110,7 +108,7 @@ export default function AlarmCenterPage() {
|
||||
try {
|
||||
await handleAlarm({ id: currentAlarm.id, handleStatus: 2, handleRemark: '已处理' });
|
||||
message.success('处理成功');
|
||||
setDetailVisible(false);
|
||||
setDrawerVisible(false);
|
||||
fetchList();
|
||||
fetchStat();
|
||||
} catch (err) {
|
||||
@@ -141,12 +139,26 @@ export default function AlarmCenterPage() {
|
||||
const columns = [
|
||||
{
|
||||
title: '告警编号',
|
||||
dataIndex: 'id',
|
||||
width: 140,
|
||||
render: (text) => <Text style={{ color: '#165DFF' }}>AL{text}</Text>
|
||||
dataIndex: 'alarmNo',
|
||||
width: 180,
|
||||
render: (text) => <Text style={{ color: '#165DFF', fontWeight: 500 }}>{text}</Text>
|
||||
},
|
||||
{
|
||||
title: '告警标题',
|
||||
dataIndex: 'alarmTitle',
|
||||
ellipsis: true,
|
||||
width: 180
|
||||
},
|
||||
{
|
||||
title: '告警内容',
|
||||
dataIndex: 'alarmContent',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '设备名称',
|
||||
dataIndex: 'deviceName',
|
||||
width: 160
|
||||
},
|
||||
{ title: '告警内容', dataIndex: 'content', ellipsis: true },
|
||||
{ title: '来源设备', dataIndex: 'deviceId', width: 160 },
|
||||
{
|
||||
title: '告警级别',
|
||||
dataIndex: 'alarmLevel',
|
||||
@@ -157,11 +169,16 @@ export default function AlarmCenterPage() {
|
||||
</Tag>
|
||||
)
|
||||
},
|
||||
{ title: '发生时间', dataIndex: 'createTime', width: 160 },
|
||||
{
|
||||
title: '告警时间',
|
||||
dataIndex: 'alarmTime',
|
||||
width: 180,
|
||||
render: (t) => t ? dayjs(t).format('YYYY-MM-DD HH:mm:ss') : '-'
|
||||
},
|
||||
{
|
||||
title: '处理状态',
|
||||
dataIndex: 'handleStatus',
|
||||
width: 100,
|
||||
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>
|
||||
@@ -171,14 +188,15 @@ export default function AlarmCenterPage() {
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 80,
|
||||
width: 100,
|
||||
fixed: 'right',
|
||||
render: (_, record) => (
|
||||
<Button type="link" onClick={() => showDetail(record.id)}>查看</Button>
|
||||
)
|
||||
}
|
||||
];
|
||||
|
||||
// 图表数据(自动使用接口统计)
|
||||
// 图表数据
|
||||
const pieConfig = {
|
||||
data: [
|
||||
{ type: '严重', value: statData.levelStats?.[1] || 0 },
|
||||
@@ -193,285 +211,337 @@ export default function AlarmCenterPage() {
|
||||
|
||||
return (
|
||||
<div style={{ background: '#f5f7fa', minHeight: '100vh', padding: '16px 24px' }}>
|
||||
<div style={{ display: 'flex', width: '100%', gap: 16, flexWrap: 'nowrap' }}>
|
||||
|
||||
{/* 左侧 */}
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
{/* 查询栏 */}
|
||||
<Row gutter={16} style={{ marginBottom: 16 }}>
|
||||
<Col span={24}>
|
||||
<Card bordered={false} bodyStyle={{ padding: '16px 24px' }} style={{ borderRadius: 8 }}>
|
||||
<Row gutter={[24, 16]} align="middle">
|
||||
<Col>
|
||||
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>告警级别</div>
|
||||
<Select
|
||||
style={{ width: 120 }}
|
||||
value={queryParams.alarmLevel}
|
||||
onChange={v => setQueryParams({ ...queryParams, alarmLevel: v })}
|
||||
options={[
|
||||
{ value: '', label: '全部' },
|
||||
{ value: 1, label: '严重' },
|
||||
{ value: 2, label: '重要' },
|
||||
{ value: 3, label: '一般' },
|
||||
{ value: 4, label: '提示' },
|
||||
]}
|
||||
/>
|
||||
</Col>
|
||||
<Col>
|
||||
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>处理状态</div>
|
||||
<Select
|
||||
style={{ width: 120 }}
|
||||
value={queryParams.handleStatus}
|
||||
onChange={v => setQueryParams({ ...queryParams, handleStatus: v })}
|
||||
options={[
|
||||
{ value: '', label: '全部' },
|
||||
{ value: 0, label: '待处理' },
|
||||
{ value: 1, label: '处理中' },
|
||||
{ value: 2, label: '已关闭' },
|
||||
]}
|
||||
/>
|
||||
</Col>
|
||||
<Col>
|
||||
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>设备ID</div>
|
||||
<Input
|
||||
placeholder="设备ID"
|
||||
value={queryParams.deviceId}
|
||||
onChange={e => setQueryParams({ ...queryParams, deviceId: e.target.value })}
|
||||
style={{ width: 160 }}
|
||||
/>
|
||||
</Col>
|
||||
<Col>
|
||||
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>时间范围</div>
|
||||
<RangePicker
|
||||
showTime
|
||||
style={{ width: 320 }}
|
||||
onChange={arr => {
|
||||
if (arr) {
|
||||
setQueryParams({
|
||||
...queryParams,
|
||||
beginTime: arr[0].format('YYYY-MM-DD HH:mm:ss'),
|
||||
endTime: arr[1].format('YYYY-MM-DD HH:mm:ss')
|
||||
});
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Col>
|
||||
<Col>
|
||||
{/* 查询栏 */}
|
||||
<Row gutter={16} style={{ marginBottom: 16 }}>
|
||||
<Col span={24}>
|
||||
<Card bordered={false} bodyStyle={{ padding: '16px 24px' }} style={{ borderRadius: 8 }}>
|
||||
<Row gutter={[24, 16]} align="middle">
|
||||
<Col>
|
||||
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>告警级别</div>
|
||||
<Select
|
||||
style={{ width: 120 }}
|
||||
value={queryParams.alarmLevel}
|
||||
onChange={v => setQueryParams({ ...queryParams, alarmLevel: v })}
|
||||
options={[
|
||||
{ value: '', label: '全部' },
|
||||
{ value: 1, label: '严重' },
|
||||
{ value: 2, label: '重要' },
|
||||
{ value: 3, label: '一般' },
|
||||
{ value: 4, label: '提示' },
|
||||
]}
|
||||
/>
|
||||
</Col>
|
||||
<Col>
|
||||
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>处理状态</div>
|
||||
<Select
|
||||
style={{ width: 120 }}
|
||||
value={queryParams.handleStatus}
|
||||
onChange={v => setQueryParams({ ...queryParams, handleStatus: v })}
|
||||
options={[
|
||||
{ value: '', label: '全部' },
|
||||
{ value: 0, label: '待处理' },
|
||||
{ value: 1, label: '处理中' },
|
||||
{ value: 2, label: '已关闭' },
|
||||
]}
|
||||
/>
|
||||
</Col>
|
||||
<Col>
|
||||
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>设备ID</div>
|
||||
<Input
|
||||
placeholder="设备ID"
|
||||
value={queryParams.deviceId}
|
||||
onChange={e => setQueryParams({ ...queryParams, deviceId: e.target.value })}
|
||||
style={{ width: 160 }}
|
||||
/>
|
||||
</Col>
|
||||
<Col>
|
||||
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>时间范围</div>
|
||||
<RangePicker
|
||||
showTime
|
||||
style={{ width: 320 }}
|
||||
onChange={arr => {
|
||||
if (arr) {
|
||||
setQueryParams({
|
||||
...queryParams,
|
||||
beginTime: arr[0].format('YYYY-MM-DD HH:mm:ss'),
|
||||
endTime: arr[1].format('YYYY-MM-DD HH:mm:ss')
|
||||
});
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Col>
|
||||
<Col>
|
||||
<Space>
|
||||
<Button style={{ borderRadius: 8 }} onClick={() => {
|
||||
setQueryParams({ deviceId: '', alarmLevel: '', handleStatus: '', beginTime: '', endTime: '' });
|
||||
fetchList();
|
||||
}}>重置</Button>
|
||||
<Button type="primary" style={{ borderRadius: 8, background: '#165DFF' }} onClick={fetchList}>
|
||||
<SearchOutlined />查询
|
||||
</Button>
|
||||
<Button style={{ borderRadius: 8 }} onClick={doExport}>
|
||||
<FileTextOutlined />导出
|
||||
</Button>
|
||||
</Space>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
{/* 统计卡片 */}
|
||||
<Row gutter={16} style={{ marginBottom: 16, flexWrap: 'wrap' }}>
|
||||
<Col xs={24} sm={12} md={8} lg={4} xl={4}>
|
||||
<Card bordered={false} bodyStyle={{ padding: '16px 20px' }} style={{ borderRadius: 8, whiteSpace: 'nowrap' }}>
|
||||
<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' }} />
|
||||
</div>
|
||||
</Col>
|
||||
<Col style={{ overflow: 'hidden' }}>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>告警总数</div>
|
||||
<div style={{ fontSize: 28, fontWeight: 700, color: '#F53F3F', lineHeight: '36px' }}>
|
||||
{statData.total || 0}
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
</Col>
|
||||
|
||||
<Col xs={24} sm={12} md={8} lg={4} xl={4}>
|
||||
<Card bordered={false} bodyStyle={{ padding: '16px 20px' }} style={{ borderRadius: 8, whiteSpace: 'nowrap' }}>
|
||||
<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' }} />
|
||||
</div>
|
||||
</Col>
|
||||
<Col style={{ overflow: 'hidden' }}>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>严重告警</div>
|
||||
<div style={{ fontSize: 28, fontWeight: 700, color: '#F53F3F', lineHeight: '36px' }}>
|
||||
{statData.levelStats?.[1] || 0}
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
</Col>
|
||||
|
||||
<Col xs={24} sm={12} md={8} lg={4} xl={4}>
|
||||
<Card bordered={false} bodyStyle={{ padding: '16px 20px' }} style={{ borderRadius: 8, whiteSpace: 'nowrap' }}>
|
||||
<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' }} />
|
||||
</div>
|
||||
</Col>
|
||||
<Col style={{ overflow: 'hidden' }}>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>待处理</div>
|
||||
<div style={{ fontSize: 28, fontWeight: 700, color: '#FF7D00', lineHeight: '36px' }}>
|
||||
{statData.pending || 0}
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
</Col>
|
||||
|
||||
<Col xs={24} sm={12} md={8} lg={4} xl={4}>
|
||||
<Card bordered={false} bodyStyle={{ padding: '16px 20px' }} style={{ borderRadius: 8, whiteSpace: 'nowrap' }}>
|
||||
<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' }} />
|
||||
</div>
|
||||
</Col>
|
||||
<Col style={{ overflow: 'hidden' }}>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>处理中</div>
|
||||
<div style={{ fontSize: 28, fontWeight: 700, color: '#165DFF', lineHeight: '36px' }}>
|
||||
{statData.processing || 0}
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
</Col>
|
||||
|
||||
<Col xs={24} sm={12} md={8} lg={4} xl={4}>
|
||||
<Card bordered={false} bodyStyle={{ padding: '16px 20px' }} style={{ borderRadius: 8, whiteSpace: 'nowrap' }}>
|
||||
<Row align="middle" gutter={16}>
|
||||
<Col>
|
||||
<div style={{ width: 48, height: 48, background: '#E8FFEA', borderRadius: '50%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
|
||||
<CheckCircleOutlined style={{ fontSize: 24, color: '#00B42A' }} />
|
||||
</div>
|
||||
</Col>
|
||||
<Col style={{ overflow: 'hidden' }}>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>已关闭</div>
|
||||
<div style={{ fontSize: 28, fontWeight: 700, color: '#00B42A', lineHeight: '36px' }}>
|
||||
{statData.closed || 0}
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
{/* 表格 */}
|
||||
<Row gutter={16} style={{ marginBottom: 16 }}>
|
||||
<Col flex="auto" style={{ minWidth: 0 }}>
|
||||
<Card bordered={false} bodyStyle={{ padding: '16px 24px' }} style={{ borderRadius: 8 }}>
|
||||
<Spin spinning={loading}>
|
||||
<Table
|
||||
rowKey="id"
|
||||
columns={columns}
|
||||
dataSource={alarmList}
|
||||
pagination={false}
|
||||
size="middle"
|
||||
scroll={{ x: 'max-content' }}
|
||||
/>
|
||||
</Spin>
|
||||
<div style={{ display: 'flex', justifyContent: 'center', marginTop: 16 }}>
|
||||
<Pagination
|
||||
current={pageNum}
|
||||
pageSize={10}
|
||||
total={total}
|
||||
onChange={(p) => setPageNum(p)}
|
||||
showSizeChanger={false} showQuickJumper size="small"
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
{/* 三个图表 */}
|
||||
<Row gutter={16}>
|
||||
<Col span={8}>
|
||||
<Card bordered={false} title="告警趋势" style={{ borderRadius: 8 }}>
|
||||
<Line
|
||||
data={[
|
||||
{ date: '00:00', 严重: statData.levelStats?.[1] || 0 },
|
||||
{ date: '04:00', 严重: (statData.levelStats?.[1] || 0) + 1 },
|
||||
{ date: '08:00', 严重: (statData.levelStats?.[1] || 0) + 2 },
|
||||
{ date: '12:00', 严重: statData.levelStats?.[1] || 0 },
|
||||
{ date: '16:00', 严重: (statData.levelStats?.[1] || 0) + 1 },
|
||||
{ date: '20:00', 严重: statData.levelStats?.[1] || 0 },
|
||||
]}
|
||||
xField="date"
|
||||
yField={['严重']}
|
||||
color={['#F53F3F']}
|
||||
smooth
|
||||
height={220}
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Card bordered={false} title="告警分类占比" style={{ borderRadius: 8 }}>
|
||||
<Pie {...pieConfig} height={220} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Card bordered={false} title="告警状态统计" style={{ borderRadius: 8 }}>
|
||||
<Bar
|
||||
data={[
|
||||
{ name: '待处理', value: statData.pending || 0 },
|
||||
{ name: '处理中', value: statData.processing || 0 },
|
||||
{ name: '已关闭', value: statData.closed || 0 },
|
||||
]}
|
||||
xField="name"
|
||||
yField="value"
|
||||
color={['#165DFF']}
|
||||
height={220}
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
{/* 告警详情抽屉 —— 按设计稿完整实现 */}
|
||||
<Drawer
|
||||
title="告警详情"
|
||||
open={drawerVisible}
|
||||
onClose={() => setDrawerVisible(false)}
|
||||
width={420}
|
||||
destroyOnClose
|
||||
>
|
||||
<Spin spinning={detailLoading}>
|
||||
{currentAlarm && (
|
||||
<>
|
||||
{/* 告警头部 */}
|
||||
<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' }} />
|
||||
</div>
|
||||
<div style={{ flex: 1 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
||||
<span style={{ fontSize: 16, fontWeight: 700 }}>{currentAlarm.alarmTitle}</span>
|
||||
<Tag color={levelColor[currentAlarm.alarmLevel]} style={{ borderRadius: 2, border: 'none', color: '#fff' }}>
|
||||
{levelText[currentAlarm.alarmLevel]}
|
||||
</Tag>
|
||||
</div>
|
||||
<div style={{ fontSize: 12, color: '#86909C' }}>告警编号:{currentAlarm.alarmNo}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 告警基础信息 */}
|
||||
<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="发生时间">{dayjs(currentAlarm.alarmTime).format('YYYY-MM-DD HH:mm:ss')}</Descriptions.Item>
|
||||
<Descriptions.Item label="处理状态">
|
||||
<Tag color={statusColor[currentAlarm.handleStatus]}>{statusText[currentAlarm.handleStatus]}</Tag>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="负责人">{currentAlarm.handleUserName || '-'}</Descriptions.Item>
|
||||
</Descriptions>
|
||||
|
||||
{/* 告警描述 */}
|
||||
<Card size="small" title="告警描述" style={{ marginBottom: 16 }}>
|
||||
<div style={{ color: '#333' }}>{currentAlarm.alarmContent || '-'}</div>
|
||||
</Card>
|
||||
|
||||
{/* 根因分析 */}
|
||||
<Card size="small" title="根因分析建议" style={{ marginBottom: 16 }}>
|
||||
<div style={{ color: '#333' }}>{currentAlarm.rootCause || '-'}</div>
|
||||
</Card>
|
||||
|
||||
{/* 推荐处理措施 */}
|
||||
<Card size="small" title="推荐处理措施" style={{ marginBottom: 16 }}>
|
||||
<div style={{ color: '#333' }}>{currentAlarm.handleSuggestion || '-'}</div>
|
||||
</Card>
|
||||
|
||||
{/* 通知与订阅 */}
|
||||
<Card size="small" title="通知与订阅" style={{ marginBottom: 16 }}>
|
||||
<Row gutter={[8, 8]}>
|
||||
<Col span={8}>
|
||||
<Space>
|
||||
<Button style={{ borderRadius: 8 }} onClick={() => {
|
||||
setQueryParams({ deviceId: '', alarmLevel: '', handleStatus: '', beginTime: '', endTime: '' });
|
||||
fetchList();
|
||||
}}>重置</Button>
|
||||
<Button type="primary" style={{ borderRadius: 8, background: '#165DFF' }} onClick={fetchList}>
|
||||
<SearchOutlined />查询
|
||||
</Button>
|
||||
<Button style={{ borderRadius: 8 }} onClick={doExport}>
|
||||
<FileTextOutlined />导出
|
||||
</Button>
|
||||
<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} />
|
||||
</Space>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Space>
|
||||
<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} />
|
||||
</Space>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Space>
|
||||
<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} />
|
||||
</Space>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
{/* 统计卡片 —— 完全匹配后端接口 */}
|
||||
<Row gutter={16} style={{ marginBottom: 16, flexWrap: 'wrap' }}>
|
||||
<Col xs={24} sm={12} md={8} lg={4} xl={4}>
|
||||
<Card bordered={false} bodyStyle={{ padding: '16px 20px' }} style={{ borderRadius: 8, whiteSpace: 'nowrap' }}>
|
||||
<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' }} />
|
||||
</div>
|
||||
</Col>
|
||||
<Col style={{ overflow: 'hidden' }}>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>告警总数</div>
|
||||
<div style={{ fontSize: 28, fontWeight: 700, color: '#F53F3F', lineHeight: '36px' }}>
|
||||
{statData.total || 0}
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
</Col>
|
||||
{/* 底部按钮 */}
|
||||
<Button type="primary" block onClick={doHandle}>标记为已解决</Button>
|
||||
</>
|
||||
)}
|
||||
</Spin>
|
||||
</Drawer>
|
||||
|
||||
<Col xs={24} sm={12} md={8} lg={4} xl={4}>
|
||||
<Card bordered={false} bodyStyle={{ padding: '16px 20px' }} style={{ borderRadius: 8, whiteSpace: 'nowrap' }}>
|
||||
<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' }} />
|
||||
</div>
|
||||
</Col>
|
||||
<Col style={{ overflow: 'hidden' }}>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>严重告警</div>
|
||||
<div style={{ fontSize: 28, fontWeight: 700, color: '#F53F3F', lineHeight: '36px' }}>
|
||||
{statData.levelStats?.[1] || 0}
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
</Col>
|
||||
|
||||
<Col xs={24} sm={12} md={8} lg={4} xl={4}>
|
||||
<Card bordered={false} bodyStyle={{ padding: '16px 20px' }} style={{ borderRadius: 8, whiteSpace: 'nowrap' }}>
|
||||
<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' }} />
|
||||
</div>
|
||||
</Col>
|
||||
<Col style={{ overflow: 'hidden' }}>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>待处理</div>
|
||||
<div style={{ fontSize: 28, fontWeight: 700, color: '#FF7D00', lineHeight: '36px' }}>
|
||||
{statData.pending || 0}
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
</Col>
|
||||
|
||||
<Col xs={24} sm={12} md={8} lg={4} xl={4}>
|
||||
<Card bordered={false} bodyStyle={{ padding: '16px 20px' }} style={{ borderRadius: 8, whiteSpace: 'nowrap' }}>
|
||||
<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' }} />
|
||||
</div>
|
||||
</Col>
|
||||
<Col style={{ overflow: 'hidden' }}>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>处理中</div>
|
||||
<div style={{ fontSize: 28, fontWeight: 700, color: '#165DFF', lineHeight: '36px' }}>
|
||||
{statData.processing || 0}
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
</Col>
|
||||
|
||||
<Col xs={24} sm={12} md={8} lg={4} xl={4}>
|
||||
<Card bordered={false} bodyStyle={{ padding: '16px 20px' }} style={{ borderRadius: 8, whiteSpace: 'nowrap' }}>
|
||||
<Row align="middle" gutter={16}>
|
||||
<Col>
|
||||
<div style={{ width: 48, height: 48, background: '#E8FFEA', borderRadius: '50%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
|
||||
<CheckCircleOutlined style={{ fontSize: 24, color: '#00B42A' }} />
|
||||
</div>
|
||||
</Col>
|
||||
<Col style={{ overflow: 'hidden' }}>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>已关闭</div>
|
||||
<div style={{ fontSize: 28, fontWeight: 700, color: '#00B42A', lineHeight: '36px' }}>
|
||||
{statData.closed || 0}
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
{/* 表格 */}
|
||||
<Row gutter={16} style={{ marginBottom: 16 }}>
|
||||
<Col flex="auto" style={{ minWidth: 0 }}>
|
||||
<Card bordered={false} bodyStyle={{ padding: '16px 24px' }} style={{ borderRadius: 8 }}>
|
||||
<Spin spinning={loading}>
|
||||
<Table
|
||||
rowKey="id"
|
||||
columns={columns}
|
||||
dataSource={alarmList}
|
||||
pagination={false}
|
||||
size="middle"
|
||||
scroll={{ x: 'max-content' }}
|
||||
/>
|
||||
</Spin>
|
||||
<div style={{ display: 'flex', justifyContent: 'center', marginTop: 16 }}>
|
||||
<Pagination
|
||||
current={pageNum}
|
||||
pageSize={10}
|
||||
total={total}
|
||||
onChange={(p) => setPageNum(p)}
|
||||
showSizeChanger={false} showQuickJumper size="small"
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
{/* 三个图表 */}
|
||||
<Row gutter={16}>
|
||||
<Col span={8}>
|
||||
<Card bordered={false} title="告警趋势" style={{ borderRadius: 8 }}>
|
||||
<Line
|
||||
data={[
|
||||
{ date: '00:00', 严重: statData.levelStats?.[1] || 0 },
|
||||
{ date: '04:00', 严重: (statData.levelStats?.[1] || 0) + 1 },
|
||||
{ date: '08:00', 严重: (statData.levelStats?.[1] || 0) + 2 },
|
||||
{ date: '12:00', 严重: statData.levelStats?.[1] || 0 },
|
||||
{ date: '16:00', 严重: (statData.levelStats?.[1] || 0) + 1 },
|
||||
{ date: '20:00', 严重: statData.levelStats?.[1] || 0 },
|
||||
]}
|
||||
xField="date"
|
||||
yField={['严重']}
|
||||
color={['#F53F3F']}
|
||||
smooth
|
||||
height={220}
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Card bordered={false} title="告警分类占比" style={{ borderRadius: 8 }}>
|
||||
<Pie {...pieConfig} height={220} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Card bordered={false} title="告警状态统计" style={{ borderRadius: 8 }}>
|
||||
<Bar
|
||||
data={[
|
||||
{ name: '待处理', value: statData.pending || 0 },
|
||||
{ name: '处理中', value: statData.processing || 0 },
|
||||
{ name: '已关闭', value: statData.closed || 0 },
|
||||
]}
|
||||
xField="name"
|
||||
yField="value"
|
||||
color={['#165DFF']}
|
||||
height={220}
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
|
||||
{/* 右侧详情 */}
|
||||
{detailVisible && currentAlarm && (
|
||||
<div style={{ width: 380, flexShrink: 0 }}>
|
||||
<style>{`@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }`}</style>
|
||||
<Card bordered={false} title="告警详情" extra={<CloseOutlined onClick={() => setDetailVisible(false)} />} style={{ borderRadius: 8 }}>
|
||||
<Spin spinning={detailLoading}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 20 }}>
|
||||
<div style={{ width: 40, height: 40, background: '#FFF1F0', borderRadius: '50%', display: 'flex', justifyContent: 'center', alignItems: 'center', marginRight: 12 }}>
|
||||
<ExclamationCircleOutlined style={{ fontSize: 20, color: '#F53F3F' }} />
|
||||
</div>
|
||||
<div style={{ flex: 1 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
||||
<span style={{ fontSize: 16, fontWeight: 700 }}>{currentAlarm.content}</span>
|
||||
<Tag color={levelColor[currentAlarm.alarmLevel]} style={{ borderRadius: 2, border: 'none', color: '#fff' }}>
|
||||
{levelText[currentAlarm.alarmLevel]}
|
||||
</Tag>
|
||||
</div>
|
||||
<div style={{ fontSize: 12, color: '#86909C' }}>告警编号:AL{currentAlarm.id}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Row gutter={[16, 12]} style={{ marginBottom: 24 }}>
|
||||
<Col span={12}><div style={{ fontSize: 12, color: '#86909C' }}>设备ID</div><div>{currentAlarm.deviceId}</div></Col>
|
||||
<Col span={12}><div style={{ fontSize: 12, color: '#86909C' }}>状态</div><Tag color={statusColor[currentAlarm.handleStatus]}>{statusText[currentAlarm.handleStatus]}</Tag></Col>
|
||||
<Col span={24}><div style={{ fontSize: 12, color: '#86909C' }}>发生时间</div><div>{currentAlarm.createTime}</div></Col>
|
||||
</Row>
|
||||
|
||||
<Button type="primary" block onClick={doHandle}>标记为已解决</Button>
|
||||
</Spin>
|
||||
</Card>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,125 +1,165 @@
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { Card, Row, Col, Space } from 'antd';
|
||||
import { AreaChartOutlined } from '@ant-design/icons';
|
||||
import {
|
||||
BellOutlined,
|
||||
ExclamationCircleOutlined,
|
||||
ClockCircleOutlined,
|
||||
CheckCircleOutlined
|
||||
} from '@ant-design/icons';
|
||||
import * as echarts from 'echarts';
|
||||
|
||||
const AntdCard = Card as any;
|
||||
// 接口引入
|
||||
import { getAlarmStatistics } from '../../api/alarmApi.js';
|
||||
|
||||
const AlarmStatistics = () => {
|
||||
// 图表 ref
|
||||
const barChartRef = useRef(null);
|
||||
const pieChartRef = useRef(null);
|
||||
|
||||
const [statData, setStatData] = useState({
|
||||
total: 0,
|
||||
levelStats: {},
|
||||
pending: 0,
|
||||
processing: 0,
|
||||
closed: 0,
|
||||
});
|
||||
|
||||
// 获取统计(修复:接口 code = 0 才是成功)
|
||||
const fetchStat = async () => {
|
||||
try {
|
||||
const res = await getAlarmStatistics();
|
||||
if (res.code === 200) {
|
||||
setStatData(res.data || {});
|
||||
}
|
||||
} catch (err) { }
|
||||
};
|
||||
|
||||
// 柱状图
|
||||
useEffect(() => {
|
||||
if (!barChartRef.current) return;
|
||||
const barChart = echarts.init(barChartRef.current);
|
||||
barChart.setOption({
|
||||
title: { text: '近7天告警趋势' },
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: ['1日', '2日', '3日', '4日', '5日', '6日', '7日']
|
||||
},
|
||||
const chart = echarts.init(barChartRef.current);
|
||||
|
||||
const option = {
|
||||
title: { text: '近7天告警趋势', textStyle: { fontSize: 14 } },
|
||||
xAxis: { type: 'category', data: ['1日', '2日', '3日', '4日', '5日', '6日', '7日'] },
|
||||
yAxis: { type: 'value' },
|
||||
series: [
|
||||
{
|
||||
data: [5, 8, 12, 9, 15, 7, 12],
|
||||
type: 'bar',
|
||||
itemStyle: { color: '#1677ff' }
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const resizeFn = () => barChart.resize();
|
||||
window.addEventListener('resize', resizeFn);
|
||||
|
||||
return () => {
|
||||
barChart.dispose();
|
||||
window.removeEventListener('resize', resizeFn);
|
||||
series: [{
|
||||
data: [5, 8, 12, 9, 15, 7, statData.total || 2],
|
||||
type: 'bar',
|
||||
itemStyle: { color: '#165DFF', borderRadius: 4 }
|
||||
}]
|
||||
};
|
||||
}, []);
|
||||
|
||||
chart.setOption(option);
|
||||
const resize = () => chart.resize();
|
||||
window.addEventListener('resize', resize);
|
||||
return () => {
|
||||
chart.dispose();
|
||||
window.removeEventListener('resize', resize);
|
||||
};
|
||||
}, [statData]);
|
||||
|
||||
// 饼图
|
||||
useEffect(() => {
|
||||
if (!pieChartRef.current) return;
|
||||
const pieChart = echarts.init(pieChartRef.current);
|
||||
pieChart.setOption({
|
||||
const chart = echarts.init(pieChartRef.current);
|
||||
|
||||
const pieData = [
|
||||
{ value: statData.levelStats?.[1] || 0, name: '严重告警' },
|
||||
{ value: statData.levelStats?.[2] || 0, name: '重要告警' },
|
||||
{ value: statData.levelStats?.[3] || 0, name: '一般告警' },
|
||||
{ value: statData.levelStats?.[4] || 0, name: '提示告警' },
|
||||
].filter(i => i.value > 0);
|
||||
|
||||
const option = {
|
||||
title: { text: '告警级别分布' },
|
||||
tooltip: { trigger: 'item' },
|
||||
series: [
|
||||
{
|
||||
type: 'pie',
|
||||
radius: '50%',
|
||||
data: [
|
||||
{ value: 15, name: '严重告警' },
|
||||
{ value: 30, name: '警告告警' },
|
||||
{ value: 25, name: '提示告警' }
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const resizeFn = () => pieChart.resize();
|
||||
window.addEventListener('resize', resizeFn);
|
||||
|
||||
return () => {
|
||||
pieChart.dispose();
|
||||
window.removeEventListener('resize', resizeFn);
|
||||
legend: { bottom: 0 },
|
||||
series: [{
|
||||
type: 'pie',
|
||||
radius: ['40%', '70%'],
|
||||
data: pieData.length ? pieData : [{ value: 1, name: '暂无数据' }],
|
||||
color: ['#F53F3F', '#FF7D00', '#F7BA1E', '#165DFF'],
|
||||
}]
|
||||
};
|
||||
|
||||
chart.setOption(option);
|
||||
const resize = () => chart.resize();
|
||||
window.addEventListener('resize', resize);
|
||||
return () => {
|
||||
chart.dispose();
|
||||
window.removeEventListener('resize', resize);
|
||||
};
|
||||
}, [statData]);
|
||||
|
||||
useEffect(() => {
|
||||
fetchStat();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div style={{ padding: 24 }}>
|
||||
{/* 顶部统计卡片 保留你原来的图标样式 */}
|
||||
<AntdCard title="告警概览" style={{ marginBottom: 24 }}>
|
||||
<Row gutter={16}>
|
||||
<Col span={8}>
|
||||
<Space>
|
||||
<div style={{ background: '#e6f4ff', padding: 8, borderRadius: 8 }}>
|
||||
<AreaChartOutlined style={{ color: '#1677ff', fontSize: 20 }} />
|
||||
<div style={{ padding: 24, background: '#f5f7fa', minHeight: '100vh' }}>
|
||||
<Card title="告警概览" bordered={false} style={{ marginBottom: 24, borderRadius: 8 }}>
|
||||
<Row gutter={16} align="middle">
|
||||
<Col xs={24} sm={12} md={6}>
|
||||
<Space size={16}>
|
||||
<div style={{ width: 48, height: 48, background: '#FFF1F0', borderRadius: '50%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
|
||||
<BellOutlined style={{ fontSize: 24, color: '#F53F3F' }} />
|
||||
</div>
|
||||
<div>
|
||||
<div style={{ color: '#666' }}>今日告警</div>
|
||||
<div style={{ fontWeight: 600, fontSize: 18 }}>12</div>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>告警总数</div>
|
||||
<div style={{ fontSize: 24, fontWeight: 700 }}>{statData.total || 0}</div>
|
||||
</div>
|
||||
</Space>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Space>
|
||||
<div style={{ background: '#fff7e6', padding: 8, borderRadius: 8 }}>
|
||||
<AreaChartOutlined style={{ color: '#fa8c16', fontSize: 20 }} />
|
||||
|
||||
<Col xs={24} sm={12} md={6}>
|
||||
<Space size={16}>
|
||||
<div style={{ width: 48, height: 48, background: '#FFF1F0', borderRadius: '50%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
|
||||
<ExclamationCircleOutlined style={{ fontSize: 24, color: '#F53F3F' }} />
|
||||
</div>
|
||||
<div>
|
||||
<div style={{ color: '#666' }}>本周告警</div>
|
||||
<div style={{ fontWeight: 600, fontSize: 18 }}>45</div>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>严重告警</div>
|
||||
<div style={{ fontSize: 24, fontWeight: 700 }}>{statData.levelStats?.[1] || 0}</div>
|
||||
</div>
|
||||
</Space>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Space>
|
||||
<div style={{ background: '#f6ffed', padding: 8, borderRadius: 8 }}>
|
||||
<AreaChartOutlined style={{ color: '#52c41a', fontSize: 20 }} />
|
||||
|
||||
<Col xs={24} sm={12} md={6}>
|
||||
<Space size={16}>
|
||||
<div style={{ width: 48, height: 48, background: '#FFF7E8', borderRadius: '50%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
|
||||
<ClockCircleOutlined style={{ fontSize: 24, color: '#FF7D00' }} />
|
||||
</div>
|
||||
<div>
|
||||
<div style={{ color: '#666' }}>本月告警</div>
|
||||
<div style={{ fontWeight: 600, fontSize: 18 }}>128</div>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>待处理</div>
|
||||
<div style={{ fontSize: 24, fontWeight: 700 }}>{statData.pending || 0}</div>
|
||||
</div>
|
||||
</Space>
|
||||
</Col>
|
||||
|
||||
<Col xs={24} sm={12} md={6}>
|
||||
<Space size={16}>
|
||||
<div style={{ width: 48, height: 48, background: '#E8FFEA', borderRadius: '50%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
|
||||
<CheckCircleOutlined style={{ fontSize: 24, color: '#00B42A' }} />
|
||||
</div>
|
||||
<div>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>已关闭</div>
|
||||
<div style={{ fontSize: 24, fontWeight: 700 }}>{statData.closed || 0}</div>
|
||||
</div>
|
||||
</Space>
|
||||
</Col>
|
||||
</Row>
|
||||
</AntdCard>
|
||||
</Card>
|
||||
|
||||
{/* 两个图表 左右各一半 并排显示 不空洞 */}
|
||||
<Row gutter={16}>
|
||||
<Col span={12}>
|
||||
<AntdCard title="告警趋势统计">
|
||||
<div ref={barChartRef} style={{ width: '100%', height: 350 }} />
|
||||
</AntdCard>
|
||||
<Col xs={24} md={12}>
|
||||
<Card bordered={false} style={{ borderRadius: 8 }}>
|
||||
<div ref={barChartRef} style={{ width: '100%', height: 360 }} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<AntdCard title="告警分类统计">
|
||||
<div ref={pieChartRef} style={{ width: '100%', height: 350 }} />
|
||||
</AntdCard>
|
||||
|
||||
<Col xs={24} md={12}>
|
||||
<Card bordered={false} style={{ borderRadius: 8 }}>
|
||||
<div ref={pieChartRef} style={{ width: '100%', height: 360 }} />
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user