告警详情和 总览界面 修改 布局调整
This commit is contained in:
@@ -1,150 +1,322 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
Table,
|
||||
Tag,
|
||||
Input,
|
||||
Button,
|
||||
Row,
|
||||
Col,
|
||||
Card,
|
||||
Typography,
|
||||
Space,
|
||||
Statistic
|
||||
import React, { useState } from 'react';
|
||||
import {
|
||||
Table,
|
||||
Tag,
|
||||
Input,
|
||||
Button,
|
||||
Row,
|
||||
Col,
|
||||
Card,
|
||||
Typography,
|
||||
Space,
|
||||
Statistic,
|
||||
Select,
|
||||
DatePicker,
|
||||
List,
|
||||
} from 'antd';
|
||||
import {
|
||||
BellOutlined,
|
||||
AlertOutlined,
|
||||
InfoCircleOutlined,
|
||||
SearchOutlined,
|
||||
FilterOutlined,
|
||||
CheckCircleOutlined,
|
||||
SyncOutlined
|
||||
import {
|
||||
BellOutlined,
|
||||
AlertOutlined,
|
||||
SyncOutlined,
|
||||
CheckCircleOutlined,
|
||||
ClockCircleOutlined,
|
||||
RiseOutlined,
|
||||
FallOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import { ALERTS } from '../constants';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
const { RangePicker } = DatePicker;
|
||||
|
||||
export default function Alerts() {
|
||||
const columns = [
|
||||
{
|
||||
title: '级别',
|
||||
dataIndex: 'type',
|
||||
key: 'type',
|
||||
render: (type: string) => {
|
||||
const config = {
|
||||
critical: { color: 'error', text: '紧急', icon: <AlertOutlined /> },
|
||||
warning: { color: 'warning', text: '警告', icon: <BellOutlined /> },
|
||||
info: { color: 'processing', text: '提示', icon: <InfoCircleOutlined /> },
|
||||
}[type] || { color: 'default', text: '其他', icon: <InfoCircleOutlined /> };
|
||||
const [selectedAlert, setSelectedAlert] = useState<any>(null);
|
||||
const AntdCard = Card as any;
|
||||
|
||||
return (
|
||||
<Tag color={config.color} icon={config.icon} bordered={false} style={{ fontWeight: 'bold' }}>
|
||||
{config.text}
|
||||
</Tag>
|
||||
);
|
||||
},
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: '设备来源',
|
||||
key: 'device',
|
||||
render: (record: any) => (
|
||||
<Space direction="vertical" size={0}>
|
||||
<Text strong style={{ fontSize: 13 }}>{record.deviceName}</Text>
|
||||
<Text type="secondary" style={{ fontSize: 10, fontFamily: 'monospace' }}>{record.deviceId}</Text>
|
||||
</Space>
|
||||
),
|
||||
width: 180,
|
||||
},
|
||||
{
|
||||
title: '内容描述',
|
||||
dataIndex: 'message',
|
||||
key: 'message',
|
||||
render: (text: string) => <Text ellipsis style={{ maxWidth: 300 }}>{text}</Text>,
|
||||
},
|
||||
{
|
||||
title: '发生时间',
|
||||
dataIndex: 'time',
|
||||
key: 'time',
|
||||
render: (time: string) => <Text type="secondary" style={{ fontFamily: 'monospace', fontSize: 11 }}>{time}</Text>,
|
||||
width: 160,
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
key: 'status',
|
||||
render: (record: any) => (
|
||||
record.handled ?
|
||||
<Text type="success" italic style={{ fontSize: 11 }}><CheckCircleOutlined /> 已归档</Text> :
|
||||
<Text type="warning" strong style={{ fontSize: 11 }}><SyncOutlined spin /> 待处理</Text>
|
||||
),
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
align: 'right' as const,
|
||||
render: () => (
|
||||
<Space>
|
||||
<Button type="primary" size="small" style={{ borderRadius: 2 }}>处理</Button>
|
||||
<Button type="default" size="small" style={{ borderRadius: 2 }}>忽略</Button>
|
||||
</Space>
|
||||
),
|
||||
width: 140,
|
||||
},
|
||||
];
|
||||
// 模拟告警数据(和参考图一致)
|
||||
const alertList = [
|
||||
{
|
||||
id: 'AL20250525001',
|
||||
content: '逆变器停机',
|
||||
device: '逆变器 12 (组串式)',
|
||||
level: '严重',
|
||||
time: '2025-05-25 09:18:32',
|
||||
duration: '2小时18分',
|
||||
status: '处理中',
|
||||
handler: '张运维'
|
||||
},
|
||||
{
|
||||
id: 'AL20250525002',
|
||||
content: '发电量下降 > 15%',
|
||||
device: '汇流箱 05',
|
||||
level: '重要',
|
||||
time: '2025-05-25 08:46:11',
|
||||
duration: '3小时50分',
|
||||
status: '处理中',
|
||||
handler: '李工程师'
|
||||
},
|
||||
{
|
||||
id: 'AL20250525003',
|
||||
content: '逆变器温度过高',
|
||||
device: '逆变器 07 (组串式)',
|
||||
level: '重要',
|
||||
time: '2025-05-25 07:32:45',
|
||||
duration: '4小时24分',
|
||||
status: '待处理',
|
||||
handler: '-'
|
||||
},
|
||||
{
|
||||
id: 'AL20250525004',
|
||||
content: '通信中断',
|
||||
device: '气象站 01',
|
||||
level: '一般',
|
||||
time: '2025-05-25 06:51:20',
|
||||
duration: '5小时05分',
|
||||
status: '待处理',
|
||||
handler: '王运维'
|
||||
},
|
||||
{
|
||||
id: 'AL20250525005',
|
||||
content: '数据异常',
|
||||
device: '电表 01 (并网点)',
|
||||
level: '提示',
|
||||
time: '2025-05-25 06:20:18',
|
||||
duration: '3小时36分',
|
||||
status: '已关闭',
|
||||
handler: '赵工程师'
|
||||
},
|
||||
];
|
||||
|
||||
const summary = [
|
||||
{ label: '严重故障', count: ALERTS.filter(a => a.type === 'critical').length, color: '#f5222d', icon: <AlertOutlined />, bgColor: '#fff1f0', borderColor: '#ffa39e' },
|
||||
{ label: '异常警告', count: ALERTS.filter(a => a.type === 'warning').length, color: '#faad14', icon: <BellOutlined />, bgColor: '#fffbe6', borderColor: '#ffe58f' },
|
||||
{ label: '状态提示', count: ALERTS.filter(a => a.type === 'info').length, color: '#1890ff', icon: <InfoCircleOutlined />, bgColor: '#e6f7ff', borderColor: '#91d5ff' },
|
||||
];
|
||||
const columns = [
|
||||
{ title: '告警编号', dataIndex: 'id', key: 'id', width: 120 },
|
||||
{ title: '告警内容', dataIndex: 'content', key: 'content' },
|
||||
{ title: '来源设备', dataIndex: 'device', key: 'device', width: 140 },
|
||||
{
|
||||
title: '告警级别',
|
||||
dataIndex: 'level',
|
||||
key: 'level',
|
||||
width: 80,
|
||||
render: (level: string) => {
|
||||
const colorMap: Record<string, string> = {
|
||||
'严重': 'red',
|
||||
'重要': 'orange',
|
||||
'一般': 'gold',
|
||||
'提示': 'blue'
|
||||
};
|
||||
return <Tag color={colorMap[level]}>{level}</Tag>;
|
||||
}
|
||||
},
|
||||
{ title: '发生时间', dataIndex: 'time', key: 'time', width: 160 },
|
||||
{ title: '持续时长', dataIndex: 'duration', key: 'duration', width: 100 },
|
||||
{
|
||||
title: '处理状态',
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
width: 100,
|
||||
render: (status: string) => {
|
||||
const colorMap: Record<string, string> = {
|
||||
'处理中': 'blue',
|
||||
'待处理': 'orange',
|
||||
'已关闭': 'green'
|
||||
};
|
||||
return <Tag color={colorMap[status]}>{status}</Tag>;
|
||||
}
|
||||
},
|
||||
{ title: '负责人', dataIndex: 'handler', key: 'handler', width: 80 },
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 60,
|
||||
render: () => <Button type="link" size="small">查看</Button>
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<Title level={5} style={{ margin: 0 }}>警报中心: 实时检索</Title>
|
||||
<Space>
|
||||
<Input
|
||||
prefix={<SearchOutlined style={{ color: 'rgba(0,0,0,0.25)' }} />}
|
||||
placeholder="搜索设备ID或警报内容..."
|
||||
style={{ width: 250, borderRadius: 2 }}
|
||||
/>
|
||||
<Button icon={<FilterOutlined />} style={{ borderRadius: 2 }}>
|
||||
高级过滤
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
// 顶部统计数据
|
||||
const stats = [
|
||||
{ title: '今日告警总数', value: 36, suffix: '', change: '+28.6%', up: true, extra: '昨日 28', icon: <BellOutlined style={{ color: '#ff4d4f' }} /> },
|
||||
{ title: '严重告警', value: 8, suffix: '', change: '+33.3%', up: true, extra: '昨日 6', icon: <AlertOutlined style={{ color: '#ff4d4f' }} /> },
|
||||
{ title: '处理中', value: 12, suffix: '', change: '+20.0%', up: true, extra: '昨日 10', icon: <SyncOutlined style={{ color: '#fa8c16' }} /> },
|
||||
{ title: '已关闭', value: 16, suffix: '', change: '+45.5%', up: true, extra: '昨日 11', icon: <CheckCircleOutlined style={{ color: '#52c41a' }} /> },
|
||||
{ title: '平均响应时长', value: '18分32秒', suffix: '', change: '-12.6%', up: false, extra: '昨日 21分12秒', icon: <ClockCircleOutlined style={{ color: '#1890ff' }} /> },
|
||||
];
|
||||
|
||||
<Row gutter={16}>
|
||||
{summary.map((item) => (
|
||||
<Col span={8} key={item.label}>
|
||||
<Card
|
||||
size="small"
|
||||
style={{
|
||||
backgroundColor: item.bgColor,
|
||||
borderColor: item.borderColor,
|
||||
borderRadius: 4
|
||||
}}
|
||||
>
|
||||
<Statistic
|
||||
title={<Text strong type="secondary" style={{ fontSize: 10, textTransform: 'uppercase', opacity: 0.7 }}>{item.label}</Text>}
|
||||
value={item.count}
|
||||
valueStyle={{ color: item.color, fontWeight: 900, fontSize: 24 }}
|
||||
prefix={React.cloneElement(item.icon, { style: { opacity: 0.4 } })}
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
))}
|
||||
</Row>
|
||||
return (
|
||||
<div style={{ padding: '16px', background: '#f4f7f9', minHeight: '100%' }}>
|
||||
<p className="text-lg font-semibold text-[#000] mb-2">
|
||||
告警中心
|
||||
</p>
|
||||
{/* 顶部筛选栏 */}
|
||||
<AntdCard size="small" style={{ borderRadius: 8, marginBottom: 16 }}>
|
||||
<Row gutter={[16, 16]} align="middle">
|
||||
<Col span={4}>
|
||||
<Select placeholder="告警级别" defaultValue="全部" style={{ width: '100%' }} options={[{ label: '全部', value: 'all' }, { label: '严重', value: 'critical' }, { label: '重要', value: 'important' }, { label: '一般', value: 'normal' }, { label: '提示', value: 'info' }]} />
|
||||
</Col>
|
||||
<Col span={4}>
|
||||
<Select placeholder="告警类型" defaultValue="全部" style={{ width: '100%' }} options={[{ label: '全部', value: 'all' }]} />
|
||||
</Col>
|
||||
<Col span={4}>
|
||||
<Select placeholder="设备类型" defaultValue="全部" style={{ width: '100%' }} options={[{ label: '全部', value: 'all' }]} />
|
||||
</Col>
|
||||
<Col span={6}>
|
||||
<RangePicker defaultValue={[null, null]} style={{ width: '100%' }} />
|
||||
</Col>
|
||||
<Col span={4}>
|
||||
<Select placeholder="处理状态" defaultValue="全部" style={{ width: '100%' }} options={[{ label: '全部', value: 'all' }, { label: '处理中', value: 'processing' }, { label: '已关闭', value: 'closed' }]} />
|
||||
</Col>
|
||||
<Col span={24} style={{ display: 'flex', alignItems: 'center', gap: 8, marginTop: 8 }}>
|
||||
<Input placeholder="请输入告警编号内容" style={{ width: 200 }} />
|
||||
<Button>重置</Button>
|
||||
<Button type="primary">查询</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
</AntdCard>
|
||||
|
||||
<Card styles={{ body: { padding: 0 } }} className="overflow-hidden">
|
||||
<Table
|
||||
size="small"
|
||||
columns={columns}
|
||||
dataSource={ALERTS.map(a => ({ ...a, key: a.id }))}
|
||||
pagination={{ pageSize: 12, size: 'small' }}
|
||||
/>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
{/* 统计卡片 */}
|
||||
<Row gutter={[16, 16]} style={{ marginBottom: 16 }}>
|
||||
{stats.map((stat, idx) => (
|
||||
<Col xs={24} sm={12} md={8} lg={4} key={idx}>
|
||||
<AntdCard size="small" style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}>
|
||||
<Statistic
|
||||
title={<span style={{ fontSize: 13, color: '#666' }}>{stat.title}</span>}
|
||||
value={stat.value}
|
||||
valueStyle={{ color: '#1f2329', fontWeight: 600, fontSize: 20 }}
|
||||
prefix={stat.icon}
|
||||
suffix={stat.suffix}
|
||||
/>
|
||||
<div style={{ marginTop: 4, display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>{stat.extra}</Text>
|
||||
<Text style={{ fontSize: 12, color: stat.up ? '#ff4d4f' : '#52c41a' }}>
|
||||
{stat.change} {stat.up ? <RiseOutlined /> : <FallOutlined />}
|
||||
</Text>
|
||||
</div>
|
||||
</AntdCard>
|
||||
</Col>
|
||||
))}
|
||||
</Row>
|
||||
|
||||
<Row gutter={[16, 16]}>
|
||||
{/* 左侧主内容区 */}
|
||||
<Col xs={24} lg={18}>
|
||||
{/* 告警列表 */}
|
||||
<AntdCard size="small" title={
|
||||
<div style={{ display: 'flex', gap: 4, fontSize: 14, fontWeight: 600 }}>
|
||||
<span style={{ color: '#165DFF' }}>告警列表</span>
|
||||
<span style={{ color: '#1f2937' }}>(共36条)</span>
|
||||
</div>
|
||||
} style={{ borderRadius: 8, marginBottom: 16 }}>
|
||||
<Table
|
||||
size="small"
|
||||
columns={columns}
|
||||
dataSource={alertList}
|
||||
pagination={{ pageSize: 10, total: 36, showSizeChanger: true }}
|
||||
rowKey="id"
|
||||
onRow={(record) => ({ onClick: () => setSelectedAlert(record) })}
|
||||
rowSelection={{ selectedRowKeys: selectedAlert ? [selectedAlert.id] : [], type: 'radio' }}
|
||||
/>
|
||||
</AntdCard>
|
||||
|
||||
{/* 底部图表占位(和参考图结构一致) */}
|
||||
<Row gutter={[16, 16]}>
|
||||
<Col xs={24} lg={8}>
|
||||
<AntdCard size="small" style={{ borderRadius: 8 }}>
|
||||
<div style={{ height: 150, background: '#f5f7fa', borderRadius: 4, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#888' }}>
|
||||
趋势图占位
|
||||
</div>
|
||||
</AntdCard>
|
||||
</Col>
|
||||
<Col xs={24} lg={8}>
|
||||
<AntdCard size="small" style={{ borderRadius: 8 }}>
|
||||
<div style={{ height: 150, background: '#f5f7fa', borderRadius: 4, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#888' }}>
|
||||
占比图占位
|
||||
</div>
|
||||
</AntdCard>
|
||||
</Col>
|
||||
<Col xs={24} lg={8}>
|
||||
<AntdCard size="small" style={{ borderRadius: 8 }}>
|
||||
<div style={{ height: 150, background: '#f5f7fa', borderRadius: 4, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#888' }}>
|
||||
分布图占位
|
||||
</div>
|
||||
</AntdCard>
|
||||
</Col>
|
||||
</Row>
|
||||
</Col>
|
||||
|
||||
{/* 右侧告警详情面板 */}
|
||||
<Col xs={24} lg={6}>
|
||||
<AntdCard size="small" style={{ borderRadius: 8, height: '100%' }}>
|
||||
{selectedAlert ? (
|
||||
<div>
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 8 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<BellOutlined style={{ color: '#ff4d4f', fontSize: 20 }} />
|
||||
<Text strong style={{ fontSize: 16 }}>{selectedAlert.content}</Text>
|
||||
<Tag color="red">{selectedAlert.level}</Tag>
|
||||
</div>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>告警编号 AL20250525001</Text>
|
||||
</div>
|
||||
<div style={{ fontSize: 12, color: '#666' }}>
|
||||
<div>来源设备:{selectedAlert.device}(设备类型:逆变器)</div>
|
||||
<div>发生时间:{selectedAlert.time} | 持续时长:{selectedAlert.duration}</div>
|
||||
<div>处理状态:<Tag color="blue">{selectedAlert.status}</Tag> | 负责人:{selectedAlert.handler}</div>
|
||||
<div>当前处理人:{selectedAlert.handler}({selectedAlert.time.split(' ')[0]} 接收)</div>
|
||||
<div>告警描述:逆变器因内部故障自动停机,当前无功率输出。</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
<Text strong style={{ fontSize: 13, marginBottom: 8, display: 'block' }}>根因分析建议</Text>
|
||||
<List size="small" dataSource={[
|
||||
'逆变器内部保护触发(IGBT/继电器故障)',
|
||||
'交流侧电压异常或并网不稳定',
|
||||
'散热风扇故障导致过温保护'
|
||||
]} renderItem={(item) => <List.Item style={{ padding: '4px 0', fontSize: 12 }}>{item}</List.Item>} />
|
||||
<Button type="primary" size="small" style={{ marginTop: 8 }}>AI 诊断分析</Button>
|
||||
</div>
|
||||
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
<Text strong style={{ fontSize: 13, marginBottom: 8, display: 'block' }}>相关趋势</Text>
|
||||
<div style={{ height: 100, background: '#f5f7fa', borderRadius: 4, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#888' }}>
|
||||
趋势图占位
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
<Text strong style={{ fontSize: 13, marginBottom: 8, display: 'block' }}>推荐处理措施</Text>
|
||||
<List size="small" dataSource={[
|
||||
'现场检查逆变器告警记录及指示灯状态',
|
||||
'检查散热风扇运行及通风条件',
|
||||
'检查交流侧电压及并网条件',
|
||||
'如无法恢复,建议联系厂家或更换模块'
|
||||
]} renderItem={(item) => <List.Item style={{ padding: '4px 0', fontSize: 12 }}>{item}</List.Item>} />
|
||||
<Button type="primary" size="small" style={{ marginTop: 8 }}>生成工单</Button>
|
||||
</div>
|
||||
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
<Text strong style={{ fontSize: 13, marginBottom: 8, display: 'block' }}>通知与订阅</Text>
|
||||
<Space direction="vertical" size="small" style={{ width: '100%' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
|
||||
<span style={{ fontSize: 12 }}>短信</span>
|
||||
<span style={{ fontSize: 12, color: '#1890ff' }}>已开启</span>
|
||||
</div>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
|
||||
<span style={{ fontSize: 12 }}>Telegram</span>
|
||||
<span style={{ fontSize: 12, color: '#1890ff' }}>已开启</span>
|
||||
</div>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
|
||||
<span style={{ fontSize: 12 }}>邮件</span>
|
||||
<span style={{ fontSize: 12, color: '#888' }}>未开启</span>
|
||||
</div>
|
||||
</Space>
|
||||
</div>
|
||||
|
||||
<Button type="primary" block>标记为已解决</Button>
|
||||
</div>
|
||||
) : (
|
||||
<div style={{ textAlign: 'center', padding: '40px 0', color: '#888' }}>请选择一条告警查看详情</div>
|
||||
)}
|
||||
</AntdCard>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user