From 575229947db12acc42b01179751d56647f7f894b Mon Sep 17 00:00:00 2001 From: mmc <1556375442@qq.com> Date: Mon, 3 Aug 2026 14:22:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E8=8F=9C=E5=8D=95=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SystemSetting/SystemMaintain.tsx | 46 ++++++ src/pages/Alerts.tsx | 37 +---- src/pages/Devices.tsx | 48 +----- src/pages/SystemSetting.tsx | 145 +----------------- src/router/index.tsx | 31 +++- 5 files changed, 82 insertions(+), 225 deletions(-) create mode 100644 src/components/SystemSetting/SystemMaintain.tsx diff --git a/src/components/SystemSetting/SystemMaintain.tsx b/src/components/SystemSetting/SystemMaintain.tsx new file mode 100644 index 0000000..c2bd83c --- /dev/null +++ b/src/components/SystemSetting/SystemMaintain.tsx @@ -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('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 ( +
+ + + 错误管理} key="error" /> + 告警模型管理} key="alarm" /> + 工单模型管理} key="workOrder" /> + + + + {activeSubTab === 'error' && } + {activeSubTab === 'alarm' && } + {activeSubTab === 'workOrder' && } +
+ ); +}; + +export default SystemMaintenancePage; diff --git a/src/pages/Alerts.tsx b/src/pages/Alerts.tsx index dccb741..ed3000f 100644 --- a/src/pages/Alerts.tsx +++ b/src/pages/Alerts.tsx @@ -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: }; - if (item.path === '/alerts/time') return { key: 'realtime', label: '实时告警', icon: }; - if (item.path === '/alerts/history') return { key: 'history', label: '告警历史', icon: }; - if (item.path === '/alerts/counts') return { key: 'statistics', label: '告警统计', icon: }; - if (item.path === '/alerts/rules') return { key: 'rules', label: '告警规则', icon: }; - if (item.path === '/alerts/subscribe') return { key: 'subscription', label: '告警订阅', icon: }; - return null; - }).filter(Boolean); - - setShowTabs(tabs); - if (tabs.length > 0) setActiveTab(tabs[0].key); - } - }); - }, []); // 渲染对应组件 const renderTabContent = () => { switch (activeTab) { case 'overview': return ; - case 'realtime': return ; - case 'history': return ; - case 'statistics': return ; - case 'rules': return ; - case 'subscription': return ; - default: return
请选择菜单
; + } }; diff --git a/src/pages/Devices.tsx b/src/pages/Devices.tsx index 493d18f..ea286fc 100644 --- a/src/pages/Devices.tsx +++ b/src/pages/Devices.tsx @@ -23,12 +23,6 @@ export default function DeviceIndexPage() { const { userInfo } = useSelector((state: RootState) => state.user); - const tabs = [ - { key: 'overview', label: '装备总览', icon: }, - { key: 'status', label: '设备状态', icon: }, - { key: 'wayLineTask', label: '航线任务', icon: }, - { key: 'robotTask', label: '机器人任务', icon: }, - ]; // 获取设备列表(用于默认选择第一个) 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 setSelectedSn(sn)} - />; - } - if (activeTab === 'wayLineTask') return ; - if (activeTab === 'robotTask') return ; + + return null; }; return ( -
-
- 装备控制 -
-
- - handleTabChange(key)} - items={tabs} - style={{ - border: '0', - height: 40, - lineHeight: '40px', - background: 'transparent', - backgroundColor: 'transparent' - }} /> -
-
{ - const [activeSubTab, setActiveSubTab] = useState('error'); - return ( -
- - - 错误管理} key="error" /> - 告警模型管理} key="alarm" /> - 工单模型管理} key="workOrder" /> - - - {activeSubTab === 'error' && } - {activeSubTab === 'alarm' && } - {activeSubTab === 'workOrder' && } -
- ); -}; - -// 右侧面板 -const RightPanel = () => ( -
- - -
超级管理员
全部权限
-
运维工程师
设备管理
-
-
- - -
逆变器正常
-
- - -
数据保留3年
-
- - - - -
-); // ====================== // 主页面 @@ -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: }; - } - if (item.path === '/systemSetting/User') { - return { key: 'user-role', label: '用户与角色', icon: }; - } - if (item.path === '/systemSetting/menu') { - return { key: 'menu', label: '菜单管理', icon: }; - } - if (item.path === '/systemSetting/org') { - return { key: 'org', label: '组织管理', icon: }; - } - if (item.path === '/systemSetting/site') { - return { key: 'site', label: '场站管理', icon: }; - } - if (item.path === '/systemSetting/notice') { - return { key: 'notice', label: '通知策略', icon: }; - } - if (item.path === '/systemSetting/deviceAccess') { - return { key: 'deviceAccess', label: '设备接入', icon: }; - } - if (item.path === '/systemSetting/dataSafety') { - return { key: 'dataSafety', label: '数据与安全', icon: }; - } - if (item.path === '/systemSetting/systemMaintenance') { - return { key: 'systemMaintenance', label: '系统维护', icon: }; - } - if (item.path === '/systemSetting/monitor') { - return { key: 'monitor', label: '系统监控', icon: }; - } - if (item.path === '/systemSetting/devices') { - return { key: 'devices', label: '设备管理', icon: }; - } - // 移除错误管理的单独菜单,已经放在系统维护里面了 - return null; - }).filter(Boolean); - - setShowTabs(tabs); - - // 默认选中第一个 - if (tabs.length > 0) { - setActiveTab(tabs[0].key); - } - } - }); - }, []); const NoticePage = () =>

通知策略页面

; const DataSafetyPage = () =>

数据与安全页面

; const DefaultPage = () =>

请选择菜单

; - const renderTabContent = () => { - switch (activeTab) { - case 'basic': - return ; - case 'user-role': - return ; - case 'menu': - return ; - case 'org': - return ; - case 'site': - return ; - case 'notice': - return ; - case 'deviceAccess': - return ; - case 'dataSafety': - return ; - case 'systemMaintenance': - return ; - case 'monitor': - return ; - case 'devices': - return ; - default: - return ; - } - }; + return ( @@ -193,22 +64,14 @@ export default function SystemSettings() { 系统设置 告警规则配置、用户角色、通知管理与系统参数设置 -
- setActiveTab(key)} - items={showTabs} - style={{ border: 0, height: 40, lineHeight: '40px' }} - /> -
+ - {renderTabContent()} +
); diff --git a/src/router/index.tsx b/src/router/index.tsx index adfcc6a..ad0e987 100644 --- a/src/router/index.tsx +++ b/src/router/index.tsx @@ -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: ( }> @@ -216,7 +229,21 @@ const routes: RouteObject[] = [ }> - ) + ), + children: [ + { index: true, element: }> }, + { path: 'basic', element: }> }, + { path: 'User', element: }> }, + { path: 'menu', element: }> }, + { path: 'org', element: }> }, + { path: 'site', element: }> }, + { path: 'notice', element: }>

通知策略页面

}, + { path: 'deviceAccess', element: }> }, + { path: 'dataSafety', element: }>

数据与安全页面

}, + { path: 'systemMaintenance', element: }> }, + { path: 'monitor', element: }> }, + { path: 'devices', element: }> }, + ] }, { path: 'downloads',