总览和 告警 界面

This commit is contained in:
mmc
2026-05-07 20:25:14 +08:00
parent 5ef889e435
commit dea212151a
3 changed files with 834 additions and 468 deletions

View File

@@ -1,11 +1,12 @@
import React, { useState } from 'react';
import {
Card, Row, Col, Select, DatePicker, Input, Button, Space, Table, Tag,
Statistic, Typography, Tabs
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;
@@ -57,101 +58,326 @@ export default function AlarmCenterPage() {
}
];
// 告警趋势图配置
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 (
<div style={{ background: '#f5f7fa', minHeight: '100vh', padding: '0 24px 24px' }}>
{/* ===================== 统一宽度容器 ===================== */}
<div style={{ display: 'flex', gap: 16, marginTop: 16 }}>
<div style={{ display: 'flex', gap: 16, marginTop: 16, width: '100%' }}>
{/* ===================== 左侧:所有模块宽度完全一致 ===================== */}
<div style={{ flex: 1 }}>
<div style={{ flex: 1, minWidth: 0 }}>
{/* 筛选卡片 */}
<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>
{/* 统一容器:保证 筛选 + 统计 宽度完全一样 */}
<div style={{ width: "100%" }}>
{/* 统计卡片 */}
<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 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>
{/* 告警列表(宽度 = 筛选卡片 完全一致) */}
<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
style={{
display: "flex",
gap: "16px",
marginBottom: 16,
width: "100%"
}}
>
<div style={{ flex: 1 }}>
<Card bordered={false} style={{ borderRadius: 8, padding: '12px' }} bodyStyle={{ padding: '12px 0 0 0' }}>
<Statistic
title="今日告警总数"
value={5}
prefix={<BellOutlined style={{ color: '#ff4d4f' }} />}
valueStyle={{ fontSize: 28, fontWeight: 700, color: '#ff4d4f' }}
/>
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>昨日 28</div>
</Card>
</div>
<div style={{ flex: 1 }}>
<Card bordered={false} style={{ borderRadius: 8, padding: '12px' }} bodyStyle={{ padding: '8px 0 0 0' }}>
<Statistic
title="严重告警"
value={0}
prefix={<ExclamationCircleOutlined style={{ color: '#ff4d4f' }} />}
valueStyle={{ fontSize: 28, fontWeight: 700, color: '#ff4d4f' }}
/>
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>重要 2</div>
</Card>
</div>
<div style={{ flex: 1 }}>
<Card bordered={false} style={{ borderRadius: 8, padding: '12px' }} bodyStyle={{ padding: '8px 0 0 0' }}>
<Statistic
title="处理中"
value={1}
prefix={<ClockCircleOutlined style={{ color: '#faad14' }} />}
valueStyle={{ fontSize: 28, fontWeight: 700, color: '#faad14' }}
/>
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>待处理 4</div>
</Card>
</div>
<div style={{ flex: 1 }}>
<Card bordered={false} style={{ borderRadius: 8, padding: '12px' }} bodyStyle={{ padding: '8px 0 0 0' }}>
<Statistic
title="已关闭"
value={0}
prefix={<CheckCircleOutlined style={{ color: '#52c41a' }} />}
valueStyle={{ fontSize: 28, fontWeight: 700, color: '#52c41a' }}
/>
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>闭环完成</div>
</Card>
</div>
<div style={{ flex: 1 }}>
<Card bordered={false} style={{ borderRadius: 8, padding: '12px' }} bodyStyle={{ padding: '8px 0 0 0' }}>
<Statistic
title="平均响应"
value="49分钟"
prefix={<ClockCircleOutlined style={{ color: '#1890ff' }} />}
valueStyle={{ fontSize: 28, fontWeight: 700, color: '#1890ff' }}
/>
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>时间估算</div>
</Card>
</div>
</div>
<Table
rowKey="id"
columns={columns}
dataSource={mockAlerts}
pagination={{ pageSize: 8 }}
scroll={{ x: '100%' }}
style={{ width: '100%' }}
/>
</Card>
</div>
{/* 告警列表(宽度 = 筛选卡片 完全一致) */}
{/* 告警列表 + 右侧详情(不换行、表格自适应、可横向滚动) */}
<div style={{
display: 'flex',
gap: 16,
width: '100%',
flexWrap: 'nowrap', /* 强制不换行 */
alignItems: 'stretch', /* 高度对齐 */
marginBottom: 16
}}>
{/* 左侧告警列表:自适应宽度 + 横向滚动 */}
<div style={{
flex: 1,
minWidth: 0, /* 关键:允许表格缩小 */
}}>
<Card
bordered={false}
style={{
borderRadius: 8,
marginBottom: 16,
height: '100%',
}}
>
<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: 'max-content' }} /* 表格超出自动横向滚动 */
style={{ width: '100%' }}
/>
</Card>
</div>
{/* 右侧详情:固定 360px,不挤压、不换行 */}
{detailVisible && selectedAlert && (
<div style={{
width: 360,
flexShrink: 0, /* 关键:不被挤压 */
display: 'flex',
flexDirection: 'column',
}}>
<Card
title="告警详情"
bordered={false}
style={{
borderRadius: 8,
height: '100%',
display: 'flex',
flexDirection: 'column',
overflow: 'hidden'
}}
bodyStyle={{
padding: '16px',
display: 'flex',
flexDirection: 'column',
flex: 1,
overflow: 'hidden'
}}
>
{/* 可滚动内容区域 */}
<div style={{ flex: 1, overflow: 'auto', paddingRight: 8 }}>
<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>
</div>
{/* 固定底部操作按钮 */}
<div style={{ marginTop: 12, paddingTop: 12, borderTop: '1px solid #f0f0f0' }}>
<Space direction="vertical" style={{ width: '100%' }}>
<Button type="primary" block>确认告警</Button>
<Button block>标记处理中</Button>
<Button block danger>关闭告警</Button>
</Space>
</div>
</Card>
</div>
)}
</div>
{/* 三个图表卡片:告警趋势 + 分类占比 + 设备分布 */}
<Row gutter={16}>
<Col span={8}>
<Card
bordered={false}
style={{ borderRadius: 8 }}
title="告警趋势"
extra={<Button type="link">更多 </Button>}
>
<Line {...trendConfig} height={180} />
</Card>
</Col>
<Col span={8}>
<Card
bordered={false}
style={{ borderRadius: 8 }}
title="告警分类占比"
extra={<Button type="link">更多 </Button>}
>
<Pie {...pieConfig} height={180} />
</Card>
</Col>
<Col span={8}>
<Card
bordered={false}
style={{ borderRadius: 8 }}
title="告警来源设备分布"
extra={<Button type="link">更多</Button>}
>
<Bar {...barConfig} height={180} />
</Card>
</Col>
</Row>
</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>
</div >
);
}