190 lines
7.5 KiB
TypeScript
190 lines
7.5 KiB
TypeScript
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 = () => (
|
|
<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>
|
|
);
|
|
|
|
// ======================
|
|
// 主页面
|
|
// ======================
|
|
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: <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 SystemMaintenancePage = () => <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', background: '#fff', overflow: 'hidden' }}>
|
|
<div style={{ padding: '20px 24px 0' }}>
|
|
<Typography.Title level={4} style={{ margin: 0 }}>系统设置</Typography.Title>
|
|
<Text type="secondary"> 告警规则配置、用户角色、通知管理与系统参数设置
|
|
</Text>
|
|
</div>
|
|
<Header style={{ background: '#fff', padding: 0, borderBottom: '1px solid #f0f0f0', position: 'sticky', top: 0, zIndex: 10 }}>
|
|
<Menu
|
|
mode="horizontal"
|
|
selectedKeys={[activeTab]}
|
|
onClick={({ key }) => setActiveTab(key)}
|
|
items={showTabs}
|
|
style={{ border: 0, height: 64, lineHeight: '64px' }}
|
|
/>
|
|
</Header>
|
|
|
|
<Content style={{
|
|
maxHeight: 'calc(100vh - 64px)', overflowY: 'auto', background: '#f5f7fa',
|
|
scrollbarWidth: 'none',
|
|
msOverflowStyle: 'none',
|
|
}}>
|
|
{renderTabContent()}
|
|
</Content>
|
|
</Layout>
|
|
);
|
|
}
|