菜单模块增删改查

This commit is contained in:
mmc
2026-04-28 14:45:07 +08:00
parent c08278190a
commit 2a2d40d772
6 changed files with 532 additions and 528 deletions

View File

@@ -13,6 +13,7 @@ import {
Select,
DatePicker,
List,
Layout,
} from 'antd';
import {
BellOutlined,
@@ -22,74 +23,99 @@ import {
ClockCircleOutlined,
RiseOutlined,
FallOutlined,
CloseOutlined,
} from '@ant-design/icons';
import { ALERTS } from '../constants';
const { Text, Title } = Typography;
const { Text } = Typography;
const { RangePicker } = DatePicker;
const AntdCard = Card as any;
// 模拟数据
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: '-',
},
];
const stats = [
{
title: '今日告警总数',
value: 36,
change: '+28.6%',
up: true,
extra: '昨日 28',
icon: <BellOutlined style={{ color: '#ff4d4f' }} />,
},
{
title: '严重告警',
value: 8,
change: '+33.3%',
up: true,
extra: '昨日 6',
icon: <AlertOutlined style={{ color: '#ff4d4f' }} />,
},
{
title: '处理中',
value: 12,
change: '+20.0%',
up: true,
extra: '昨日 10',
icon: <SyncOutlined style={{ color: '#fa8c16' }} />,
},
{
title: '已关闭',
value: 16,
change: '+45.5%',
up: true,
extra: '昨日 11',
icon: <CheckCircleOutlined style={{ color: '#52c41a' }} />,
},
{
title: '平均响应时长',
value: '18分32秒',
change: '-12.6%',
up: false,
extra: '昨日 21分12秒',
icon: <ClockCircleOutlined style={{ color: '#1890ff' }} />,
},
];
export default function Alerts() {
// 控制右侧详情面板
const [showDetail, setShowDetail] = useState(false);
const [selectedAlert, setSelectedAlert] = useState<any>(null);
const AntdCard = Card as any;
// 模拟告警数据(和参考图一致)
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 columns = [
{ title: '告警编号', dataIndex: 'id', key: 'id', width: 120 },
{ title: '告警内容', dataIndex: 'content', key: 'content' },
{ title: '来源设备', dataIndex: 'device', key: 'device', width: 140 },
{ title: '来源设备', dataIndex: 'device', key: 'device', width: 160 },
{
title: '告警级别',
dataIndex: 'level',
@@ -97,16 +123,16 @@ export default function Alerts() {
width: 80,
render: (level: string) => {
const colorMap: Record<string, string> = {
'严重': 'red',
'重要': 'orange',
'一般': 'gold',
'提示': 'blue'
严重: '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: 'duration', key: 'duration', width: 110 },
{
title: '处理状态',
dataIndex: 'status',
@@ -114,209 +140,184 @@ export default function Alerts() {
width: 100,
render: (status: string) => {
const colorMap: Record<string, string> = {
'处理中': 'blue',
'待处理': 'orange',
'已关闭': 'green'
处理中: 'blue',
待处理: 'orange',
已关闭: 'green',
};
return <Tag color={colorMap[status]}>{status}</Tag>;
}
},
},
{ title: '负责人', dataIndex: 'handler', key: 'handler', width: 80 },
{ title: '负责人', dataIndex: 'handler', key: 'handler', width: 90 },
{
title: '操作',
key: 'action',
width: 60,
render: () => <Button type="link" size="small">查看</Button>
width: 80,
render: (_, record) => (
<Button
type="link"
size="small"
onClick={() => {
setSelectedAlert(record);
setShowDetail(true);
}}
>
查看
</Button>
),
},
];
// 顶部统计数据
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' }} /> },
];
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>
<div style={{ background: '#f4f7f9', minHeight: '100%' }}>
<Layout style={{ background: 'transparent' }}>
{/* 左侧主内容区:宽度动态变化 */}
<Layout.Content
style={{
padding: '16px',
transition: 'width 0.3s ease',
width: showDetail ? 'calc(100% - 460px)' : '100%',
}}
>
<div style={{ fontSize: 16, fontWeight: 600, marginBottom: 12 }}>告警中心</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>
{/* 筛选栏 */}
<AntdCard size="small" style={{ borderRadius: 8, marginBottom: 16 }}>
<Row gutter={[16, 16]} align="middle">
<Col span={4}><Select placeholder="告警级别" style={{ width: '100%' }} /></Col>
<Col span={4}><Select placeholder="告警类型" style={{ width: '100%' }} /></Col>
<Col span={4}><Select placeholder="设备类型" style={{ width: '100%' }} /></Col>
<Col span={6}><RangePicker style={{ width: '100%' }} /></Col>
<Col span={6}><Select placeholder="处理状态" style={{ width: '100%' }} /></Col>
<Col span={24} style={{ display: 'flex', gap: 8, marginTop: 8 }}>
<Input placeholder="搜索" style={{ width: 220 }} />
<Button>重置</Button>
<Button type="primary">查询</Button>
</Col>
</Row>
</AntdCard>
{/* 统计卡片 */}
<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 }}>
<Statistic
title={<span style={{ fontSize: 13 }}>{stat.title}</span>}
value={stat.value}
valueStyle={{ fontSize: 20, fontWeight: 600 }}
prefix={stat.icon}
/>
<div style={{ display: 'flex', justifyContent: 'space-between', marginTop: 4 }}>
<Text type="secondary" style={{ fontSize: 12 }}>{stat.extra}</Text>
<Text style={{ color: stat.up ? '#ff4d4f' : '#52c41a', fontSize: 12 }}>
{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 }}>
<AntdCard
size="small"
title={
<div style={{ fontSize: 14, fontWeight: 600 }}>
<span style={{ color: '#165DFF' }}>告警列表</span>
<span style={{ color: '#333' }}>(共36条)</span>
</div>
}
style={{ borderRadius: 8 }}
>
<Table
size="small"
columns={columns}
dataSource={alertList}
pagination={{ pageSize: 10, total: 36, showSizeChanger: true }}
pagination={{ pageSize: 10 }}
rowKey="id"
onRow={(record) => ({ onClick: () => setSelectedAlert(record) })}
rowSelection={{ selectedRowKeys: selectedAlert ? [selectedAlert.id] : [], type: 'radio' }}
onRow={(record) => ({
onClick: () => {
setSelectedAlert(record);
setShowDetail(true);
},
})}
/>
</AntdCard>
</Layout.Content>
{/* 底部图表占位(和参考图结构一致) */}
<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 ? (
{/* 右侧详情面板:推挤式,非覆盖 */}
{showDetail && (
<Layout.Sider
width={460}
style={{
background: '#fff',
padding: '16px',
height: 'calc(100vh - 50px)',
overflow: 'auto',
boxShadow: '-2px 0 8px rgba(0,0,0,0.08)',
}}
>
{selectedAlert && (
<div>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}>
<Text strong style={{ fontSize: 16 }}>告警详情</Text>
<Button
type="text"
icon={<CloseOutlined />}
onClick={() => setShowDetail(false)}
style={{ fontSize: 16 }}
/> </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 style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 8 }}>
<BellOutlined style={{ color: '#ff4d4f', fontSize: 20 }} />
<Text strong style={{ fontSize: 16 }}>{selectedAlert.content}</Text>
<Tag color="red">{selectedAlert.level}</Tag>
</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 style={{ fontSize: 12, color: '#666', lineHeight: 1.8 }}>
<div>告警编号:{selectedAlert.id}</div>
<div>来源设备:{selectedAlert.device}</div>
<div>发生时间:{selectedAlert.time}</div>
<div>持续时长:{selectedAlert.duration}</div>
<div>处理状态:{selectedAlert.status}</div>
<div>负责人:{selectedAlert.handler}</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>
<List
size="small"
dataSource={[
'逆变器内部保护触发(IGBT/继电器故障)',
'交流侧电压异常或并网不稳定',
'散热风扇故障导致过温保护',
]}
renderItem={(item) => <List.Item style={{ padding: '4px 0' }}>{item}</List.Item>}
/>
</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>
<List
size="small"
dataSource={[
'现场检查逆变器告警记录及指示灯状态',
'检查散热风扇运行及通风条件',
'检查交流侧电压及并网条件',
]}
renderItem={(item) => <List.Item style={{ padding: '4px 0' }}>{item}</List.Item>}
/>
</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>
<Button type="primary" block style={{ marginTop: 16 }}>
标记为已解决
</Button>
</div>
) : (
<div style={{ textAlign: 'center', padding: '40px 0', color: '#888' }}>请选择一条告警查看详情</div>
)}
</AntdCard>
</Col>
</Row>
</Layout.Sider>
)}
</Layout>
</div>
);
}