菜单模块增删改查

This commit is contained in:
mmc
2026-04-28 14:45:07 +08:00
parent c08278190a
commit 2a2d40d772
6 changed files with 532 additions and 528 deletions

View File

@@ -121,3 +121,14 @@ export function getDeptMenuTreeSelect(deptId) {
method: 'get' method: 'get'
}); });
} }
//获取树形菜单/getRouters
export function getTreeMenuList() {
return request({
url: `/getRouters`,
method: 'get'
});
}

View File

@@ -4,6 +4,8 @@ import {
Layout, Menu, Button, Space, ConfigProvider, theme, Layout, Menu, Button, Space, ConfigProvider, theme,
Breadcrumb, Badge, message Breadcrumb, Badge, message
} from 'antd'; } from 'antd';
// 先引入中文语言包
import zhCN from 'antd/locale/zh_CN';
import { import {
DashboardOutlined, ExperimentOutlined, VideoCameraOutlined, DashboardOutlined, ExperimentOutlined, VideoCameraOutlined,
BellOutlined, DownloadOutlined, UserOutlined, LogoutOutlined, BellOutlined, DownloadOutlined, UserOutlined, LogoutOutlined,
@@ -15,6 +17,7 @@ import { RootState, useAppDispatch } from '../store';
import { logout } from '../store/userSlice'; import { logout } from '../store/userSlice';
import { getMenuList } from '../api/mune'; import { getMenuList } from '../api/mune';
const { Header, Sider, Content } = Layout; const { Header, Sider, Content } = Layout;
export default function AppLayout() { export default function AppLayout() {
@@ -26,6 +29,8 @@ export default function AppLayout() {
const { userInfo } = useSelector((state: RootState) => state.user); const { userInfo } = useSelector((state: RootState) => state.user);
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const getMenu = () => { const getMenu = () => {
getMenuList().then(res => { getMenuList().then(res => {
if (res.code == 200) { if (res.code == 200) {
@@ -66,6 +71,7 @@ export default function AppLayout() {
return ( return (
<ConfigProvider <ConfigProvider
locale={zhCN}
theme={{ theme={{
algorithm: theme.defaultAlgorithm, algorithm: theme.defaultAlgorithm,
token: { colorPrimary: '#1890ff', borderRadius: 2 }, token: { colorPrimary: '#1890ff', borderRadius: 2 },
@@ -111,7 +117,11 @@ export default function AppLayout() {
</div> </div>
</Header> </Header>
<Layout> <Layout style={{
overflow: 'auto', background: '#ffffff',
height: "calc(100vh - 50px)",
overflowX: 'hidden'
}}>
{/* 左侧:菜单 + 下部区域 */} {/* 左侧:菜单 + 下部区域 */}
<Sider <Sider
trigger={null} trigger={null}
@@ -141,11 +151,12 @@ export default function AppLayout() {
</Sider> </Sider>
{/* 右侧:主内容 */} {/* 右侧:主内容 */}
<Content className=" overflow-y-auto bg-[#f4f7f9] min-h-0"> <Content className=" overflow-y-auto bg-[#f4f7f9] min-h-0 overflow-x-hidden">
<Outlet /> <Outlet />
</Content> </Content>
</Layout> </Layout>
</Layout> </Layout>
</ConfigProvider>
</ConfigProvider >
); );
} }

View File

@@ -13,6 +13,7 @@ import {
Select, Select,
DatePicker, DatePicker,
List, List,
Layout,
} from 'antd'; } from 'antd';
import { import {
BellOutlined, BellOutlined,
@@ -22,18 +23,15 @@ import {
ClockCircleOutlined, ClockCircleOutlined,
RiseOutlined, RiseOutlined,
FallOutlined, FallOutlined,
CloseOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import { ALERTS } from '../constants';
const { Text, Title } = Typography; const { Text } = Typography;
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
const AntdCard = Card as any;
export default function Alerts() { // 模拟数据
const [selectedAlert, setSelectedAlert] = useState<any>(null); const alertList = [
const AntdCard = Card as any;
// 模拟告警数据(和参考图一致)
const alertList = [
{ {
id: 'AL20250525001', id: 'AL20250525001',
content: '逆变器停机', content: '逆变器停机',
@@ -42,7 +40,7 @@ export default function Alerts() {
time: '2025-05-25 09:18:32', time: '2025-05-25 09:18:32',
duration: '2小时18分', duration: '2小时18分',
status: '处理中', status: '处理中',
handler: '张运维' handler: '张运维',
}, },
{ {
id: 'AL20250525002', id: 'AL20250525002',
@@ -52,7 +50,7 @@ export default function Alerts() {
time: '2025-05-25 08:46:11', time: '2025-05-25 08:46:11',
duration: '3小时50分', duration: '3小时50分',
status: '处理中', status: '处理中',
handler: '李工程师' handler: '李工程师',
}, },
{ {
id: 'AL20250525003', id: 'AL20250525003',
@@ -62,34 +60,62 @@ export default function Alerts() {
time: '2025-05-25 07:32:45', time: '2025-05-25 07:32:45',
duration: '4小时24分', duration: '4小时24分',
status: '待处理', status: '待处理',
handler: '-' handler: '-',
},
];
const stats = [
{
title: '今日告警总数',
value: 36,
change: '+28.6%',
up: true,
extra: '昨日 28',
icon: <BellOutlined style={{ color: '#ff4d4f' }} />,
}, },
{ {
id: 'AL20250525004', title: '严重告警',
content: '通信中断', value: 8,
device: '气象站 01', change: '+33.3%',
level: '一般', up: true,
time: '2025-05-25 06:51:20', extra: '昨日 6',
duration: '5小时05分', icon: <AlertOutlined style={{ color: '#ff4d4f' }} />,
status: '待处理',
handler: '王运维'
}, },
{ {
id: 'AL20250525005', title: '处理中',
content: '数据异常', value: 12,
device: '电表 01 (并网点)', change: '+20.0%',
level: '提示', up: true,
time: '2025-05-25 06:20:18', extra: '昨日 10',
duration: '3小时36分', icon: <SyncOutlined style={{ color: '#fa8c16' }} />,
status: '已关闭',
handler: '赵工程师'
}, },
]; {
title: '已关闭',
value: 16,
change: '+45.5%',
up: true,
extra: '昨日 11',
icon: <CheckCircleOutlined style={{ color: '#52c41a' }} />,
},
{
title: '平均响应时长',
value: '18分32秒',
change: '-12.6%',
up: false,
extra: '昨日 21分12秒',
icon: <ClockCircleOutlined style={{ color: '#1890ff' }} />,
},
];
export default function Alerts() {
// 控制右侧详情面板
const [showDetail, setShowDetail] = useState(false);
const [selectedAlert, setSelectedAlert] = useState<any>(null);
const columns = [ const columns = [
{ title: '告警编号', dataIndex: 'id', key: 'id', width: 120 }, { title: '告警编号', dataIndex: 'id', key: 'id', width: 120 },
{ title: '告警内容', dataIndex: 'content', key: 'content' }, { title: '告警内容', dataIndex: 'content', key: 'content' },
{ title: '来源设备', dataIndex: 'device', key: 'device', width: 140 }, { title: '来源设备', dataIndex: 'device', key: 'device', width: 160 },
{ {
title: '告警级别', title: '告警级别',
dataIndex: 'level', dataIndex: 'level',
@@ -97,16 +123,16 @@ export default function Alerts() {
width: 80, width: 80,
render: (level: string) => { render: (level: string) => {
const colorMap: Record<string, string> = { const colorMap: Record<string, string> = {
'严重': 'red', 严重: 'red',
'重要': 'orange', 重要: 'orange',
'一般': 'gold', 一般: 'gold',
'提示': 'blue' 提示: 'blue',
}; };
return <Tag color={colorMap[level]}>{level}</Tag>; return <Tag color={colorMap[level]}>{level}</Tag>;
} },
}, },
{ title: '发生时间', dataIndex: 'time', key: 'time', width: 160 }, { title: '发生时间', dataIndex: 'time', key: 'time', width: 160 },
{ title: '持续时长', dataIndex: 'duration', key: 'duration', width: 100 }, { title: '持续时长', dataIndex: 'duration', key: 'duration', width: 110 },
{ {
title: '处理状态', title: '处理状态',
dataIndex: 'status', dataIndex: 'status',
@@ -114,56 +140,56 @@ export default function Alerts() {
width: 100, width: 100,
render: (status: string) => { render: (status: string) => {
const colorMap: Record<string, string> = { const colorMap: Record<string, string> = {
'处理中': 'blue', 处理中: 'blue',
'待处理': 'orange', 待处理: 'orange',
'已关闭': 'green' 已关闭: 'green',
}; };
return <Tag color={colorMap[status]}>{status}</Tag>; return <Tag color={colorMap[status]}>{status}</Tag>;
}
}, },
{ title: '负责人', dataIndex: 'handler', key: 'handler', width: 80 }, },
{ title: '负责人', dataIndex: 'handler', key: 'handler', width: 90 },
{ {
title: '操作', title: '操作',
key: 'action', key: 'action',
width: 60, width: 80,
render: () => <Button type="link" size="small">查看</Button> render: (_, record) => (
<Button
type="link"
size="small"
onClick={() => {
setSelectedAlert(record);
setShowDetail(true);
}}
>
查看
</Button>
),
}, },
]; ];
// 顶部统计数据
const stats = [
{ title: '今日告警总数', value: 36, suffix: '', change: '+28.6%', up: true, extra: '昨日 28', icon: <BellOutlined style={{ color: '#ff4d4f' }} /> },
{ title: '严重告警', value: 8, suffix: '', change: '+33.3%', up: true, extra: '昨日 6', icon: <AlertOutlined style={{ color: '#ff4d4f' }} /> },
{ title: '处理中', value: 12, suffix: '', change: '+20.0%', up: true, extra: '昨日 10', icon: <SyncOutlined style={{ color: '#fa8c16' }} /> },
{ title: '已关闭', value: 16, suffix: '', change: '+45.5%', up: true, extra: '昨日 11', icon: <CheckCircleOutlined style={{ color: '#52c41a' }} /> },
{ title: '平均响应时长', value: '18分32秒', suffix: '', change: '-12.6%', up: false, extra: '昨日 21分12秒', icon: <ClockCircleOutlined style={{ color: '#1890ff' }} /> },
];
return ( return (
<div style={{ padding: '16px', background: '#f4f7f9', minHeight: '100%' }}> <div style={{ background: '#f4f7f9', minHeight: '100%' }}>
<p className="text-lg font-semibold text-[#000] mb-2"> <Layout style={{ background: 'transparent' }}>
告警中心 {/* 左侧主内容区:宽度动态变化 */}
</p> <Layout.Content
{/* 顶部筛选栏 */} style={{
padding: '16px',
transition: 'width 0.3s ease',
width: showDetail ? 'calc(100% - 460px)' : '100%',
}}
>
<div style={{ fontSize: 16, fontWeight: 600, marginBottom: 12 }}>告警中心</div>
{/* 筛选栏 */}
<AntdCard size="small" style={{ borderRadius: 8, marginBottom: 16 }}> <AntdCard size="small" style={{ borderRadius: 8, marginBottom: 16 }}>
<Row gutter={[16, 16]} align="middle"> <Row gutter={[16, 16]} align="middle">
<Col span={4}> <Col span={4}><Select placeholder="告警级别" style={{ width: '100%' }} /></Col>
<Select placeholder="告警级别" defaultValue="全部" style={{ width: '100%' }} options={[{ label: '全部', value: 'all' }, { label: '严重', value: 'critical' }, { label: '重要', value: 'important' }, { label: '一般', value: 'normal' }, { label: '提示', value: 'info' }]} /> <Col span={4}><Select placeholder="告警类型" style={{ width: '100%' }} /></Col>
</Col> <Col span={4}><Select placeholder="设备类型" style={{ width: '100%' }} /></Col>
<Col span={4}> <Col span={6}><RangePicker style={{ width: '100%' }} /></Col>
<Select placeholder="告警类型" defaultValue="全部" style={{ width: '100%' }} options={[{ label: '全部', value: 'all' }]} /> <Col span={6}><Select placeholder="处理状态" style={{ width: '100%' }} /></Col>
</Col> <Col span={24} style={{ display: 'flex', gap: 8, marginTop: 8 }}>
<Col span={4}> <Input placeholder="搜索" style={{ width: 220 }} />
<Select placeholder="设备类型" defaultValue="全部" style={{ width: '100%' }} options={[{ label: '全部', value: 'all' }]} />
</Col>
<Col span={6}>
<RangePicker defaultValue={[null, null]} style={{ width: '100%' }} />
</Col>
<Col span={4}>
<Select placeholder="处理状态" defaultValue="全部" style={{ width: '100%' }} options={[{ label: '全部', value: 'all' }, { label: '处理中', value: 'processing' }, { label: '已关闭', value: 'closed' }]} />
</Col>
<Col span={24} style={{ display: 'flex', alignItems: 'center', gap: 8, marginTop: 8 }}>
<Input placeholder="请输入告警编号内容" style={{ width: 200 }} />
<Button>重置</Button> <Button>重置</Button>
<Button type="primary">查询</Button> <Button type="primary">查询</Button>
</Col> </Col>
@@ -174,17 +200,16 @@ export default function Alerts() {
<Row gutter={[16, 16]} style={{ marginBottom: 16 }}> <Row gutter={[16, 16]} style={{ marginBottom: 16 }}>
{stats.map((stat, idx) => ( {stats.map((stat, idx) => (
<Col xs={24} sm={12} md={8} lg={4} key={idx}> <Col xs={24} sm={12} md={8} lg={4} key={idx}>
<AntdCard size="small" style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}> <AntdCard size="small" style={{ borderRadius: 8 }}>
<Statistic <Statistic
title={<span style={{ fontSize: 13, color: '#666' }}>{stat.title}</span>} title={<span style={{ fontSize: 13 }}>{stat.title}</span>}
value={stat.value} value={stat.value}
valueStyle={{ color: '#1f2329', fontWeight: 600, fontSize: 20 }} valueStyle={{ fontSize: 20, fontWeight: 600 }}
prefix={stat.icon} prefix={stat.icon}
suffix={stat.suffix}
/> />
<div style={{ marginTop: 4, display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}> <div style={{ display: 'flex', justifyContent: 'space-between', marginTop: 4 }}>
<Text type="secondary" style={{ fontSize: 12 }}>{stat.extra}</Text> <Text type="secondary" style={{ fontSize: 12 }}>{stat.extra}</Text>
<Text style={{ fontSize: 12, color: stat.up ? '#ff4d4f' : '#52c41a' }}> <Text style={{ color: stat.up ? '#ff4d4f' : '#52c41a', fontSize: 12 }}>
{stat.change} {stat.up ? <RiseOutlined /> : <FallOutlined />} {stat.change} {stat.up ? <RiseOutlined /> : <FallOutlined />}
</Text> </Text>
</div> </div>
@@ -193,130 +218,106 @@ export default function Alerts() {
))} ))}
</Row> </Row>
<Row gutter={[16, 16]}>
{/* 左侧主内容区 */}
<Col xs={24} lg={18}>
{/* 告警列表 */} {/* 告警列表 */}
<AntdCard size="small" title={ <AntdCard
<div style={{ display: 'flex', gap: 4, fontSize: 14, fontWeight: 600 }}> size="small"
title={
<div style={{ fontSize: 14, fontWeight: 600 }}>
<span style={{ color: '#165DFF' }}>告警列表</span> <span style={{ color: '#165DFF' }}>告警列表</span>
<span style={{ color: '#1f2937' }}>(共36条)</span> <span style={{ color: '#333' }}>(共36条)</span>
</div> </div>
} style={{ borderRadius: 8, marginBottom: 16 }}> }
style={{ borderRadius: 8 }}
>
<Table <Table
size="small" size="small"
columns={columns} columns={columns}
dataSource={alertList} dataSource={alertList}
pagination={{ pageSize: 10, total: 36, showSizeChanger: true }} pagination={{ pageSize: 10 }}
rowKey="id" rowKey="id"
onRow={(record) => ({ onClick: () => setSelectedAlert(record) })} onRow={(record) => ({
rowSelection={{ selectedRowKeys: selectedAlert ? [selectedAlert.id] : [], type: 'radio' }} onClick: () => {
setSelectedAlert(record);
setShowDetail(true);
},
})}
/> />
</AntdCard> </AntdCard>
</Layout.Content>
{/* 底部图表占位(和参考图结构一致) */} {/* 右侧详情面板:推挤式,非覆盖 */}
<Row gutter={[16, 16]}> {showDetail && (
<Col xs={24} lg={8}> <Layout.Sider
<AntdCard size="small" style={{ borderRadius: 8 }}> width={460}
<div style={{ height: 150, background: '#f5f7fa', borderRadius: 4, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#888' }}> style={{
趋势图占位 background: '#fff',
</div> padding: '16px',
</AntdCard> height: 'calc(100vh - 50px)',
</Col> overflow: 'auto',
<Col xs={24} lg={8}> boxShadow: '-2px 0 8px rgba(0,0,0,0.08)',
<AntdCard size="small" style={{ borderRadius: 8 }}> }}
<div style={{ height: 150, background: '#f5f7fa', borderRadius: 4, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#888' }}> >
占比图占位 {selectedAlert && (
</div>
</AntdCard>
</Col>
<Col xs={24} lg={8}>
<AntdCard size="small" style={{ borderRadius: 8 }}>
<div style={{ height: 150, background: '#f5f7fa', borderRadius: 4, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#888' }}>
分布图占位
</div>
</AntdCard>
</Col>
</Row>
</Col>
{/* 右侧告警详情面板 */}
<Col xs={24} lg={6}>
<AntdCard size="small" style={{ borderRadius: 8, height: '100%' }}>
{selectedAlert ? (
<div> <div>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}>
<Text strong style={{ fontSize: 16 }}>告警详情</Text>
<Button
type="text"
icon={<CloseOutlined />}
onClick={() => setShowDetail(false)}
style={{ fontSize: 16 }}
/> </div>
<div style={{ marginBottom: 16 }}> <div style={{ marginBottom: 16 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 8 }}> <div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 8 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<BellOutlined style={{ color: '#ff4d4f', fontSize: 20 }} /> <BellOutlined style={{ color: '#ff4d4f', fontSize: 20 }} />
<Text strong style={{ fontSize: 16 }}>{selectedAlert.content}</Text> <Text strong style={{ fontSize: 16 }}>{selectedAlert.content}</Text>
<Tag color="red">{selectedAlert.level}</Tag> <Tag color="red">{selectedAlert.level}</Tag>
</div> </div>
<Text type="secondary" style={{ fontSize: 12 }}>告警编号 AL20250525001</Text> <div style={{ fontSize: 12, color: '#666', lineHeight: 1.8 }}>
</div> <div>告警编号:{selectedAlert.id}</div>
<div style={{ fontSize: 12, color: '#666' }}> <div>来源设备:{selectedAlert.device}</div>
<div>来源设备:{selectedAlert.device}(设备类型:逆变器)</div> <div>发生时间:{selectedAlert.time}</div>
<div>发生时间:{selectedAlert.time} | 持续时长:{selectedAlert.duration}</div> <div>持续时长:{selectedAlert.duration}</div>
<div>处理状态:<Tag color="blue">{selectedAlert.status}</Tag> | 负责人:{selectedAlert.handler}</div> <div>处理状态:{selectedAlert.status}</div>
<div>当前处理人:{selectedAlert.handler}({selectedAlert.time.split(' ')[0]} 接收)</div> <div>负责人:{selectedAlert.handler}</div>
<div>告警描述:逆变器因内部故障自动停机,当前无功率输出。</div>
</div> </div>
</div> </div>
<div style={{ marginBottom: 16 }}> <div style={{ marginBottom: 16 }}>
<Text strong style={{ fontSize: 13, marginBottom: 8, display: 'block' }}>根因分析建议</Text> <Text strong style={{ fontSize: 13, marginBottom: 8, display: 'block' }}>根因分析建议</Text>
<List size="small" dataSource={[ <List
size="small"
dataSource={[
'逆变器内部保护触发(IGBT/继电器故障)', '逆变器内部保护触发(IGBT/继电器故障)',
'交流侧电压异常或并网不稳定', '交流侧电压异常或并网不稳定',
'散热风扇故障导致过温保护' '散热风扇故障导致过温保护',
]} renderItem={(item) => <List.Item style={{ padding: '4px 0', fontSize: 12 }}>{item}</List.Item>} /> ]}
<Button type="primary" size="small" style={{ marginTop: 8 }}>AI 诊断分析</Button> renderItem={(item) => <List.Item style={{ padding: '4px 0' }}>{item}</List.Item>}
</div> />
<div style={{ marginBottom: 16 }}>
<Text strong style={{ fontSize: 13, marginBottom: 8, display: 'block' }}>相关趋势</Text>
<div style={{ height: 100, background: '#f5f7fa', borderRadius: 4, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#888' }}>
趋势图占位
</div>
</div> </div>
<div style={{ marginBottom: 16 }}> <div style={{ marginBottom: 16 }}>
<Text strong style={{ fontSize: 13, marginBottom: 8, display: 'block' }}>推荐处理措施</Text> <Text strong style={{ fontSize: 13, marginBottom: 8, display: 'block' }}>推荐处理措施</Text>
<List size="small" dataSource={[ <List
size="small"
dataSource={[
'现场检查逆变器告警记录及指示灯状态', '现场检查逆变器告警记录及指示灯状态',
'检查散热风扇运行及通风条件', '检查散热风扇运行及通风条件',
'检查交流侧电压及并网条件', '检查交流侧电压及并网条件',
'如无法恢复,建议联系厂家或更换模块' ]}
]} renderItem={(item) => <List.Item style={{ padding: '4px 0', fontSize: 12 }}>{item}</List.Item>} /> renderItem={(item) => <List.Item style={{ padding: '4px 0' }}>{item}</List.Item>}
<Button type="primary" size="small" style={{ marginTop: 8 }}>生成工单</Button> />
</div> </div>
<div style={{ marginBottom: 16 }}> <Button type="primary" block style={{ marginTop: 16 }}>
<Text strong style={{ fontSize: 13, marginBottom: 8, display: 'block' }}>通知与订阅</Text> 标记为已解决
<Space direction="vertical" size="small" style={{ width: '100%' }}> </Button>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<span style={{ fontSize: 12 }}>短信</span>
<span style={{ fontSize: 12, color: '#1890ff' }}>已开启</span>
</div> </div>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<span style={{ fontSize: 12 }}>Telegram</span>
<span style={{ fontSize: 12, color: '#1890ff' }}>已开启</span>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<span style={{ fontSize: 12 }}>邮件</span>
<span style={{ fontSize: 12, color: '#888' }}>未开启</span>
</div>
</Space>
</div>
<Button type="primary" block>标记为已解决</Button>
</div>
) : (
<div style={{ textAlign: 'center', padding: '40px 0', color: '#888' }}>请选择一条告警查看详情</div>
)} )}
</AntdCard> </Layout.Sider>
</Col> )}
</Row> </Layout>
</div> </div>
); );
} }

View File

@@ -1,4 +1,4 @@
import React from 'react'; import React, { useState } from 'react';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { import {
Form, Form,
@@ -6,7 +6,6 @@ import {
Button, Button,
Typography, Typography,
Card, Card,
message,
Checkbox, Checkbox,
App, App,
} from 'antd'; } from 'antd';
@@ -22,50 +21,46 @@ import { useAppDispatch } from '../store';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
const { Text, Title } = Typography; const { Text, Title } = Typography;
const AntdCard = Card as any;
export default function Login() { export default function Login() {
const navigate = useNavigate(); const navigate = useNavigate();
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const { message, } = App.useApp(); const { message } = App.useApp();
// 登录 loading 状态
const [loading, setLoading] = useState(false);
// 账号密码登录 // 账号密码登录
const onFinish = async (values: any) => { const onFinish = async (values: any) => {
try { try {
// 开启 loading
setLoading(true);
// 👇 调用 dispatch,并用 unwrap() 拿到 return 的数据 // 👇 调用 dispatch,并用 unwrap() 拿到 return 的数据
const loginResult = await dispatch(userLogin(values)).unwrap(); const loginResult = await dispatch(userLogin(values)).unwrap();
// loginResult 就是你 userLogin 里 return 的 res // loginResult 就是你 userLogin 里 return 的 res
console.log("登录成功返回的数据:", loginResult);
if (loginResult.code == 200) { if (loginResult.code == 200) {
//dispatch(setUserInfo(loginResult)) message.success('登录成功');
const searchParams = new URLSearchParams(window.location.search); const searchParams = new URLSearchParams(window.location.search);
const goRemote = searchParams.get('goRemote'); const goRemote = searchParams.get('goRemote');
if (Number(goRemote) == 1) { if (Number(goRemote) == 1) {
const rawUserId = Cookies.get("userId"); // 比如 "32434" const rawUserId = Cookies.get('userId');
const encodedUserId = btoa(unescape(encodeURIComponent(rawUserId))); const encodedUserId = btoa(unescape(encodeURIComponent(rawUserId)));
window.location.href = `https://ai.satabot.com/?userId=${encodedUserId}`; window.location.href = `https://ai.satabot.com/?userId=${encodedUserId}`;
return; return;
} }
message.success(`登录成功`);
navigate('/', { replace: true }); navigate('/', { replace: true });
} else { } else {
message.error('登录失败:' + loginResult.msg);
message.error("登录失败:" + loginResult.msg);
} }
// 登录成功后跳转
} catch (err) { } catch (err) {
message.error("登录失败:" + err.toString()); message.error('登录失败:' + err.toString());
} finally {
// 无论成功失败,关闭 loading
setLoading(false);
} }
}; };
return ( return (
@@ -82,7 +77,7 @@ export default function Login() {
transition={{ duration: 0.4 }} transition={{ duration: 0.4 }}
className="w-full max-w-5xl" className="w-full max-w-5xl"
> >
<Card <AntdCard
variant={false} variant={false}
className="shadow-xl overflow-hidden rounded-2xl" className="shadow-xl overflow-hidden rounded-2xl"
styles={{ body: { padding: 0 } }} styles={{ body: { padding: 0 } }}
@@ -112,20 +107,26 @@ export default function Login() {
/> />
</Form.Item> </Form.Item>
{/* 记住密码 */} {/* 用户协议 */}
{/*<Form.Item name="remember" valuePropName="checked" noStyle> <Form.Item
name="agreement"
valuePropName="checked"
rules={[{ validator: (_, value) => value ? Promise.resolve() : Promise.reject(new Error('请阅读并同意用户协议')) }]}
>
<Checkbox> <Checkbox>
<Text style={{ fontSize: 14, color: '#666' }}>记住密码</Text> <Text style={{ fontSize: 14, color: '#666' }}>
我已阅读并同意 <Text type="link" style={{ padding: 0, color: '#1677ff' }}>用户协议</Text> 和 <Text type="link" style={{ padding: 0, color: '#1677ff' }}>隐私政策</Text>
</Text>
</Checkbox> </Checkbox>
</Form.Item>*/} </Form.Item>
<Form.Item style={{ marginTop: 20 }}> <Form.Item style={{ marginTop: 20 }}>
<Button <Button
type="primary" type="primary"
htmlType="submit" htmlType="submit"
block block
// 绑定 loading
loading={loading}
style={{ style={{
borderRadius: 8, borderRadius: 8,
height: 52, height: 52,
@@ -139,18 +140,6 @@ export default function Login() {
登录 登录
</Button> </Button>
</Form.Item> </Form.Item>
{/* 用户协议 */}
<Form.Item
name="agreement"
valuePropName="checked"
rules={[{ validator: (_, value) => value ? Promise.resolve() : Promise.reject(new Error('请阅读并同意用户协议')) }]}
>
<Checkbox>
<Text style={{ fontSize: 14, color: '#666' }}>
我已阅读并同意 <Text type="link" style={{ padding: 0, color: "#1677ff" }}>用户协议</Text> 和 <Text type="link" style={{ padding: 0, color: "#1677ff" }}>隐私政策</Text>
</Text>
</Checkbox>
</Form.Item>
</Form> </Form>
</motion.div> </motion.div>
</div> </div>
@@ -159,7 +148,6 @@ export default function Login() {
<div <div
className="md:w-1/2 relative min-h-[600px] overflow-hidden" className="md:w-1/2 relative min-h-[600px] overflow-hidden"
style={{ style={{
// 梯形斜切效果
clipPath: 'polygon(12% 0, 100% 0, 100% 100%, 0 100%)', clipPath: 'polygon(12% 0, 100% 0, 100% 100%, 0 100%)',
}} }}
> >
@@ -174,7 +162,7 @@ export default function Login() {
/> />
</div> </div>
</div> </div>
</Card> </AntdCard>
</motion.div> </motion.div>
</div> </div>
); );

View File

@@ -1,50 +1,16 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { import {
Table, Button, Typography, Space, Modal, Form, Tree, message, Table, Button, Space, Modal, Form, Tree, message,
Input, Popconfirm, Select Input, Popconfirm, Select, Card, InputNumber
} from 'antd'; } from 'antd';
import { import {
PlusOutlined, EditOutlined, DeleteOutlined, SettingOutlined PlusOutlined, EditOutlined, DeleteOutlined, SettingOutlined
} from '@ant-design/icons'; } from '@ant-design/icons';
import { addMenu, deleteMenu, getMenuList, updateMenu } from '../api/mune';
const { Title } = Typography;
const { Option } = Select; const { Option } = Select;
// 1. 完整菜单树 // 角色列表
const menuData = [
{
id: 1,
title: '控制台',
path: '/dashboard',
parentId: 0,
children: [
{ id: 11, title: '概览', path: '/dashboard/overview', parentId: 1 },
],
},
{
id: 2,
title: '设备管理',
path: '/device',
parentId: 0,
children: [
{ id: 21, title: '机器人管理', path: '/device/robot', parentId: 2 },
{ id: 22, title: '视频监控', path: '/device/video', parentId: 2 },
],
},
{
id: 3,
title: '系统管理',
path: '/system',
parentId: 0,
children: [
{ id: 31, title: '用户管理', path: '/system/user', parentId: 3 },
{ id: 32, title: '角色管理', path: '/system/role', parentId: 3 },
{ id: 33, title: '菜单管理', path: '/system/menu', parentId: 3 },
],
},
];
// 2. 角色列表
const roleList = [ const roleList = [
{ name: '平台admin', key: 'admin' }, { name: '平台admin', key: 'admin' },
{ name: '区域机构管理员', key: 'region_admin' }, { name: '区域机构管理员', key: 'region_admin' },
@@ -52,152 +18,176 @@ const roleList = [
{ name: '场站员工', key: 'site_staff' }, { name: '场站员工', key: 'site_staff' },
]; ];
// 扁平化菜单 // 扁平数组 → 树形结构(给表格 + 权限树共用)
const flattenMenu = (menus) => { const buildTreeFromFlat = (data) => {
let arr = [];
const loop = (list, parentPath = '') => {
list.forEach(item => {
const fullPath = parentPath ? `${parentPath}/${item.path}` : item.path;
arr.push({ ...item, fullPath });
if (item.children?.length) loop(item.children, item.path);
});
};
loop(menus);
return arr;
};
// 转树形结构(用于Tree组件)
const buildTree = (flatten) => {
const map = {}; const map = {};
const tree = []; const tree = [];
flatten.forEach(item => {
map[item.id] = { ...item, children: [] }; data.forEach(item => {
map[item.menuId] = { ...item, children: [] };
}); });
flatten.forEach(item => {
if (item.parentId === 0) { data.forEach(item => {
tree.push(map[item.id]); if (item.parentId === 0 || !item.parentId) {
tree.push(map[item.menuId]);
} else { } else {
if (map[item.parentId]) { if (map[item.parentId]) {
map[item.parentId].children.push(map[item.id]); map[item.parentId].children.push(map[item.menuId]);
} }
} }
}); });
return tree; return tree;
}; };
// 存储角色权限 // 菜单数据转 Tree组件 格式
const buildPermTree = (treeData) => {
const loop = (list) => {
return list.map(item => {
const node = {
title: item.menuName,
key: item.menuId,
};
if (item.children && item.children.length) {
node.children = loop(item.children);
}
return node;
});
};
return loop(treeData);
};
const rolePermissionMap = {}; const rolePermissionMap = {};
export default function Roles() { export default function MenuList() {
const [menus, setMenus] = useState(flattenMenu(menuData)); const [rawMenuList, setRawMenuList] = useState([]);
const [menuTree, setMenuTree] = useState(buildTree(flattenMenu(menuData))); const [menuTreeData, setMenuTreeData] = useState([]);
const [menuTree, setMenuTree] = useState([]);
// 新增/编辑菜单
const [menuModal, setMenuModal] = useState(false); const [menuModal, setMenuModal] = useState(false);
const [menuForm] = Form.useForm(); const [menuForm] = Form.useForm();
const [editMenu, setEditMenu] = useState(null); const [editMenu, setEditMenu] = useState(null);
// 权限配置
const [permModal, setPermModal] = useState(false); const [permModal, setPermModal] = useState(false);
const [selectedRole, setSelectedRole] = useState(''); const [selectedRole, setSelectedRole] = useState('');
const [checkedKeys, setCheckedKeys] = useState([]); const [checkedKeys, setCheckedKeys] = useState([]);
const [messageApi, contextHolder] = message.useMessage();
// 菜单类型:一级/二级 // 获取菜单
const menuType = Form.useWatch('menuType', menuForm); const getMenuListApi = () => {
getMenuList().then(res => {
// 每次菜单变化,重新生成树形 if (res.code === 200) {
useEffect(() => { const data = res.data || [];
setMenuTree(buildTree(menus)); setRawMenuList(data);
}, [menus]); // 扁平转树形 → 表格树形 & 权限树
const tree = buildTreeFromFlat(data);
// 打开编辑 setMenuTreeData(tree);
const handleEdit = (record) => { setMenuTree(buildPermTree(tree));
setEditMenu(record); }
menuForm.setFieldsValue({ }).catch(() => {
...record, messageApi.error('菜单加载失败');
menuType: record.parentId === 0 ? 'top' : 'sub',
}); });
};
useEffect(() => {
getMenuListApi();
}, []);
// 编辑
const handleEdit = (record) => {
console.log(record, "values11")
setEditMenu(record);
menuForm.setFieldsValue({ ...record });
setMenuModal(true); setMenuModal(true);
}; };
// 保存菜单(新增+编辑) // 保存菜单
const handleSaveMenu = () => { const handleSaveMenu = () => {
menuForm.validateFields().then(values => { menuForm.validateFields().then(values => {
const { menuType, parentId, title, path } = values; console.log(values, "values")
if (editMenu) { if (editMenu) {
// 编辑 const data = {
setMenus(menus.map(m => menuId: editMenu.menuId,
m.id === editMenu.id ...values
? {
...m,
title,
path,
parentId: menuType === 'top' ? 0 : Number(parentId)
}
: m
));
message.success('编辑成功');
} else {
// 新增
const newMenu = {
id: Date.now(),
title,
path,
parentId: menuType === 'top' ? 0 : Number(parentId),
};
setMenus([...menus, newMenu]);
message.success('新增菜单成功');
} }
updateMenu(data).then(res => {
if (res.code === 200) {
messageApi.success("编辑成功");
setMenuModal(false); setMenuModal(false);
getMenuListApi();
} else {
messageApi.error(res.msg);
}
}).catch(() => {
messageApi.error('编辑失败');
});
} else {
addMenu(values).then(res => {
if (res.code === 200) {
messageApi.success("新增成功");
setMenuModal(false);
getMenuListApi();
} else {
messageApi.error(res.msg);
}
}).catch(() => {
messageApi.error('新增失败');
});
}
}); });
}; };
// 删除菜单 // 删除
const handleDelete = (id) => { const handleDelete = (menuId) => {
setMenus(menus.filter(m => m.id !== id)); deleteMenu(menuId).then(res => {
message.success('删除成功'); if (res.code == 200) {
messageApi.success('删除成功');
getMenuListApi();
} else {
messageApi.error(res.msg);
}
}).catch(() => {
messageApi.error("删除失败");
})
}; };
// 打开权限配置 // 权限弹窗
const handlePermOpen = () => { const handlePermOpen = () => {
if (!selectedRole) { if (!selectedRole) return messageApi.warning('请选择角色');
message.warning('请先选择角色'); setCheckedKeys(rolePermissionMap[selectedRole] || []);
return;
}
const saved = rolePermissionMap[selectedRole] || [];
setCheckedKeys(saved);
setPermModal(true); setPermModal(true);
}; };
// 保存权限
const handlePermSave = () => { const handlePermSave = () => {
rolePermissionMap[selectedRole] = checkedKeys; rolePermissionMap[selectedRole] = checkedKeys;
message.success(`【${selectedRole}】权限保存成功`); messageApi.success(`【${selectedRole}】权限保存成功`);
setPermModal(false); setPermModal(false);
}; };
// 一级菜单列表(用于父级选择) // 上级菜单下拉选项(只展示一级)
const topMenus = menus.filter(m => m.parentId === 0); const topMenus = rawMenuList.filter(m => m.parentId === 0 || !m.parentId);
const columns = [ const columns = [
{ title: '菜单名称', dataIndex: 'title', key: 'title', width: 180 }, {
{ title: '路由地址', dataIndex: 'fullPath', key: 'fullPath' }, title: '菜单名称',
dataIndex: 'menuName',
key: 'menuName',
// 关键:antd 表格自带缩进树形
},
{ title: '路由地址', dataIndex: 'path', key: 'path' },
{ title: '排序', dataIndex: 'orderNum', key: 'orderNum' },
{ {
title: '操作', title: '操作',
key: 'action', key: 'action',
width: 220, width: 220,
render: (_, record) => ( render: (_, record) => (
<Space> <Space>
<Button type="link" icon={<EditOutlined />} onClick={() => handleEdit(record)}> <Button type="text" icon={<EditOutlined />} onClick={() => handleEdit(record)}>编辑</Button>
编辑 <Popconfirm title="确定删除?" onConfirm={() => handleDelete(record.menuId)}>
</Button> <Button type="text" danger>删除</Button>
<Popconfirm
title="确定删除该菜单?"
onConfirm={() => handleDelete(record.id)}
>
<Button type="link" danger icon={<DeleteOutlined />}>
删除
</Button>
</Popconfirm> </Popconfirm>
</Space> </Space>
), ),
@@ -205,91 +195,70 @@ export default function Roles() {
]; ];
return ( return (
<div className="space-y-4"> <div style={{ padding: '20px' }}>
<div className="flex justify-between items-center"> {contextHolder}
<Title level={5} style={{ margin: 0 }}>菜单权限管理</Title> <Card title="菜单权限管理" style={{ borderRadius: 8 }}>
<div style={{ marginBottom: 16, display: 'flex', justifyContent: 'space-between' }}>
<Space> <Space>
<Select <Select placeholder="选择角色" style={{ width: 180 }} value={selectedRole} onChange={setSelectedRole}>
placeholder="选择角色" {roleList.map(r => <Option key={r.key} value={r.key}>{r.name}</Option>)}
style={{ width: 180 }}
value={selectedRole}
onChange={setSelectedRole}
>
{roleList.map(r => (
<Option key={r.key} value={r.key}>{r.name}</Option>
))}
</Select> </Select>
<Button <Button type="primary" icon={<SettingOutlined />} onClick={handlePermOpen}>配置权限</Button>
type="primary" </Space>
icon={<SettingOutlined />} <Button type="primary" icon={<PlusOutlined />} onClick={() => {
onClick={handlePermOpen}
>
配置权限
</Button>
<Button
type="primary"
icon={<PlusOutlined />}
onClick={() => {
setEditMenu(null); setEditMenu(null);
menuForm.resetFields(); menuForm.resetFields();
setMenuModal(true); setMenuModal(true);
}} }}>新增菜单</Button>
>
新增菜单
</Button>
</Space>
</div> </div>
{/* 关键:rowKey + treeData + indentSize 开启树形表格 */}
<Table <Table
columns={columns} columns={columns}
dataSource={menus} dataSource={menuTreeData}
rowKey="id" rowKey="menuId"
pagination={false} pagination={false}
variant bordered
size="middle"
indentSize={24}
/> />
{/* 菜单 新增/编辑 弹窗 */} {/* 新增/编辑弹窗 */}
<Modal <Modal
title={editMenu ? '编辑菜单' : '新增菜单'} title={editMenu ? '编辑菜单' : '新增菜单'}
open={menuModal} open={menuModal}
width={600}
onCancel={() => setMenuModal(false)} onCancel={() => setMenuModal(false)}
onOk={handleSaveMenu} onOk={handleSaveMenu}
width={500} destroyOnClose
> >
<Form form={menuForm} layout="vertical"> <Form form={menuForm} layout="vertical">
<Form.Item name="menuType" label="菜单类型" rules={[{ required: true }]}> <Form.Item label="上级菜单" name="parentId">
<Select placeholder="请选择菜单类型"> <Select placeholder="无(一级菜单)">
<Option value="top">一级菜单</Option> <Option value={0}>无(一级菜单)</Option>
<Option value="sub">二级菜单</Option>
</Select>
</Form.Item>
{/* 二级菜单才显示父级选择 */}
{menuType === 'sub' && (
<Form.Item name="parentId" label="上级菜单" rules={[{ required: true }]}>
<Select placeholder="请选择上级菜单">
{topMenus.map(m => ( {topMenus.map(m => (
<Option key={m.id} value={m.id}>{m.title}</Option> <Option key={m.menuId} value={m.menuId}>{m.menuName}</Option>
))} ))}
</Select> </Select>
</Form.Item> </Form.Item>
)}
<Form.Item name="title" label="菜单名称" rules={[{ required: true }]}> <Form.Item label="菜单名称" name="menuName" rules={[{ required: true }]}>
<Input placeholder="请输入菜单名称" /> <Input placeholder="请输入菜单名称" />
</Form.Item> </Form.Item>
<Form.Item name="path" label="路由地址" rules={[{ required: true }]}>
<Input placeholder="/system/xxx" /> <Form.Item label="路由地址" name="path">
<Input placeholder="/system/menu" />
</Form.Item> </Form.Item>
<Form.Item name="sort" label="排序号">
<Input type="number" placeholder="数字越小越靠前" /> <Form.Item label="显示排序" name="orderNum">
<InputNumber min={0} style={{ width: '100%' }} placeholder="数字越小越靠前" />
</Form.Item> </Form.Item>
</Form> </Form>
</Modal> </Modal>
{/* 权限配置弹窗 */} {/* 权限树弹窗 */}
<Modal <Modal
title={`【${selectedRole}】菜单权限配置`} title={`【${selectedRole}】权限配置`}
open={permModal} open={permModal}
width={520} width={520}
onCancel={() => setPermModal(false)} onCancel={() => setPermModal(false)}
@@ -301,9 +270,9 @@ export default function Roles() {
checkedKeys={checkedKeys} checkedKeys={checkedKeys}
onCheck={setCheckedKeys} onCheck={setCheckedKeys}
defaultExpandAll defaultExpandAll
fieldNames={{ title: 'title', key: 'id', children: 'children' }}
/> />
</Modal> </Modal>
</Card>
</div> </div>
); );
} }

View File

@@ -1,13 +1,14 @@
import React, { useState, useEffect } from 'react'; import React, { useState } from 'react';
import { import {
Card, Row, Col, Button, Typography, Space, Modal, Form, Tree, message, Card, Row, Col, Button, Typography, Space, Modal, Form, Tree, message,
Input, Popconfirm, Divider Input, Popconfirm, Divider
} from 'antd'; } from 'antd';
import { import {
PlusOutlined, LockOutlined, SettingOutlined, EditOutlined, DeleteOutlined PlusOutlined, SettingOutlined, EditOutlined, DeleteOutlined, CloseOutlined
} from '@ant-design/icons'; } from '@ant-design/icons';
const { Text, Title } = Typography; const { Text } = Typography;
const AntdCard = Card as any;
// 默认角色 // 默认角色
const defaultRoles = [ const defaultRoles = [
@@ -46,7 +47,7 @@ export default function Roles() {
const [editRole, setEditRole] = useState(null); const [editRole, setEditRole] = useState(null);
// 打开权限配置 // 打开权限配置
const handleOpenPerm = async (role) => { const handleOpenPerm = (role) => {
setCurrentRole(role); setCurrentRole(role);
setCheckedKeys([]); setCheckedKeys([]);
setPermVisible(true); setPermVisible(true);
@@ -54,7 +55,7 @@ export default function Roles() {
// 保存权限 // 保存权限
const handleSavePerm = () => { const handleSavePerm = () => {
message.success(`【${currentRole.name}】菜单权限配置成功!`); message.success(`【${currentRole?.name}】菜单权限配置成功!`);
setPermVisible(false); setPermVisible(false);
}; };
@@ -85,16 +86,14 @@ export default function Roles() {
roleForm.validateFields().then(values => { roleForm.validateFields().then(values => {
const roleData = { const roleData = {
...values, ...values,
menuKeys: checkedKeys, // 保存菜单权限 menuKeys: checkedKeys,
level: editRole ? editRole.level : 'Level Custom' level: editRole ? editRole.level : 'Level Custom'
}; };
if (editRole) { if (editRole) {
// 编辑
setRoles(roles.map(r => r.key === editRole.key ? { ...r, ...roleData } : r)); setRoles(roles.map(r => r.key === editRole.key ? { ...r, ...roleData } : r));
message.success('编辑成功'); message.success('编辑成功');
} else { } else {
// 新增
const newRole = { const newRole = {
...roleData, ...roleData,
key: values.key || Date.now().toString(), key: values.key || Date.now().toString(),
@@ -107,52 +106,76 @@ export default function Roles() {
}; };
return ( return (
<div className="space-y-4"> <div style={{ padding: '16px', background: '#f4f7f9', minHeight: '100%' }}>
<div className="flex justify-between items-center"> {/* 标题 */}
<Title level={5} style={{ margin: 0 }}>角色管理</Title> <div style={{ fontSize: 16, fontWeight: 600, marginBottom: 16 }}>角色管理</div>
<Button type="primary" icon={<PlusOutlined />} onClick={handleAddRole}>
{/* 顶部操作栏 */}
<AntdCard size="small" style={{ borderRadius: 8, marginBottom: 16 }}>
<div style={{ display: 'flex', justifyContent: 'flex-end' }}>
<Button
type="primary"
icon={<PlusOutlined />}
onClick={handleAddRole}
style={{ borderRadius: 2 }}
>
新增角色 新增角色
</Button> </Button>
</div> </div>
</AntdCard>
<Row gutter={16}> {/* 角色卡片列表 */}
<Row gutter={[16, 16]}>
{roles.map(role => ( {roles.map(role => (
<Col span={8} key={role.key}> <Col xs={24} sm={12} md={8} lg={6} key={role.key}>
<Card <AntdCard
size="small"
hoverable hoverable
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}
actions={[ actions={[
<Button <Button
type="link" type="text"
icon={<SettingOutlined />} icon={<SettingOutlined />}
onClick={() => handleOpenPerm(role)} onClick={() => handleOpenPerm(role)}
style={{ fontSize: 12 }}
> >
菜单权限 菜单权限
</Button>, </Button>,
<Button <Button
type="link" type="text"
icon={<EditOutlined />} icon={<EditOutlined />}
onClick={() => handleEditRole(role)} onClick={() => handleEditRole(role)}
style={{ fontSize: 12 }}
> >
编辑 编辑
</Button>, </Button>,
<Popconfirm <Popconfirm
title="确定删除该角色?" title="确定删除该角色?"
onConfirm={() => handleDeleteRole(role.key)} onConfirm={() => handleDeleteRole(role.key)}
okText="确定"
cancelText="取消"
> >
<Button type="link" danger icon={<DeleteOutlined />}>删除</Button> <Button
type="text"
danger
icon={<DeleteOutlined />}
style={{ fontSize: 12 }}
>
删除
</Button>
</Popconfirm> </Popconfirm>
]} ]}
> >
<Card.Meta <Card.Meta
title={role.name} title={<span style={{ fontWeight: 600, fontSize: 14 }}>{role.name}</span>}
description={ description={
<Space direction="vertical" size={2}> <Space direction="vertical" size={2} style={{ width: '100%' }}>
<Text type="secondary" style={{ fontSize: 10 }}>{role.level}</Text> <Text type="secondary" style={{ fontSize: 11 }}>{role.level}</Text>
<Text type="secondary" style={{ fontSize: 12 }}>{role.desc}</Text> <Text type="secondary" style={{ fontSize: 12, lineHeight: 1.4 }}>{role.desc}</Text>
</Space> </Space>
} }
/> />
</Card> </AntdCard>
</Col> </Col>
))} ))}
</Row> </Row>
@@ -164,6 +187,7 @@ export default function Roles() {
width={520} width={520}
onCancel={() => setPermVisible(false)} onCancel={() => setPermVisible(false)}
onOk={handleSavePerm} onOk={handleSavePerm}
closeIcon={<CloseOutlined />}
> >
<Tree <Tree
checkable checkable
@@ -174,7 +198,7 @@ export default function Roles() {
/> />
</Modal> </Modal>
{/* ========== 新增/编辑角色弹窗(带菜单选择) ========== */} {/* ========== 新增/编辑角色弹窗 ========== */}
<Modal <Modal
title={editRole ? '编辑角色' : '新增角色'} title={editRole ? '编辑角色' : '新增角色'}
open={roleModalVisible} open={roleModalVisible}
@@ -182,6 +206,7 @@ export default function Roles() {
onOk={handleSaveRole} onOk={handleSaveRole}
maskClosable={false} maskClosable={false}
width={550} width={550}
closeIcon={<CloseOutlined />}
> >
<Form form={roleForm} layout="vertical"> <Form form={roleForm} layout="vertical">
<Form.Item <Form.Item
@@ -189,7 +214,7 @@ export default function Roles() {
label="角色名称" label="角色名称"
rules={[{ required: true, message: '请输入角色名称' }]} rules={[{ required: true, message: '请输入角色名称' }]}
> >
<Input placeholder="例如:运维管理员" /> <Input placeholder="例如:运维管理员" style={{ borderRadius: 2 }} />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
@@ -197,15 +222,14 @@ export default function Roles() {
label="角色标识" label="角色标识"
rules={[{ required: true, message: '请输入角色标识' }]} rules={[{ required: true, message: '请输入角色标识' }]}
> >
<Input placeholder="例如:operation" /> <Input placeholder="例如:operation" style={{ borderRadius: 2 }} />
</Form.Item> </Form.Item>
<Form.Item name="desc" label="角色描述"> <Form.Item name="desc" label="角色描述">
<Input.TextArea rows={3} placeholder="描述该角色的权限范围" /> <Input.TextArea rows={3} placeholder="描述该角色的权限范围" style={{ borderRadius: 2 }} />
</Form.Item> </Form.Item>
{/* ========== 新增角色时直接选择菜单权限 ========== */} <Divider orientation="left" style={{ margin: '16px 0' }}>菜单权限配置</Divider>
<Divider orientation="left">菜单权限配置</Divider>
<Tree <Tree
checkable checkable
treeData={menuTree} treeData={menuTree}