import React from 'react'; import { Table, Tag, Input, Button, Row, Col, Card, Typography, Space, Statistic } from 'antd'; import { BellOutlined, AlertOutlined, InfoCircleOutlined, SearchOutlined, FilterOutlined, CheckCircleOutlined, SyncOutlined } from '@ant-design/icons'; import { ALERTS } from '../constants'; const { Text, Title } = Typography; export default function Alerts() { const columns = [ { title: '级别', dataIndex: 'type', key: 'type', render: (type: string) => { const config = { critical: { color: 'error', text: '紧急', icon: }, warning: { color: 'warning', text: '警告', icon: }, info: { color: 'processing', text: '提示', icon: }, }[type] || { color: 'default', text: '其他', icon: }; return ( {config.text} ); }, width: 100, }, { title: '设备来源', key: 'device', render: (record: any) => ( {record.deviceName} {record.deviceId} ), width: 180, }, { title: '内容描述', dataIndex: 'message', key: 'message', render: (text: string) => {text}, }, { title: '发生时间', dataIndex: 'time', key: 'time', render: (time: string) => {time}, width: 160, }, { title: '状态', key: 'status', render: (record: any) => ( record.handled ? 已归档 : 待处理 ), width: 120, }, { title: '操作', key: 'action', align: 'right' as const, render: () => ( ), width: 140, }, ]; const summary = [ { label: '严重故障', count: ALERTS.filter(a => a.type === 'critical').length, color: '#f5222d', icon: , bgColor: '#fff1f0', borderColor: '#ffa39e' }, { label: '异常警告', count: ALERTS.filter(a => a.type === 'warning').length, color: '#faad14', icon: , bgColor: '#fffbe6', borderColor: '#ffe58f' }, { label: '状态提示', count: ALERTS.filter(a => a.type === 'info').length, color: '#1890ff', icon: , bgColor: '#e6f7ff', borderColor: '#91d5ff' }, ]; return (
警报中心: 实时检索 } placeholder="搜索设备ID或警报内容..." style={{ width: 250, borderRadius: 2 }} />
{summary.map((item) => ( {item.label}} value={item.count} valueStyle={{ color: item.color, fontWeight: 900, fontSize: 24 }} prefix={React.cloneElement(item.icon, { style: { opacity: 0.4 } })} /> ))} ({ ...a, key: a.id }))} pagination={{ pageSize: 12, size: 'small' }} /> ); }