This commit is contained in:
mmc
2026-05-07 17:09:19 +08:00
parent 9cf26ce2bd
commit 5ef889e435
5 changed files with 439 additions and 112 deletions

View File

@@ -1,21 +1,157 @@
import React from 'react';
import { Card, Row, Col, Space, Empty } from 'antd';
import { AlertOutlined, CloseCircleOutlined, ExclamationCircleOutlined, CheckCircleOutlined } from '@ant-design/icons';
import React, { useState } from 'react';
import {
Card, Row, Col, Select, DatePicker, Input, Button, Space, Table, Tag,
Statistic, Typography, Tabs
} from 'antd';
import {
BellOutlined, ClockCircleOutlined, CheckCircleOutlined, ExclamationCircleOutlined
} from '@ant-design/icons';
const AntdCard = Card as any;
const { RangePicker } = DatePicker;
const { Text } = Typography;
const AlarmOverview = () => {
return (
<div style={{ padding: 24 }}>
<Row gutter={16} style={{ marginBottom: 24 }}>
<Col span={6}><AntdCard size="small"><Space><div style={{ background: '#e6f4ff', borderRadius: 8, padding: 8 }}><AlertOutlined style={{ color: '#1677ff', fontSize: 20 }} /></div><div><div style={{ fontSize: 13, color: '#666' }}>告警总数</div><div style={{ fontWeight: 600 }}>45</div></div></Space></AntdCard></Col>
<Col span={6}><AntdCard size="small"><Space><div style={{ background: '#fff2f0', borderRadius: 8, padding: 8 }}><CloseCircleOutlined style={{ color: '#ff4d4f', fontSize: 20 }} /></div><div><div style={{ fontSize: 13, color: '#666' }}>严重告警</div><div style={{ fontWeight: 600 }}>12</div></div></Space></AntdCard></Col>
<Col span={6}><AntdCard size="small"><Space><div style={{ background: '#fff7e6', borderRadius: 8, padding: 8 }}><ExclamationCircleOutlined style={{ color: '#fa8c16', fontSize: 20 }} /></div><div><div style={{ fontSize: 13, color: '#666' }}>警告告警</div><div style={{ fontWeight: 600 }}>20</div></div></Space></AntdCard></Col>
<Col span={6}><AntdCard size="small"><Space><div style={{ background: '#f6ffed', borderRadius: 8, padding: 8 }}><CheckCircleOutlined style={{ color: '#52c41a', fontSize: 20 }} /></div><div><div style={{ fontSize: 13, color: '#666' }}>已处理</div><div style={{ fontWeight: 600 }}>13</div></div></Space></AntdCard></Col>
</Row>
<AntdCard title="告警地图"><Empty description="告警地图(可接入GIS)" /></AntdCard>
</div>
);
// 级别 + 状态颜色
const levelColor = {
严重: 'red',
重要: 'orange',
一般: 'gold',
提示: 'blue'
};
export default AlarmOverview;
const statusColor = {
处理中: 'processing',
待处理: 'warning',
已关闭: 'success'
};
// 模拟数据
const mockAlerts = [
{ id: 'DEVICE_OFFLINE_CAM-02', content: '设备离线', device: 'CAM-02', level: '提示', time: '2026-04-28 17:22:04', duration: '1小时23分', status: '待处理', handler: '-' },
{ id: 'INV_TEMP_HIGH_INV-A02', content: '逆变器温度过高', device: 'INV-A02', level: '重要', time: '2026-04-28 17:21:54', duration: '1小时23分', status: '待处理', handler: '-' },
{ id: 'AL-20260428-001', content: 'INV-A02 温度过高', device: 'INV-A02', level: '重要', time: '2026-04-28 10:54:45', duration: '36分钟', status: '待处理', handler: '-' },
{ id: 'AL-20260428-002', content: 'CMB-A01 组串电流异常', device: 'CMB-A01', level: '一般', time: '2026-04-28 10:32:45', duration: '52分钟', status: '处理中', handler: '张运维' },
{ id: 'AL-20260428-003', content: 'CAM-02 视频离线', device: 'CAM-02', level: '提示', time: '2026-04-28 09:32:45', duration: '0分钟', status: '待处理', handler: '-' },
];
export default function AlarmCenterPage() {
const [selectedAlert, setSelectedAlert] = useState<any>(mockAlerts[0]);
const [detailVisible, setDetailVisible] = useState(true);
const columns = [
{ title: '告警编号', dataIndex: 'id', width: 180 },
{ title: '告警内容', dataIndex: 'content', ellipsis: true },
{ title: '来源设备', dataIndex: 'device', width: 120 },
{ title: '告警级别', dataIndex: 'level', width: 100, render: l => <Tag color={levelColor[l]}>{l}</Tag> },
{ title: '发生时间', dataIndex: 'time', width: 160 },
{ title: '持续时长', dataIndex: 'duration', width: 100 },
{ title: '处理状态', dataIndex: 'status', width: 100, render: s => <Tag color={statusColor[s]}>{s}</Tag> },
{ title: '负责人', dataIndex: 'handler', width: 100 },
{
title: '操作', width: 120,
render: (_, record) => (
<Space>
<Button type="link" onClick={() => { setSelectedAlert(record); setDetailVisible(true); }}>查看</Button>
<Button type="link">更多</Button>
</Space>
)
}
];
return (
<div style={{ background: '#f5f7fa', minHeight: '100vh', padding: '0 24px 24px' }}>
{/* ===================== 统一宽度容器 ===================== */}
<div style={{ display: 'flex', gap: 16, marginTop: 16 }}>
{/* ===================== 左侧:所有模块宽度完全一致 ===================== */}
<div style={{ flex: 1 }}>
{/* 筛选卡片 */}
<Card style={{ borderRadius: 8, border: 'none', marginBottom: 16 }} bodyStyle={{ padding: '16px' }}>
<Row gutter={16} align="middle">
<Col><Select placeholder="告警级别" style={{ width: 120 }} /></Col>
<Col><Select placeholder="告警类型" style={{ width: 120 }} /></Col>
<Col><Select placeholder="设备类型" style={{ width: 120 }} /></Col>
<Col><RangePicker placeholder={['开始', '结束']} style={{ width: 240 }} /></Col>
<Col><Select placeholder="处理状态" style={{ width: 120 }} /></Col>
<Col flex="auto"><Input placeholder="搜索告警编号/内容/设备" style={{ width: '100%' }} /></Col>
<Col><Space><Button>重置</Button><Button type="primary">查询</Button></Space></Col>
</Row>
</Card>
{/* 统计卡片 */}
<Row gutter={16} style={{ marginBottom: 16 }}>
<Col span={4}><Card bordered={false} style={{ borderRadius: 8 }}><Statistic title="今日告警总数" value={5} prefix={<BellOutlined style={{ color: '#ff4d4f' }} />} valueStyle={{ fontSize: 22 }} /><div style={{ fontSize: 12, color: '#999' }}>昨日 28</div></Card></Col>
<Col span={4}><Card bordered={false} style={{ borderRadius: 8 }}><Statistic title="严重告警" value={0} prefix={<ExclamationCircleOutlined style={{ color: '#ff4d4f' }} />} valueStyle={{ fontSize: 22 }} /><div style={{ fontSize: 12, color: '#999' }}>重要 2</div></Card></Col>
<Col span={4}><Card bordered={false} style={{ borderRadius: 8 }}><Statistic title="处理中" value={1} prefix={<ClockCircleOutlined style={{ color: '#faad14' }} />} valueStyle={{ fontSize: 22 }} /><div style={{ fontSize: 12, color: '#999' }}>待处理 4</div></Card></Col>
<Col span={4}><Card bordered={false} style={{ borderRadius: 8 }}><Statistic title="已关闭" value={0} prefix={<CheckCircleOutlined style={{ color: '#52c41a' }} />} valueStyle={{ fontSize: 22 }} /><div style={{ fontSize: 12, color: '#999' }}>闭环完成</div></Card></Col>
<Col span={4}><Card bordered={false} style={{ borderRadius: 8 }}><Statistic title="平均响应" value="49分钟" prefix={<ClockCircleOutlined style={{ color: '#1890ff' }} />} valueStyle={{ fontSize: 22 }} /><div style={{ fontSize: 12, color: '#999' }}>时间估算</div></Card></Col>
</Row>
{/* 告警列表(宽度 = 筛选卡片 完全一致) */}
<Card bordered={false} style={{ borderRadius: 8 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}>
<div>
<Typography.Text strong style={{ fontSize: 16 }}>告警列表(共8条)</Typography.Text><br />
<Text type="secondary" style={{ fontSize: 12 }}>点击告警查看详情</Text>
</div>
</div>
<Table
rowKey="id"
columns={columns}
dataSource={mockAlerts}
pagination={{ pageSize: 8 }}
scroll={{ x: '100%' }}
style={{ width: '100%' }}
/>
</Card>
</div>
{/* ===================== 右侧详情面板 ===================== */}
{detailVisible && selectedAlert && (
<div style={{ width: 360, flexShrink: 0 }}>
<Card title="告警详情" bordered={false} style={{ borderRadius: 8, height: '100%' }}>
<div style={{ marginBottom: 20 }}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div style={{ display: 'flex', alignItems: 'center' }}>
<ExclamationCircleOutlined style={{ color: '#ff4d4f', marginRight: 8 }} />
<span style={{ fontSize: 16, fontWeight: 500 }}>{selectedAlert.content}</span>
</div>
<Tag color={levelColor[selectedAlert.level]}>{selectedAlert.level}</Tag>
</div>
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>{selectedAlert.id}</div>
</div>
<div style={{ background: '#fafafa', borderRadius: 8, padding: 16, marginBottom: 16 }}>
<Row gutter={[16, 16]}>
<Col span={12}><div style={{ fontSize: 12, color: '#888' }}>来源设备</div><div>{selectedAlert.device}</div></Col>
<Col span={12}><div style={{ fontSize: 12, color: '#888' }}>发生时间</div><div>{selectedAlert.time}</div></Col>
<Col span={12}><div style={{ fontSize: 12, color: '#888' }}>持续时长</div><div>{selectedAlert.duration}</div></Col>
<Col span={12}><div style={{ fontSize: 12, color: '#888' }}>处理状态</div><div>{selectedAlert.status}</div></Col>
</Row>
</div>
<div style={{ marginBottom: 16 }}>
<div style={{ fontWeight: 500, marginBottom: 8 }}>根因分析建议</div>
<div style={{ fontSize: 12, color: '#666', lineHeight: 1.7 }}>
设备离线/网络异常<br />
电源或通讯模块故障<br />
现场信号弱或采集器异常
</div>
</div>
<Space direction="vertical" style={{ width: '100%' }}>
<Button type="primary" block>确认告警</Button>
<Button block>标记处理中</Button>
<Button block danger>关闭告警</Button>
</Space>
</Card>
</div>
)}
</div>
</div>
);
}