2026-05-07 14:13:26 +08:00
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
|
import { Layout, Menu, Typography } from 'antd';
|
2026-04-28 11:01:54 +08:00
|
|
|
import {
|
2026-05-07 14:13:26 +08:00
|
|
|
AlertOutlined, ClockCircleOutlined, FileTextOutlined, BarChartOutlined,
|
|
|
|
|
SettingOutlined, BellOutlined
|
2026-04-17 17:20:41 +08:00
|
|
|
} from '@ant-design/icons';
|
2026-05-07 14:13:26 +08:00
|
|
|
import { getMenuList } from '../api/mune';
|
|
|
|
|
import AlarmOverview from '../components/alerts/AlarmOverview';
|
|
|
|
|
import AlarmRealtime from '../components/alerts/AlarmRealtime';
|
|
|
|
|
import AlarmHistory from '../components/alerts/AlarmHistory';
|
|
|
|
|
import AlarmStatistics from '../components/alerts/AlarmStatistics';
|
|
|
|
|
import AlarmRules from '../components/alerts/AlarmRules';
|
|
|
|
|
import AlarmSubscription from '../components/alerts/AlarmSubscription';
|
2026-04-17 17:20:41 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-05-07 14:13:26 +08:00
|
|
|
const { Header, Content } = Layout;
|
|
|
|
|
const { Text } = Typography;
|
2026-04-17 17:20:41 +08:00
|
|
|
|
2026-05-07 14:13:26 +08:00
|
|
|
export default function AlarmCenterPage() {
|
|
|
|
|
const [activeTab, setActiveTab] = useState('overview');
|
|
|
|
|
const [rawMenuList, setRawMenuList] = useState([]);
|
|
|
|
|
const [showTabs, setShowTabs] = useState([]);
|
2026-04-17 17:20:41 +08:00
|
|
|
|
2026-05-07 14:13:26 +08:00
|
|
|
// 获取菜单(和系统设置一模一样)
|
|
|
|
|
const getMenuListApi = () => {
|
|
|
|
|
const params = { pageNum: 1, pageSize: 99999 };
|
|
|
|
|
return getMenuList(params);
|
|
|
|
|
};
|
2026-04-28 14:45:07 +08:00
|
|
|
|
2026-05-07 14:13:26 +08:00
|
|
|
// 动态生成 tab
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
getMenuListApi().then(res => {
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
const data = res.rows || [];
|
|
|
|
|
// 告警中心 parentId 你自己改成你数据库里的 ID
|
|
|
|
|
const alarmChild = data.filter(m => m.parentId == 3388);
|
2026-04-28 11:01:54 +08:00
|
|
|
|
2026-05-07 14:13:26 +08:00
|
|
|
alarmChild.sort((a, b) => (a.orderNum || 0) - (b.orderNum || 0));
|
2026-04-28 11:01:54 +08:00
|
|
|
|
2026-05-07 14:13:26 +08:00
|
|
|
const tabs = alarmChild.map(item => {
|
|
|
|
|
if (item.path === '/alerts/all') return { key: 'overview', label: '告警总览', icon: <AlertOutlined /> };
|
|
|
|
|
if (item.path === '/alerts/time') return { key: 'realtime', label: '实时告警', icon: <ClockCircleOutlined /> };
|
|
|
|
|
if (item.path === '/alerts/history') return { key: 'history', label: '告警历史', icon: <FileTextOutlined /> };
|
|
|
|
|
if (item.path === '/alerts/counts') return { key: 'statistics', label: '告警统计', icon: <BarChartOutlined /> };
|
|
|
|
|
if (item.path === '/alerts/rules') return { key: 'rules', label: '告警规则', icon: <SettingOutlined /> };
|
|
|
|
|
if (item.path === '/alerts/subscribe') return { key: 'subscription', label: '告警订阅', icon: <BellOutlined /> };
|
|
|
|
|
return null;
|
|
|
|
|
}).filter(Boolean);
|
2026-04-28 14:45:07 +08:00
|
|
|
|
2026-05-07 14:13:26 +08:00
|
|
|
setShowTabs(tabs);
|
|
|
|
|
if (tabs.length > 0) setActiveTab(tabs[0].key);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}, []);
|
2026-04-28 11:01:54 +08:00
|
|
|
|
2026-05-07 14:13:26 +08:00
|
|
|
// 渲染对应组件
|
|
|
|
|
const renderTabContent = () => {
|
|
|
|
|
switch (activeTab) {
|
|
|
|
|
case 'overview': return <AlarmOverview />;
|
|
|
|
|
case 'realtime': return <AlarmRealtime />;
|
|
|
|
|
case 'history': return <AlarmHistory />;
|
|
|
|
|
case 'statistics': return <AlarmStatistics />;
|
|
|
|
|
case 'rules': return <AlarmRules />;
|
|
|
|
|
case 'subscription': return <AlarmSubscription />;
|
|
|
|
|
default: return <div style={{ padding: 20 }}><Text>请选择菜单</Text></div>;
|
|
|
|
|
}
|
|
|
|
|
};
|
2026-04-28 11:01:54 +08:00
|
|
|
|
2026-05-07 14:13:26 +08:00
|
|
|
return (
|
2026-05-14 10:47:56 +08:00
|
|
|
<Layout style={{ minHeight: '100vh', overflow: 'hidden' }}>
|
2026-05-11 10:47:51 +08:00
|
|
|
<div style={{ display: 'flex', paddingBottom: "12px" }}>
|
|
|
|
|
<div style={{ padding: '20px 24px 0' }}>
|
|
|
|
|
<Typography.Title level={4} style={{ margin: 0 }}>告警中心</Typography.Title>
|
|
|
|
|
<Text type="secondary">告警处置闭环、规则管理与事件中心</Text>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-05-14 10:47:56 +08:00
|
|
|
<Header style={{ padding: 0, borderBottom: '1px solid #f0f0f0', position: 'sticky', top: 0, zIndex: 10 }}>
|
|
|
|
|
{/*<Menu
|
2026-05-11 10:47:51 +08:00
|
|
|
mode="horizontal"
|
|
|
|
|
selectedKeys={[activeTab]}
|
|
|
|
|
onClick={({ key }) => setActiveTab(key)}
|
|
|
|
|
items={showTabs}
|
2026-05-14 10:47:56 +08:00
|
|
|
style={{
|
|
|
|
|
border: 'none',
|
|
|
|
|
height: 64,
|
|
|
|
|
lineHeight: '64px',
|
|
|
|
|
background: 'transparent !important',
|
|
|
|
|
backgroundColor: 'transparent !important',
|
|
|
|
|
}}
|
|
|
|
|
/>*/}
|
2026-05-11 10:47:51 +08:00
|
|
|
</Header>
|
2026-05-07 17:09:19 +08:00
|
|
|
</div>
|
|
|
|
|
|
2026-04-28 11:01:54 +08:00
|
|
|
|
2026-05-07 14:13:26 +08:00
|
|
|
<Content style={{
|
|
|
|
|
maxHeight: 'calc(100vh - 64px)', overflowY: 'auto', background: '#f5f7fa',
|
|
|
|
|
scrollbarWidth: 'none', msOverflowStyle: 'none',
|
|
|
|
|
}}>
|
|
|
|
|
{renderTabContent()}
|
|
|
|
|
</Content>
|
|
|
|
|
</Layout>
|
2026-04-28 11:01:54 +08:00
|
|
|
);
|
2026-04-17 17:20:41 +08:00
|
|
|
}
|