import React, { useState, useEffect } from 'react';
import {
Layout, Menu, Card, Row, Col, Button, Form, Input, Select, Switch, Tag, Space, Typography, message, Table
} from 'antd';
import {
SettingOutlined, UserOutlined, BellOutlined, LinkOutlined, SafetyOutlined, SyncOutlined,
CloudOutlined, TeamOutlined, FileTextOutlined, DatabaseOutlined, CalendarOutlined,
CheckCircleOutlined, ReloadOutlined, DownloadOutlined, DeleteOutlined,
KeyOutlined, AppstoreOutlined, BankOutlined,
NotificationOutlined,
ExperimentOutlined,
EnvironmentOutlined
} from '@ant-design/icons';
import UserRolePage from '../components/SystemSetting/UserPage';
import MenuList from '../components/SystemSetting/MenuList';
import Organization from '../components/SystemSetting/Organization';
import StationManage from '../components/SystemSetting/StationManage';
import { getMenuList } from '../api/mune';
import DeviceAccessPage from '../components/SystemSetting/DeviceAccessPage';
import OnlineUserPage from '../components/SystemSetting/OnlineUser';
import DeviceManagementPage from '../components/SystemSetting/DeviceManagement';
import BasicSettings from '../components/SystemSetting/BasicSettings';
const { Header, Content } = Layout;
const { Text } = Typography;
const { Option } = Select;
const AntdCard = Card as any;
// 基础设置
// 右侧面板
const RightPanel = () => (
全部权限
设备管理
逆变器正常
数据保留3年
}>清理缓存}>重启服务
);
// ======================
// 主页面
// ======================
export default function SystemSettings() {
const [activeTab, setActiveTab] = useState('basic');
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 = 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 SystemMaintenancePage = () => 系统维护页面
;
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 (
系统设置
告警规则配置、用户角色、通知管理与系统参数设置
{renderTabContent()}
);
}