二级菜单配置
This commit is contained in:
46
src/components/SystemSetting/SystemMaintain.tsx
Normal file
46
src/components/SystemSetting/SystemMaintain.tsx
Normal file
@@ -0,0 +1,46 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import { Card, Tabs } from 'antd';
|
||||
import { ExclamationCircleOutlined, AlertOutlined, FormOutlined } from '@ant-design/icons';
|
||||
import ErrorManagement from './ErrorManagement';
|
||||
import AlarmSettingsManagement from './AlarmSettingsManagement';
|
||||
import WorkOrderSettingsManagement from './WorkOrderSettingsManagement';
|
||||
|
||||
const { TabPane } = Tabs;
|
||||
|
||||
export const SystemMaintenancePage = () => {
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const [activeSubTab, setActiveSubTab] = useState<string>('error');
|
||||
|
||||
// 初始化:从url读取tab
|
||||
useEffect(() => {
|
||||
const tab = searchParams.get('subTab');
|
||||
if (tab && ['error', 'alarm', 'workOrder'].includes(tab)) {
|
||||
setActiveSubTab(tab);
|
||||
}
|
||||
}, [searchParams]);
|
||||
|
||||
const handleTabChange = (key: string) => {
|
||||
setActiveSubTab(key);
|
||||
searchParams.set('subTab', key);
|
||||
setSearchParams(searchParams);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="p-0 pt-[8px] bg-[#f5f7fa] min-h-screen">
|
||||
<Card className="mb-4">
|
||||
<Tabs activeKey={activeSubTab} onChange={handleTabChange}>
|
||||
<TabPane tab={<span><ExclamationCircleOutlined />错误管理</span>} key="error" />
|
||||
<TabPane tab={<span><AlertOutlined />告警模型管理</span>} key="alarm" />
|
||||
<TabPane tab={<span><FormOutlined />工单模型管理</span>} key="workOrder" />
|
||||
</Tabs>
|
||||
</Card>
|
||||
|
||||
{activeSubTab === 'error' && <ErrorManagement />}
|
||||
{activeSubTab === 'alarm' && <AlarmSettingsManagement />}
|
||||
{activeSubTab === 'workOrder' && <WorkOrderSettingsManagement />}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SystemMaintenancePage;
|
||||
@@ -19,51 +19,16 @@ const { Text } = Typography;
|
||||
|
||||
export default function AlarmCenterPage() {
|
||||
const [activeTab, setActiveTab] = useState('overview');
|
||||
const [rawMenuList, setRawMenuList] = useState([]);
|
||||
const [showTabs, setShowTabs] = useState([]);
|
||||
|
||||
// 获取菜单(和系统设置一模一样)
|
||||
const getMenuListApi = () => {
|
||||
const params = { pageNum: 1, pageSize: 99999 };
|
||||
return getMenuList(params);
|
||||
};
|
||||
|
||||
// 动态生成 tab
|
||||
useEffect(() => {
|
||||
getMenuListApi().then(res => {
|
||||
if (res.code === 200) {
|
||||
const data = res.rows || [];
|
||||
// 告警中心 parentId 你自己改成你数据库里的 ID
|
||||
const alarmChild = data.filter(m => m.parentId == 3388);
|
||||
|
||||
alarmChild.sort((a, b) => (a.orderNum || 0) - (b.orderNum || 0));
|
||||
|
||||
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);
|
||||
|
||||
setShowTabs(tabs);
|
||||
if (tabs.length > 0) setActiveTab(tabs[0].key);
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
// 渲染对应组件
|
||||
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>;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -23,12 +23,6 @@ export default function DeviceIndexPage() {
|
||||
const { userInfo } = useSelector((state: RootState) => state.user);
|
||||
|
||||
|
||||
const tabs = [
|
||||
{ key: 'overview', label: '装备总览', icon: <AppstoreOutlined /> },
|
||||
{ key: 'status', label: '设备状态', icon: <SettingOutlined /> },
|
||||
{ key: 'wayLineTask', label: '航线任务', icon: <AimOutlined /> },
|
||||
{ key: 'robotTask', label: '机器人任务', icon: <BranchesOutlined /> },
|
||||
];
|
||||
|
||||
// 获取设备列表(用于默认选择第一个)
|
||||
const fetchAllData = async () => {
|
||||
@@ -76,15 +70,6 @@ export default function DeviceIndexPage() {
|
||||
setActiveTab('status');
|
||||
};
|
||||
|
||||
// 切换tab时,如果是overview或status,确保选择的是第一个设备
|
||||
const handleTabChange = (key) => {
|
||||
setActiveTab(key);
|
||||
console.log('切换到tab', key, '当前选中设备SN', selectedSn);
|
||||
// 如果没有选择设备,自动选择第一个
|
||||
if ((key === 'wayLineTask' || key === 'robotTask') && devicesAll.length > 0) {
|
||||
setSelectedSn(devicesAll[0].device_sn || devicesAll[0].serialNumber);
|
||||
}
|
||||
};
|
||||
|
||||
const renderContent = () => {
|
||||
if (activeTab === 'overview') {
|
||||
@@ -94,43 +79,14 @@ export default function DeviceIndexPage() {
|
||||
onDeviceSelect={(sn) => setSelectedSn(sn)}
|
||||
/>;
|
||||
}
|
||||
if (activeTab === 'status') {
|
||||
return <DeviceStatusPage
|
||||
serialNumber={selectedSn}
|
||||
onDeviceChange={(sn) => setSelectedSn(sn)}
|
||||
/>;
|
||||
}
|
||||
if (activeTab === 'wayLineTask') return <WayLinePage />;
|
||||
if (activeTab === 'robotTask') return <RobotTaskPage />;
|
||||
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
return (
|
||||
<Layout style={{ minHeight: '100vh', overflow: 'hidden', scrollbarWidth: "thin", scrollbarColor: '#ccc transparent' }}>
|
||||
<div style={{ display: 'flex', paddingBottom: "4px" }}>
|
||||
<div style={{ padding: '8px 0px 0', flexShrink: 0 }}>
|
||||
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>装备控制</Typography.Title>
|
||||
</div>
|
||||
|
||||
<Header style={{
|
||||
flex: 1, padding: 0, background: 'transparent',
|
||||
backgroundColor: 'transparent', borderBottom: '1px solid #f0f0f0', height: 40, lineHeight: '40px'
|
||||
}}>
|
||||
|
||||
<Menu
|
||||
mode="horizontal"
|
||||
selectedKeys={[activeTab]}
|
||||
onClick={({ key }) => handleTabChange(key)}
|
||||
items={tabs}
|
||||
style={{
|
||||
border: '0',
|
||||
height: 40,
|
||||
lineHeight: '40px',
|
||||
background: 'transparent',
|
||||
backgroundColor: 'transparent'
|
||||
}} />
|
||||
</Header>
|
||||
</div>
|
||||
|
||||
<Content style={{
|
||||
maxHeight: 'calc(100vh - 40px)',
|
||||
|
||||
@@ -27,56 +27,15 @@ import BasicSettings from '../components/SystemSetting/BasicSettings';
|
||||
import ErrorManagement from '../components/SystemSetting/ErrorManagement';
|
||||
import AlarmSettingsManagement from '../components/SystemSetting/AlarmSettingsManagement';
|
||||
import WorkOrderSettingsManagement from '../components/SystemSetting/WorkOrderSettingsManagement';
|
||||
import { Outlet } from 'react-router-dom';
|
||||
|
||||
const { Header, Content } = Layout;
|
||||
const { Text } = Typography;
|
||||
const { Option } = Select;
|
||||
const AntdCard = Card as any;
|
||||
|
||||
// 重构后的系统维护页面 - 使用Tabs样式
|
||||
const SystemMaintenancePage = () => {
|
||||
const [activeSubTab, setActiveSubTab] = useState('error');
|
||||
|
||||
return (
|
||||
<div className="p-0 pt-[8px] bg-[#f5f7fa] min-h-screen">
|
||||
<Card className="mb-4">
|
||||
<Tabs activeKey={activeSubTab} onChange={setActiveSubTab}>
|
||||
<TabPane tab={<span><ExclamationCircleOutlined />错误管理</span>} key="error" />
|
||||
<TabPane tab={<span><AlertOutlined />告警模型管理</span>} key="alarm" />
|
||||
<TabPane tab={<span><FormOutlined />工单模型管理</span>} key="workOrder" />
|
||||
</Tabs>
|
||||
</Card>
|
||||
|
||||
{activeSubTab === 'error' && <ErrorManagement />}
|
||||
{activeSubTab === 'alarm' && <AlarmSettingsManagement />}
|
||||
{activeSubTab === 'workOrder' && <WorkOrderSettingsManagement />}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// 右侧面板
|
||||
const RightPanel = () => (
|
||||
<div style={{ padding: 24 }}>
|
||||
<AntdCard title="角色权限概览" style={{ marginBottom: 24 }}>
|
||||
<Row gutter={16}>
|
||||
<Col span={12}><AntdCard size="small" hoverable style={{ background: '#f0f5ff' }}><Space direction="vertical"><div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><div style={{ background: '#1677ff', borderRadius: '50%', padding: 4 }}><SafetyOutlined style={{ color: '#fff', fontSize: 16 }} /></div><Text strong>超级管理员</Text></div><Text type="secondary">全部权限</Text></Space></AntdCard></Col>
|
||||
<Col span={12}><AntdCard size="small" hoverable style={{ background: '#f6ffed' }}><Space direction="vertical"><div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><div style={{ background: '#52c41a', borderRadius: '50%', padding: 4 }}><UserOutlined style={{ color: '#fff', fontSize: 16 }} /></div><Text strong>运维工程师</Text></div><Text type="secondary">设备管理</Text></Space></AntdCard></Col>
|
||||
</Row>
|
||||
</AntdCard>
|
||||
|
||||
<AntdCard title="设备接入状态" style={{ marginBottom: 24 }}>
|
||||
<Space direction="vertical"><div style={{ display: 'flex', justifyContent: 'space-between' }}><span>逆变器</span><span>正常</span></div></Space>
|
||||
</AntdCard>
|
||||
|
||||
<AntdCard title="数据与安全" style={{ marginBottom: 24 }}>
|
||||
<Space direction="vertical"><div style={{ display: 'flex', justifyContent: 'space-between' }}><span>数据保留</span><span>3年</span></div></Space>
|
||||
</AntdCard>
|
||||
|
||||
<AntdCard title="系统维护">
|
||||
<Row gutter={16}><Col span={6}><Button block icon={<DeleteOutlined />}>清理缓存</Button></Col><Col span={6}><Button block icon={<SyncOutlined />}>重启服务</Button></Col></Row>
|
||||
</AntdCard>
|
||||
</div>
|
||||
);
|
||||
|
||||
// ======================
|
||||
// 主页面
|
||||
@@ -92,100 +51,12 @@ export default function SystemSettings() {
|
||||
return getMenuList(params);
|
||||
};
|
||||
|
||||
// 动态生成 tab
|
||||
useEffect(() => {
|
||||
getMenuListApi().then(res => {
|
||||
if (res.code === 200) {
|
||||
const data = res.rows || [];
|
||||
// 系统设置 parentId = 3394
|
||||
const systemChild = data.filter(m => m.parentId == 3394);
|
||||
|
||||
// ======================
|
||||
// 👇 按 orderNum 正序排序(数字越小越靠前)
|
||||
// ======================
|
||||
systemChild.sort((a, b) => {
|
||||
return (a.orderNum || 0) - (b.orderNum || 0);
|
||||
});
|
||||
|
||||
const tabs = systemChild.map(item => {
|
||||
if (item.path == '/systemSetting/basic') {
|
||||
return { key: 'basic', label: '基础设置', icon: <SettingOutlined /> };
|
||||
}
|
||||
if (item.path === '/systemSetting/User') {
|
||||
return { key: 'user-role', label: '用户与角色', icon: <UserOutlined /> };
|
||||
}
|
||||
if (item.path === '/systemSetting/menu') {
|
||||
return { key: 'menu', label: '菜单管理', icon: <AppstoreOutlined /> };
|
||||
}
|
||||
if (item.path === '/systemSetting/org') {
|
||||
return { key: 'org', label: '组织管理', icon: <TeamOutlined /> };
|
||||
}
|
||||
if (item.path === '/systemSetting/site') {
|
||||
return { key: 'site', label: '场站管理', icon: <EnvironmentOutlined /> };
|
||||
}
|
||||
if (item.path === '/systemSetting/notice') {
|
||||
return { key: 'notice', label: '通知策略', icon: <NotificationOutlined /> };
|
||||
}
|
||||
if (item.path === '/systemSetting/deviceAccess') {
|
||||
return { key: 'deviceAccess', label: '设备接入', icon: <ExperimentOutlined /> };
|
||||
}
|
||||
if (item.path === '/systemSetting/dataSafety') {
|
||||
return { key: 'dataSafety', label: '数据与安全', icon: <SafetyOutlined /> };
|
||||
}
|
||||
if (item.path === '/systemSetting/systemMaintenance') {
|
||||
return { key: 'systemMaintenance', label: '系统维护', icon: <SyncOutlined /> };
|
||||
}
|
||||
if (item.path === '/systemSetting/monitor') {
|
||||
return { key: 'monitor', label: '系统监控', icon: <SyncOutlined /> };
|
||||
}
|
||||
if (item.path === '/systemSetting/devices') {
|
||||
return { key: 'devices', label: '设备管理', icon: <AppstoreOutlined /> };
|
||||
}
|
||||
// 移除错误管理的单独菜单,已经放在系统维护里面了
|
||||
return null;
|
||||
}).filter(Boolean);
|
||||
|
||||
setShowTabs(tabs);
|
||||
|
||||
// 默认选中第一个
|
||||
if (tabs.length > 0) {
|
||||
setActiveTab(tabs[0].key);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
const NoticePage = () => <div style={{ padding: 20 }}><h2>通知策略页面</h2></div>;
|
||||
const DataSafetyPage = () => <div style={{ padding: 20 }}><h2>数据与安全页面</h2></div>;
|
||||
const DefaultPage = () => <div style={{ padding: 20 }}><h2>请选择菜单</h2></div>;
|
||||
const renderTabContent = () => {
|
||||
switch (activeTab) {
|
||||
case 'basic':
|
||||
return <BasicSettings />;
|
||||
case 'user-role':
|
||||
return <UserRolePage />;
|
||||
case 'menu':
|
||||
return <MenuList />;
|
||||
case 'org':
|
||||
return <Organization />;
|
||||
case 'site':
|
||||
return <StationManage />;
|
||||
case 'notice':
|
||||
return <NoticePage />;
|
||||
case 'deviceAccess':
|
||||
return <DeviceAccessPage />;
|
||||
case 'dataSafety':
|
||||
return <DataSafetyPage />;
|
||||
case 'systemMaintenance':
|
||||
return <SystemMaintenancePage />;
|
||||
case 'monitor':
|
||||
return <OnlineUserPage />;
|
||||
case 'devices':
|
||||
return <DeviceManagementPage />;
|
||||
default:
|
||||
return <DefaultPage />;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Layout style={{ minHeight: '100vh', overflow: 'hidden' }}>
|
||||
|
||||
@@ -193,22 +64,14 @@ export default function SystemSettings() {
|
||||
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>系统设置</Typography.Title>
|
||||
<Text type="secondary" style={{ fontSize: '12px' }}>告警规则配置、用户角色、通知管理与系统参数设置</Text>
|
||||
</div>
|
||||
<Header style={{ padding: 0, borderBottom: '1px solid #f0f0f0', position: 'sticky', top: 0, zIndex: 10, height: 40, lineHeight: '40px' }}>
|
||||
<Menu
|
||||
mode="horizontal"
|
||||
selectedKeys={[activeTab]}
|
||||
onClick={({ key }) => setActiveTab(key)}
|
||||
items={showTabs}
|
||||
style={{ border: 0, height: 40, lineHeight: '40px' }}
|
||||
/>
|
||||
</Header>
|
||||
|
||||
|
||||
<Content style={{
|
||||
maxHeight: 'calc(100vh - 40px)', overflowY: 'auto', background: '#f5f7fa',
|
||||
scrollbarWidth: 'none',
|
||||
msOverflowStyle: 'none',
|
||||
}}>
|
||||
{renderTabContent()}
|
||||
<Outlet />
|
||||
</Content>
|
||||
</Layout>
|
||||
);
|
||||
|
||||
@@ -27,10 +27,23 @@ const Organization = lazy(() => import('../components/SystemSetting/Organization
|
||||
const StationManage = lazy(() => import('../components/SystemSetting/StationManage'));
|
||||
const SystemSetting = lazy(() => import('../pages/SystemSetting'));
|
||||
const Profile = lazy(() => import('../pages/Profile'));
|
||||
|
||||
|
||||
const DeviceStatus = lazy(() => import('../components/devices/DeviceStatusPage'));
|
||||
const WayLineTask = lazy(() => import('../components/devices/WayLinePage'));
|
||||
const RobotTask = lazy(() => import('../components/devices/RobotTaskPage'));
|
||||
|
||||
|
||||
const BasicSettings = lazy(() => import('../components/SystemSetting/BasicSettings'));
|
||||
const UserRolePage = lazy(() => import('../components/SystemSetting/UserPage'));
|
||||
const DeviceAccessPage = lazy(() => import('../components/SystemSetting/DeviceAccessPage'));
|
||||
const OnlineUserPage = lazy(() => import('../components/SystemSetting/OnlineUser'));
|
||||
const DeviceManagementPage = lazy(() => import('../components/SystemSetting/DeviceManagement'));
|
||||
const SystemMaintenancePage = lazy(() => import('../components/SystemSetting/SystemMaintain'));
|
||||
//const ErrorManagement = lazy(() => import('../components/SystemSetting/ErrorManagement'));
|
||||
//const AlarmSettingsManagement = lazy(() => import('../components/SystemSetting/AlarmSettingsManagement'));
|
||||
//const WorkOrderSettingsManagement = lazy(() => import('../components/SystemSetting/WorkOrderSettingsManagement'));
|
||||
|
||||
// 加载中动画
|
||||
function PageFallback() {
|
||||
return (
|
||||
@@ -171,7 +184,7 @@ const routes: RouteObject[] = [
|
||||
)
|
||||
},
|
||||
{
|
||||
path: 'alerts',
|
||||
path: 'alerts/all',
|
||||
element: (
|
||||
<Suspense fallback={<PageFallback />}>
|
||||
<Alerts />
|
||||
@@ -216,7 +229,21 @@ const routes: RouteObject[] = [
|
||||
<Suspense fallback={<PageFallback />}>
|
||||
<SystemSetting />
|
||||
</Suspense>
|
||||
)
|
||||
),
|
||||
children: [
|
||||
{ index: true, element: <Suspense fallback={<PageFallback />}><BasicSettings /></Suspense> },
|
||||
{ path: 'basic', element: <Suspense fallback={<PageFallback />}><BasicSettings /></Suspense> },
|
||||
{ path: 'User', element: <Suspense fallback={<PageFallback />}><UserRolePage /></Suspense> },
|
||||
{ path: 'menu', element: <Suspense fallback={<PageFallback />}><MenuList /></Suspense> },
|
||||
{ path: 'org', element: <Suspense fallback={<PageFallback />}><Organization /></Suspense> },
|
||||
{ path: 'site', element: <Suspense fallback={<PageFallback />}><StationManage /></Suspense> },
|
||||
{ path: 'notice', element: <Suspense fallback={<PageFallback />}><div style={{ padding: 20 }}><h2>通知策略页面</h2></div></Suspense> },
|
||||
{ path: 'deviceAccess', element: <Suspense fallback={<PageFallback />}><DeviceAccessPage /></Suspense> },
|
||||
{ path: 'dataSafety', element: <Suspense fallback={<PageFallback />}><div style={{ padding: 20 }}><h2>数据与安全页面</h2></div></Suspense> },
|
||||
{ path: 'systemMaintenance', element: <Suspense fallback={<PageFallback />}><SystemMaintenancePage /></Suspense> },
|
||||
{ path: 'monitor', element: <Suspense fallback={<PageFallback />}><OnlineUserPage /></Suspense> },
|
||||
{ path: 'devices', element: <Suspense fallback={<PageFallback />}><DeviceManagementPage /></Suspense> },
|
||||
]
|
||||
},
|
||||
{
|
||||
path: 'downloads',
|
||||
|
||||
Reference in New Issue
Block a user