布局修改

This commit is contained in:
mmc
2026-04-29 14:26:01 +08:00
parent 935b2eb46a
commit 5d57d45f16
7 changed files with 990 additions and 56 deletions

575
src/pages/SystemSetting.tsx Normal file
View File

@@ -0,0 +1,575 @@
import React, { useState } from 'react';
import {
Layout, Menu, Card, Row, Col, Button, Form, Input, Select, Switch, Tag, Space, Typography, Statistic, message, Table, Divider
} from 'antd';
import {
SettingOutlined, UserOutlined, BellOutlined, LinkOutlined, SafetyOutlined, SyncOutlined,
CloudOutlined, TeamOutlined, FileTextOutlined, DatabaseOutlined, CalendarOutlined,
CheckCircleOutlined, CloseCircleOutlined, ReloadOutlined, DownloadOutlined, DeleteOutlined,
KeyOutlined,
AppstoreOutlined,
BankOutlined
} from '@ant-design/icons';
import UserRolePage from './UserPage';
import MenuList from './MenuList';
import Organization from './Organization';
import StationManage from './StationManage';
const { Header, Content } = Layout;
const { Title, Text } = Typography;
const { Option } = Select;
const AntdCard = Card as any;
// 子页面组件,你可以替换成自己的
const BasicSettings = () => {
const [form] = Form.useForm();
const handleSave = () => {
message.success('设置已保存');
};
return (
<div style={{ padding: 24 }}>
{/* 顶部概览卡片 */}
<Row gutter={16} style={{ marginBottom: 24 }}>
<Col span={5}>
<AntdCard size="small">
<Space>
<div style={{ background: '#e6f4ff', borderRadius: 8, padding: 8 }}>
<CloudOutlined style={{ color: '#1677ff', fontSize: 20 }} />
</div>
<div>
<div style={{ fontSize: 13, color: '#666' }}>当前版本</div>
<div style={{ fontWeight: 600 }}>v2.8.1 <Tag color="blue">最新版</Tag></div>
</div>
</Space>
</AntdCard>
</Col>
<Col span={5}>
<AntdCard size="small">
<Space>
<div style={{ background: '#f6ffed', borderRadius: 8, padding: 8 }}>
<TeamOutlined style={{ color: '#52c41a', fontSize: 20 }} />
</div>
<div>
<div style={{ fontSize: 13, color: '#666' }}>在线用户</div>
<div style={{ fontWeight: 600 }}>12 <span style={{ color: '#52c41a', fontSize: 12 }}>↑ 2</span></div>
</div>
</Space>
</AntdCard>
</Col>
<Col span={5}>
<AntdCard size="small">
<Space>
<div style={{ background: '#fff2f0', borderRadius: 8, padding: 8 }}>
<BellOutlined style={{ color: '#ff4d4f', fontSize: 20 }} />
</div>
<div>
<div style={{ fontSize: 13, color: '#666' }}>告警通道</div>
<div style={{ fontWeight: 600 }}>3 / 4 <span style={{ color: '#52c41a', fontSize: 12 }}>正常</span></div>
</div>
</Space>
</AntdCard>
</Col>
<Col span={5}>
<AntdCard size="small">
<Space>
<div style={{ background: '#e6fffb', borderRadius: 8, padding: 8 }}>
<DatabaseOutlined style={{ color: '#13c2c2', fontSize: 20 }} />
</div>
<div>
<div style={{ fontSize: 13, color: '#666' }}>数据备份状态</div>
<div style={{ fontWeight: 600 }}>正常 <span style={{ color: '#52c41a', fontSize: 12 }}>●</span></div>
</div>
</Space>
</AntdCard>
</Col>
<Col span={4}>
<AntdCard size="small">
<Space>
<div style={{ background: '#f9f0ff', borderRadius: 8, padding: 8 }}>
<CalendarOutlined style={{ color: '#722ed1', fontSize: 20 }} />
</div>
<div>
<div style={{ fontSize: 13, color: '#666' }}>最近更新</div>
<div style={{ fontWeight: 600 }}>2025-05-20</div>
</div>
</Space>
</AntdCard>
</Col>
</Row>
{/* 基础配置 */}
<AntdCard title="基础配置" style={{ marginBottom: 24 }}>
<Form form={form} layout="vertical">
<Row gutter={16}>
<Col span={8}>
<Form.Item label="系统名称" name="systemName">
<Input defaultValue="光伏电站智能监控与运维系统" />
</Form.Item>
</Col>
<Col span={8}>
<Form.Item label="默认电站" name="defaultSite">
<Select defaultValue="1MW 光伏电站">
<Option value="1MW">1MW 光伏电站</Option>
</Select>
</Form.Item>
</Col>
<Col span={8}>
<Form.Item label="默认语言" name="defaultLang">
<Select defaultValue="中文">
<Option value="zh">中文</Option>
<Option value="en">English</Option>
</Select>
</Form.Item>
</Col>
</Row>
<Row gutter={16}>
<Col span={8}>
<Form.Item label="时区" name="timezone">
<Select defaultValue="UTC+08:00">
<Option value="UTC+08:00">UTC+08:00</Option>
</Select>
</Form.Item>
</Col>
<Col span={8}>
<Form.Item label="首页默认页面" name="homePage">
<Select defaultValue="总览首页">
<Option value="overview">总览首页</Option>
</Select>
</Form.Item>
</Col>
<Col span={8}>
<Form.Item label="数据刷新频率" name="refreshRate">
<Select defaultValue="5分钟">
<Option value="5">5分钟</Option>
</Select>
</Form.Item>
</Col>
</Row>
<Row gutter={16}>
<Col span={8}>
<Form.Item label="地图服务" name="mapService">
<Select defaultValue="高德地图">
<Option value="amap">高德地图</Option>
</Select>
</Form.Item>
</Col>
<Col span={8}>
<Form.Item label="工单自动编号" name="autoWorkOrder" valuePropName="checked">
<Switch defaultChecked />
</Form.Item>
</Col>
<Col span={8}>
<Form.Item label="AI建议自动生成" name="autoAiSuggest" valuePropName="checked">
<Switch defaultChecked />
</Form.Item>
</Col>
</Row>
<Row gutter={16}>
<Col span={8}>
<Form.Item label="移动端同步" name="mobileSync" valuePropName="checked">
<Switch defaultChecked />
</Form.Item>
</Col>
</Row>
<Space>
<Button type="primary" onClick={handleSave}>保存设置</Button>
<Button>恢复默认</Button>
</Space>
</Form>
</AntdCard>
{/* 通知与告警策略 */}
<AntdCard title="通知与告警策略" style={{ marginBottom: 24 }}>
<Row gutter={16} style={{ marginBottom: 16 }}>
<Col span={6}>
<Space>
<div style={{ background: '#f6ffed', borderRadius: 8, padding: 8 }}>
<BellOutlined style={{ color: '#52c41a', fontSize: 20 }} />
</div>
<div>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Text strong>短信</Text>
<Switch defaultChecked />
</div>
<Text type="secondary">已启用</Text>
</div>
</Space>
</Col>
<Col span={6}>
<Space>
<div style={{ background: '#e6f4ff', borderRadius: 8, padding: 8 }}>
<BellOutlined style={{ color: '#1677ff', fontSize: 20 }} />
</div>
<div>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Text strong>邮件</Text>
<Switch defaultChecked />
</div>
<Text type="secondary">已启用</Text>
</div>
</Space>
</Col>
<Col span={6}>
<Space>
<div style={{ background: '#fff7e6', borderRadius: 8, padding: 8 }}>
<BellOutlined style={{ color: '#fa8c16', fontSize: 20 }} />
</div>
<div>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Text strong>Telegram</Text>
<Switch defaultChecked />
</div>
<Text type="secondary">已启用</Text>
</div>
</Space>
</Col>
<Col span={6}>
<Space>
<div style={{ background: '#fff0f6', borderRadius: 8, padding: 8 }}>
<BellOutlined style={{ color: '#eb2f96', fontSize: 20 }} />
</div>
<div>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<Text strong>系统通知</Text>
<Switch defaultChecked />
</div>
<Text type="secondary">已启用</Text>
</div>
</Space>
</Col>
</Row>
<Row gutter={16}>
<Col span={8}>
<Form.Item label="严重告警立即通知" valuePropName="checked">
<Switch defaultChecked />
</Form.Item>
</Col>
<Col span={8}>
<Form.Item label="发电下降超过15%" valuePropName="checked">
<Switch defaultChecked />
</Form.Item>
</Col>
<Col span={8}>
<Form.Item label="通信中断通知" valuePropName="checked">
<Switch defaultChecked />
</Form.Item>
</Col>
</Row>
<Row gutter={16}>
<Col span={8}>
<Form.Item label="每日汇总推送" valuePropName="checked">
<Switch defaultChecked />
</Form.Item>
</Col>
<Col span={8}>
<Form.Item label="夜间免打扰">
<Select defaultValue="23:00-07:00">
<Option value="23:00-07:00">23:00-07:00</Option>
</Select>
</Form.Item>
</Col>
</Row>
</AntdCard>
{/* 用户与权限预览 */}
<AntdCard title="用户与权限预览">
<Table
size="small"
pagination={{ pageSize: 4 }}
columns={[
{ title: '用户名', dataIndex: 'name' },
{ title: '角色', dataIndex: 'role', render: t => <Tag color="blue">{t}</Tag> },
{ title: '手机号', dataIndex: 'phone' },
{ title: '邮箱', dataIndex: 'email' },
{ title: '状态', dataIndex: 'status', render: () => <span style={{ color: '#52c41a' }}>● 在线</span> },
{ title: '操作', render: () => <Button type="link">查看</Button> }
]}
dataSource={[
{ name: '张运维', role: '超级管理员', phone: '138****0001', email: 'zhangyw@pvsrmart.com' },
{ name: '李工程师', role: '运维工程师', phone: '139****0002', email: 'li.gongcheng@pvsrmart.com' },
{ name: '王班长', role: '巡检主管', phone: '137****0003', email: 'wang.banzhang@pvsrmart.com' },
{ name: '赵分析师', role: '数据分析师', phone: '136****0004', email: 'zhao.fx@pvsrmart.com' },
]}
/>
</AntdCard>
</div>
);
};
// 右侧面板组件
const RightPanel = () => {
return (
<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">用户2人 | 权限28项</Text>
<Space>
<Tag color="blue">全部权限</Tag>
<Tag color="blue">系统管理</Tag>
</Space>
</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">用户5人 | 权限18项</Text>
<Space>
<Tag color="green">设备管理</Tag>
<Tag color="green">工单管理</Tag>
</Space>
</Space>
</AntdCard>
</Col>
<Col span={12} style={{ marginTop: 16 }}>
<AntdCard size="small" hoverable style={{ background: '#fff7e6' }}>
<Space direction="vertical">
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<div style={{ background: '#fa8c16', borderRadius: '50%', padding: 4 }}>
<BellOutlined style={{ color: '#fff', fontSize: 16 }} />
</div>
<Text strong>巡检主管</Text>
</div>
<Text type="secondary">用户8人 | 权限12项</Text>
<Space>
<Tag color="orange">巡检管理</Tag>
<Tag color="orange">告警处理</Tag>
</Space>
</Space>
</AntdCard>
</Col>
<Col span={12} style={{ marginTop: 16 }}>
<AntdCard size="small" hoverable style={{ background: '#f9f0ff' }}>
<Space direction="vertical">
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<div style={{ background: '#722ed1', borderRadius: '50%', padding: 4 }}>
<DatabaseOutlined style={{ color: '#fff', fontSize: 16 }} />
</div>
<Text strong>数据分析师</Text>
</div>
<Text type="secondary">用户3人 | 权限15项</Text>
<Space>
<Tag color="purple">数据分析</Tag>
<Tag color="purple">报表查看</Tag>
</Space>
</Space>
</AntdCard>
</Col>
</Row>
</AntdCard>
{/* 设备接入状态 */}
<AntdCard title="设备接入状态" style={{ marginBottom: 24 }} extra={<Button type="link">查看详情 </Button>}>
<Row gutter={16}>
<Col span={12}>
<Space direction="vertical">
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<Space><CheckCircleOutlined style={{ color: '#52c41a' }} /> 逆变器</Space>
<Text>5 / 5 <span style={{ color: '#52c41a' }}>● 正常</span></Text>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<Space><CheckCircleOutlined style={{ color: '#52c41a' }} /> 汇流箱</Space>
<Text>20 / 20 <span style={{ color: '#52c41a' }}>● 正常</span></Text>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<Space><CheckCircleOutlined style={{ color: '#52c41a' }} /> 气象站</Space>
<Text>1 / 1 <span style={{ color: '#52c41a' }}>● 正常</span></Text>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<Space><CheckCircleOutlined style={{ color: '#52c41a' }} /> 摄像头</Space>
<Text>12 / 12 <span style={{ color: '#52c41a' }}>● 正常</span></Text>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<Space><CheckCircleOutlined style={{ color: '#52c41a' }} /> 无人机</Space>
<Text>2 / 2 <span style={{ color: '#52c41a' }}>● 正常</span></Text>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<Space><CheckCircleOutlined style={{ color: '#52c41a' }} /> 机器人</Space>
<Text>5 / 5 <span style={{ color: '#52c41a' }}>● 正常</span></Text>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<Space><CheckCircleOutlined style={{ color: '#52c41a' }} /> API接口</Space>
<Text>正常 <span style={{ color: '#52c41a' }}>● 正常</span></Text>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<Space><CheckCircleOutlined style={{ color: '#52c41a' }} /> Modbus</Space>
<Text>正常 <span style={{ color: '#52c41a' }}>● 正常</span></Text>
</div>
</Space>
</Col>
<Col span={12}>
{/* 这里可以放拓扑图,先用占位 */}
<div style={{ height: 240, display: 'flex', alignItems: 'center', justifyContent: 'center', border: '1px dashed #ddd', borderRadius: 8 }}>
<div style={{ textAlign: 'center' }}>
<DatabaseOutlined style={{ fontSize: 48, color: '#1677ff' }} />
<div style={{ marginTop: 8 }}>设备拓扑图</div>
</div>
</div>
</Col>
</Row>
</AntdCard>
{/* 数据与安全 */}
<AntdCard title="数据与安全" style={{ marginBottom: 24 }}>
<Row gutter={16}>
<Col span={12}>
<Space direction="vertical" style={{ width: '100%' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<Space><DatabaseOutlined /> 数据保留</Space>
<Text>3年</Text>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<Space><ReloadOutlined /> 每日自动备份</Space>
<Text>02:00</Text>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<Space><CalendarOutlined /> 最近备份时间</Space>
<Text>2025-05-24 02:00</Text>
</div>
</Space>
</Col>
<Col span={12}>
<Space direction="vertical" style={{ width: '100%' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<Space><SafetyOutlined /> 登录审计</Space>
<Tag color="green">已开启</Tag>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<Space><KeyOutlined /> API密钥管理</Space>
<Tag color="green">正常</Tag>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<Space><FileTextOutlined /> SSL证书</Space>
<Text>有效期至 2026-12-31</Text>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<Space><SafetyOutlined /> 双因素认证</Space>
<Tag color="green">已开启</Tag>
</div>
</Space>
</Col>
</Row>
</AntdCard>
{/* 系统维护 */}
<AntdCard title="系统维护" extra={<Text type="danger">操作需管理员权限</Text>}>
<Row gutter={16}>
<Col span={6}>
<Button block size="large" icon={<DeleteOutlined />}>清理缓存</Button>
</Col>
<Col span={6}>
<Button block size="large" icon={<SyncOutlined />}>重启服务</Button>
</Col>
<Col span={6}>
<Button block size="large" icon={<DownloadOutlined />}>备份下载</Button>
</Col>
<Col span={6}>
<Button block size="large" icon={<FileTextOutlined />}>日志导出</Button>
</Col>
</Row>
</AntdCard>
</div>
);
};
// 主页面组件
export default function SystemSettings() {
const [activeTab, setActiveTab] = useState('basic');
const tabItems = [
{ key: 'basic', label: '基础设置', icon: <SettingOutlined /> },
{ key: 'user-role', label: '用户与角色', icon: <UserOutlined /> },
{ key: 'menu', label: '菜单管理', icon: <AppstoreOutlined /> },
{ key: 'org', label: '组织管理', icon: <TeamOutlined /> }, //
{ key: 'station', label: '场站管理', icon: <BankOutlined /> },
{ key: 'notification', label: '通知策略', icon: <BellOutlined /> },
{ key: 'device', label: '设备接入', icon: <LinkOutlined /> },
{ key: 'security', label: '数据与安全', icon: <SafetyOutlined /> },
{ key: 'maintenance', label: '系统维护', icon: <SyncOutlined /> },
];
const renderTabContent = () => {
switch (activeTab) {
case 'basic':
return (
<Row gutter={24}>
<Col span={16}><BasicSettings /></Col>
<Col span={8}><RightPanel /></Col>
</Row>
);
case 'user-role':
return <UserRolePage />;
case 'menu':
return <MenuList />; // 菜单管理
case 'org':
return <Organization />; // 组织管理
case 'station':
return <StationManage />; // 场站管理
case 'notification':
return <div style={{ padding: 24 }}>通知策略页面</div>;
case 'device':
return <div style={{ padding: 24 }}>设备接入页面</div>;
case 'security':
return <div style={{ padding: 24 }}>数据与安全页面</div>;
case 'maintenance':
return <div style={{ padding: 24 }}>系统维护页面</div>;
default:
return null;
}
};
return (
<Layout style={{ minHeight: '100vh', background: '#fff', overflow: 'hidden' }}>
{/* 固定在当前组件内部顶部,不随滚动 */}
<Header style={{
background: '#fff',
padding: 0,
borderBottom: '1px solid #f0f0f0',
position: 'sticky',
top: 0,
left: 0,
zIndex: 10,
width: '100%'
}}>
<Menu
mode="horizontal"
selectedKeys={[activeTab]}
onClick={({ key }) => setActiveTab(key)}
items={tabItems}
style={{ border: 'none', height: 64, lineHeight: '64px', fontSize: 14 }}
/>
</Header>
{/* 内容区域可滚动 */}
<Content style={{
background: '#f5f7fa',
maxHeight: 'calc(100vh - 64px)',
overflowY: 'auto',
paddingBottom: 20,
scrollbarWidth: 'none',
msOverflowStyle: 'none',
}}>
{renderTabContent()}
</Content>
</Layout>
);
}