import React, { useState } from 'react'; import { Card, Row, Col, Select, DatePicker, Input, Button, Space, Table, Tag, Statistic, Typography } from 'antd'; import { BellOutlined, ClockCircleOutlined, CheckCircleOutlined, ExclamationCircleOutlined } from '@ant-design/icons'; import { Line, Pie, Bar } from '@ant-design/charts'; const { RangePicker } = DatePicker; const { Text } = Typography; // 级别 + 状态颜色 const levelColor = { 严重: 'red', 重要: 'orange', 一般: 'gold', 提示: 'blue' }; 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(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 => {l} }, { title: '发生时间', dataIndex: 'time', width: 160 }, { title: '持续时长', dataIndex: 'duration', width: 100 }, { title: '处理状态', dataIndex: 'status', width: 100, render: s => {s} }, { title: '负责人', dataIndex: 'handler', width: 100 }, { title: '操作', width: 120, render: (_, record) => ( ) } ]; // 告警趋势图配置 const trendConfig = { data: [ { date: '05-19', 严重: 12, 重要: 5, 一般: 3, 提示: 2 }, { date: '05-20', 严重: 30, 重要: 16, 一般: 9, 提示: 6 }, { date: '05-21', 严重: 23, 重要: 11, 一般: 7, 提示: 5 }, { date: '05-22', 严重: 25, 重要: 17, 一般: 10, 提示: 4 }, { date: '05-23', 严重: 19, 重要: 9, 一般: 13, 提示: 7 }, { date: '05-24', 严重: 24, 重要: 18, 一般: 16, 提示: 8 }, { date: '05-25', 严重: 36, 重要: 29, 一般: 22, 提示: 13 } ], xField: 'date', yField: ['严重', '重要', '一般', '提示'], color: ['#ff4d4f', '#faad14', '#52c41a', '#1890ff'], smooth: true, legend: { position: 'top-left' }, label: { style: { fill: '#aaa' } } }; // 告警分类占比配置 const pieConfig = { data: [ { type: '严重', value: 8, percent: 22.2 }, { type: '重要', value: 12, percent: 33.3 }, { type: '一般', value: 11, percent: 30.6 }, { type: '提示', value: 5, percent: 13.9 } ], angleField: 'value', colorField: 'type', color: ['#ff4d4f', '#faad14', '#52c41a', '#1890ff'], radius: 0.8, innerRadius: 0.6, label: { type: 'outer', content: '{name}\n{percentage:.1%} ({value})' }, annotations: [ { type: 'text', style: { text: '36\n总告警', x: '50%', y: '50%', textAlign: 'center', fontSize: 20, fontWeight: 'bold' } } ] }; // 告警来源设备分布 const barConfig = { data: [ { device: '逆变器', count: 14, percent: 38.9 }, { device: '汇流箱', count: 8, percent: 22.2 }, { device: '组串', count: 6, percent: 16.7 }, { device: '气象站', count: 3, percent: 8.3 }, { device: '电表', count: 3, percent: 8.3 }, { device: '其他', count: 2, percent: 5.6 } ], xField: 'count', yField: 'device', colorField: 'device', color: ['#1890ff', '#40a9ff', '#69c0ff', '#91d5ff', '#bae7ff', '#e6f7ff'], barWidthRatio: 0.6, label: { position: 'right', style: { fill: '#666' }, content: (item) => `${item.count}(${item.percent}%)` } }; return (
{/* ===================== 统一宽度容器 ===================== */}
{/* ===================== 左侧:所有模块宽度完全一致 ===================== */}
{/* 统一容器:保证 筛选 + 统计 宽度完全一样 */}
{/* 筛选卡片 */} {/* 统计卡片 - 现在和筛选卡片一样宽 */}
} valueStyle={{ fontSize: 28, fontWeight: 700, color: '#ff4d4f' }} />
昨日 28
} valueStyle={{ fontSize: 28, fontWeight: 700, color: '#ff4d4f' }} />
重要 2
} valueStyle={{ fontSize: 28, fontWeight: 700, color: '#faad14' }} />
待处理 4
} valueStyle={{ fontSize: 28, fontWeight: 700, color: '#52c41a' }} />
闭环完成
} valueStyle={{ fontSize: 28, fontWeight: 700, color: '#1890ff' }} />
时间估算
{/* 告警列表(宽度 = 筛选卡片 完全一致) */} {/* 告警列表 + 右侧详情(不换行、表格自适应、可横向滚动) */}
{/* 左侧告警列表:自适应宽度 + 横向滚动 */}
告警列表(共8条)
点击告警查看详情
{/* 右侧详情:固定 360px,不挤压、不换行 */} {detailVisible && selectedAlert && (
{/* 可滚动内容区域 */}
{selectedAlert.content}
{selectedAlert.level}
{selectedAlert.id}
来源设备
{selectedAlert.device}
发生时间
{selectedAlert.time}
持续时长
{selectedAlert.duration}
处理状态
{selectedAlert.status}
根因分析建议
设备离线/网络异常
电源或通讯模块故障
现场信号弱或采集器异常
{/* 固定底部操作按钮 */}
)} {/* 三个图表卡片:告警趋势 + 分类占比 + 设备分布 */} 更多 } > 更多 } > 更多} > {/* ===================== 右侧详情面板:高度拉伸至视口 ===================== */} ); }