2026-04-29 14:26:01 +08:00
|
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
|
|
import {
|
|
|
|
|
|
Layout, Tabs, Card, Row, Col, Button, Typography, Space, Modal, Form, Tree, message,
|
|
|
|
|
|
Input, Popconfirm, Divider, InputNumber, Switch, Pagination, Table, Select,
|
2026-04-29 15:31:51 +08:00
|
|
|
|
Tag, Checkbox, App
|
2026-04-29 14:26:01 +08:00
|
|
|
|
} from 'antd';
|
|
|
|
|
|
import {
|
|
|
|
|
|
PlusOutlined, EditOutlined, DeleteOutlined, UserOutlined
|
|
|
|
|
|
} from '@ant-design/icons';
|
|
|
|
|
|
import { getMenuList } from '../api/mune';
|
|
|
|
|
|
import { buildPermTree, buildTreeFromFlat } from '../lib/utils';
|
|
|
|
|
|
import { addRole, deleteRole, editRoleApi, getRoleList } from '../api/role';
|
|
|
|
|
|
import { addUser, deleteUser, editUser, getUser } from '../api/user';
|
|
|
|
|
|
import EmptyData from '../components/Empty';
|
|
|
|
|
|
|
|
|
|
|
|
const { Text } = Typography;
|
|
|
|
|
|
const { TabPane } = Tabs;
|
|
|
|
|
|
const AntdCard = Card as any;
|
|
|
|
|
|
|
|
|
|
|
|
export default function UserRolePage() {
|
|
|
|
|
|
// ====================== 角色管理状态 ======================
|
2026-04-29 15:31:51 +08:00
|
|
|
|
const [messageApi, contextHolder] = message.useMessage();
|
|
|
|
|
|
const { modal } = App.useApp();
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-29 14:26:01 +08:00
|
|
|
|
const [roles, setRoles] = useState([]);
|
|
|
|
|
|
const [menuTree, setMenuTree] = useState([]);
|
|
|
|
|
|
const [checkedKeys, setCheckedKeys] = useState<number[]>([]);
|
|
|
|
|
|
const [roleModalVisible, setRoleModalVisible] = useState(false);
|
|
|
|
|
|
const [roleForm] = Form.useForm();
|
|
|
|
|
|
const [editRole, setEditRole] = useState(null);
|
2026-04-29 15:31:51 +08:00
|
|
|
|
const [selectedRoleIds, setSelectedRoleIds] = useState<number[]>([]);
|
2026-04-29 14:26:01 +08:00
|
|
|
|
|
|
|
|
|
|
// ====================== 用户管理状态 ======================
|
|
|
|
|
|
const [userList, setUserList] = useState([]);
|
|
|
|
|
|
const [modalVisible, setModalVisible] = useState(false);
|
|
|
|
|
|
const [form] = Form.useForm();
|
|
|
|
|
|
const [currentUser, setCurrentUser] = useState(null);
|
|
|
|
|
|
const [rolesOption, setRolesOption] = useState([]);
|
2026-04-29 15:31:51 +08:00
|
|
|
|
const [selectedUserIds, setSelectedUserIds] = useState<number[]>([]);
|
2026-04-29 14:26:01 +08:00
|
|
|
|
|
|
|
|
|
|
// ====================== 统一分页 ======================
|
|
|
|
|
|
const [rolePagination, setRolePagination] = useState({
|
|
|
|
|
|
pageNum: 1, pageSize: 12, total: 0
|
|
|
|
|
|
});
|
|
|
|
|
|
const [userPagination, setUserPagination] = useState({
|
|
|
|
|
|
pageNum: 1, pageSize: 10, total: 0
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// ====================== 获取角色列表 ======================
|
|
|
|
|
|
const getRoleData = () => {
|
|
|
|
|
|
const params = {
|
|
|
|
|
|
pageNum: rolePagination.pageNum,
|
|
|
|
|
|
pageSize: rolePagination.pageSize
|
|
|
|
|
|
};
|
|
|
|
|
|
getRoleList(params).then(res => {
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
setRoles(res.data || []);
|
|
|
|
|
|
setRolePagination({
|
|
|
|
|
|
...rolePagination,
|
|
|
|
|
|
total: res.total || res.data?.length || 0
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// ====================== 获取菜单树 ======================
|
|
|
|
|
|
const getMenuData = () => {
|
|
|
|
|
|
getMenuList({ pageNum: 1, pageSize: 1000 }).then(res => {
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
const treeData = buildTreeFromFlat(res.data || []);
|
|
|
|
|
|
setMenuTree(buildPermTree(treeData));
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// ====================== 获取用户列表 ======================
|
|
|
|
|
|
const getUserData = () => {
|
|
|
|
|
|
const params = {
|
|
|
|
|
|
pageNum: userPagination.pageNum,
|
|
|
|
|
|
pageSize: userPagination.pageSize
|
|
|
|
|
|
};
|
|
|
|
|
|
getUser(params).then(res => {
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
setUserList(res.rows || []);
|
|
|
|
|
|
setUserPagination({
|
|
|
|
|
|
...userPagination,
|
|
|
|
|
|
total: res.total || res.rows?.length || 0
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// ====================== 获取角色下拉框 ======================
|
|
|
|
|
|
const getRoleForSelect = () => {
|
|
|
|
|
|
getRoleList({ pageNum: 1, pageSize: 1000 }).then(res => {
|
|
|
|
|
|
if (res.code === 200) setRolesOption(res.data || []);
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// ====================== 加载数据 ======================
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
getRoleData();
|
|
|
|
|
|
getMenuData();
|
|
|
|
|
|
}, [rolePagination.pageNum, rolePagination.pageSize]);
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
getUserData();
|
|
|
|
|
|
getRoleForSelect();
|
|
|
|
|
|
}, [userPagination.pageNum, userPagination.pageSize]);
|
|
|
|
|
|
|
|
|
|
|
|
// ====================== 角色操作 ======================
|
|
|
|
|
|
const handleAddRole = () => {
|
|
|
|
|
|
roleForm.resetFields();
|
|
|
|
|
|
setCheckedKeys([]);
|
|
|
|
|
|
setEditRole(null);
|
|
|
|
|
|
roleForm.setFieldsValue({ status: true, roleSort: 1 });
|
|
|
|
|
|
setRoleModalVisible(true);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleEditRole = (record) => {
|
|
|
|
|
|
setEditRole(record);
|
|
|
|
|
|
roleForm.setFieldsValue({ ...record, status: record.status == 1 });
|
|
|
|
|
|
setCheckedKeys((record.menuIds || []).map(Number));
|
|
|
|
|
|
setRoleModalVisible(true);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleDeleteRole = (roleId) => {
|
|
|
|
|
|
deleteRole([roleId]).then(res => {
|
2026-04-29 15:31:51 +08:00
|
|
|
|
if (res.code === 200) { messageApi.success('删除成功'); getRoleData(); }
|
|
|
|
|
|
else messageApi.error(res.msg || '删除失败');
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 批量删除角色 + 确认弹窗
|
|
|
|
|
|
const handleBatchDeleteRoles = () => {
|
|
|
|
|
|
if (selectedRoleIds.length == 0) return messageApi.warning('请选择要删除的角色');
|
|
|
|
|
|
modal.confirm({
|
|
|
|
|
|
title: '批量删除角色',
|
|
|
|
|
|
content: `确定要删除已选中的 ${selectedRoleIds.length} 个角色吗?`,
|
|
|
|
|
|
okText: '确定删除',
|
|
|
|
|
|
cancelText: '取消',
|
|
|
|
|
|
okType: 'danger',
|
|
|
|
|
|
onOk: () => {
|
|
|
|
|
|
deleteRole(selectedRoleIds).then(res => {
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
messageApi.success('批量删除成功');
|
|
|
|
|
|
setSelectedRoleIds([]);
|
|
|
|
|
|
getRoleData();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
messageApi.error(res.msg || '删除失败');
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2026-04-29 14:26:01 +08:00
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleSaveRole = () => {
|
|
|
|
|
|
roleForm.validateFields().then(values => {
|
|
|
|
|
|
const params = {
|
|
|
|
|
|
...values,
|
|
|
|
|
|
menuIds: checkedKeys,
|
|
|
|
|
|
status: values.status ? 1 : 0,
|
|
|
|
|
|
roleSort: values.roleSort || 1,
|
|
|
|
|
|
};
|
|
|
|
|
|
if (editRole) params.roleId = editRole.roleId;
|
|
|
|
|
|
|
|
|
|
|
|
const api = editRole ? editRoleApi : addRole;
|
|
|
|
|
|
api(params).then(res => {
|
|
|
|
|
|
if (res.code === 200) {
|
2026-04-29 15:31:51 +08:00
|
|
|
|
messageApi.success(editRole ? '编辑成功' : '新增成功');
|
2026-04-29 14:26:01 +08:00
|
|
|
|
setRoleModalVisible(false);
|
|
|
|
|
|
getRoleData();
|
|
|
|
|
|
getRoleForSelect();
|
2026-04-29 15:31:51 +08:00
|
|
|
|
} else messageApi.error(res.msg || '保存失败');
|
2026-04-29 14:26:01 +08:00
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// ====================== 用户操作 ======================
|
|
|
|
|
|
const handleAddUser = () => {
|
|
|
|
|
|
form.resetFields();
|
|
|
|
|
|
setCurrentUser(null);
|
|
|
|
|
|
setModalVisible(true);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleEditUser = (record) => {
|
|
|
|
|
|
setCurrentUser(record);
|
|
|
|
|
|
form.setFieldsValue({ ...record, roleIds: record.roles?.map(i => i.roleId) || [] });
|
|
|
|
|
|
setModalVisible(true);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleDeleteUser = (userId) => {
|
|
|
|
|
|
deleteUser(userId).then(res => {
|
2026-04-29 15:31:51 +08:00
|
|
|
|
if (res.code === 200) { messageApi.success('删除成功'); getUserData(); }
|
|
|
|
|
|
else messageApi.error(res.msg || '删除失败');
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 批量删除用户 + 确认弹窗
|
|
|
|
|
|
const handleBatchDeleteUsers = () => {
|
|
|
|
|
|
|
|
|
|
|
|
if (selectedUserIds.length === 0) return messageApi.warning('请选择要删除的用户');
|
|
|
|
|
|
console.log(selectedUserIds, "selectedUserIds")
|
|
|
|
|
|
modal.confirm({
|
|
|
|
|
|
title: '批量删除用户',
|
|
|
|
|
|
content: `确定要删除已选中的 ${selectedUserIds.length} 个用户吗?`,
|
|
|
|
|
|
okText: '确定删除',
|
|
|
|
|
|
cancelText: '取消',
|
|
|
|
|
|
okType: 'danger',
|
|
|
|
|
|
onOk: () => {
|
|
|
|
|
|
Promise.all(selectedUserIds.map(id => deleteUser(id))).then(() => {
|
|
|
|
|
|
messageApi.success('批量删除成功');
|
|
|
|
|
|
setSelectedUserIds([]);
|
|
|
|
|
|
getUserData();
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2026-04-29 14:26:01 +08:00
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleSaveUser = () => {
|
|
|
|
|
|
form.validateFields().then(values => {
|
|
|
|
|
|
const params = { ...values, roleIds: values.roleIds || [] };
|
|
|
|
|
|
if (currentUser) params.userId = currentUser.userId;
|
|
|
|
|
|
|
|
|
|
|
|
const api = currentUser ? editUser : addUser;
|
|
|
|
|
|
api(params).then(res => {
|
|
|
|
|
|
if (res.code === 200) {
|
2026-04-29 15:31:51 +08:00
|
|
|
|
messageApi.success(currentUser ? '编辑成功' : '新增成功');
|
2026-04-29 14:26:01 +08:00
|
|
|
|
setModalVisible(false);
|
|
|
|
|
|
getUserData();
|
2026-04-29 15:31:51 +08:00
|
|
|
|
} else messageApi.error(res.msg || '保存失败');
|
2026-04-29 14:26:01 +08:00
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// ====================== 页面主体 ======================
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div style={{
|
|
|
|
|
|
height: '100%',
|
|
|
|
|
|
maxHeight: 'calc(100vh - 64px)',
|
|
|
|
|
|
overflowY: 'auto',
|
|
|
|
|
|
scrollbarWidth: 'none',
|
|
|
|
|
|
msOverflowStyle: 'none',
|
|
|
|
|
|
padding: '20px',
|
|
|
|
|
|
background: '#f5f7fa'
|
|
|
|
|
|
}}>
|
2026-04-29 15:31:51 +08:00
|
|
|
|
{contextHolder}
|
2026-04-29 14:26:01 +08:00
|
|
|
|
|
|
|
|
|
|
{/* 整体卡片 */}
|
2026-04-29 15:31:51 +08:00
|
|
|
|
<AntdCard style={{ borderRadius: 12, boxShadow: '0 2px 10px rgba(0,0,0,0.06)' }}>
|
2026-04-29 14:26:01 +08:00
|
|
|
|
<Tabs defaultActiveKey="user" type="card" size="large" style={{ marginBottom: 20 }}>
|
|
|
|
|
|
|
|
|
|
|
|
{/* ========== 用户管理 ========== */}
|
|
|
|
|
|
<TabPane tab="用户管理" key="user">
|
|
|
|
|
|
<div style={{ marginBottom: 16, display: 'flex', justifyContent: 'space-between' }}>
|
2026-04-29 15:31:51 +08:00
|
|
|
|
{selectedUserIds.length > 0 && (
|
|
|
|
|
|
<Button danger onClick={handleBatchDeleteUsers}>
|
|
|
|
|
|
批量删除(已选 {selectedUserIds.length} 项)
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
)}
|
2026-04-29 14:26:01 +08:00
|
|
|
|
<Button type="primary" icon={<PlusOutlined />} onClick={handleAddUser}>新增用户</Button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<Table
|
|
|
|
|
|
rowKey="userId"
|
2026-04-29 15:31:51 +08:00
|
|
|
|
rowSelection={{
|
|
|
|
|
|
type: 'checkbox',
|
|
|
|
|
|
onChange: (selectedRowKeys) => setSelectedUserIds(selectedRowKeys)
|
|
|
|
|
|
}}
|
2026-04-29 14:26:01 +08:00
|
|
|
|
columns={[
|
|
|
|
|
|
{ title: '用户账号', dataIndex: 'userName' },
|
|
|
|
|
|
{ title: '用户昵称', dataIndex: 'nickName' },
|
|
|
|
|
|
{ title: '手机号', dataIndex: 'phonenumber' },
|
|
|
|
|
|
{ title: '邮箱', dataIndex: 'email' },
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '角色', render: (_, r) => (r.roles || []).map(i => (
|
|
|
|
|
|
<Tag color="blue" key={i.roleId}>{i.roleName || i.roleKey}</Tag>
|
|
|
|
|
|
))
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2026-04-29 15:31:51 +08:00
|
|
|
|
title: '状态', render: (_, s) => s.status == '0' ?
|
2026-04-29 14:26:01 +08:00
|
|
|
|
<Tag color="green">正常</Tag> : <Tag color="red">停用</Tag>
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '操作', render: (_, r) => (
|
|
|
|
|
|
<Space>
|
|
|
|
|
|
<Button type="text" icon={<EditOutlined />} onClick={() => handleEditUser(r)}>编辑</Button>
|
|
|
|
|
|
<Popconfirm onConfirm={() => handleDeleteUser(r.userId)} title="确定删除?">
|
|
|
|
|
|
<Button type="text" danger>删除</Button>
|
|
|
|
|
|
</Popconfirm>
|
|
|
|
|
|
</Space>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
]}
|
|
|
|
|
|
dataSource={userList}
|
|
|
|
|
|
pagination={{
|
|
|
|
|
|
current: userPagination.pageNum,
|
|
|
|
|
|
pageSize: userPagination.pageSize,
|
|
|
|
|
|
total: userPagination.total,
|
|
|
|
|
|
showSizeChanger: true,
|
|
|
|
|
|
showTotal: t => `共 ${t} 条`
|
|
|
|
|
|
}}
|
|
|
|
|
|
onChange={(p) => setUserPagination({ ...userPagination, pageNum: p.current, pageSize: p.pageSize })}
|
|
|
|
|
|
bordered
|
|
|
|
|
|
size="middle"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</TabPane>
|
|
|
|
|
|
|
|
|
|
|
|
{/* ========== 角色管理 ========== */}
|
|
|
|
|
|
<TabPane tab="角色管理" key="role">
|
|
|
|
|
|
<div style={{ marginBottom: 16, display: 'flex', justifyContent: 'space-between' }}>
|
2026-04-29 15:31:51 +08:00
|
|
|
|
{selectedRoleIds.length > 0 && (
|
|
|
|
|
|
<Button danger onClick={handleBatchDeleteRoles}>
|
|
|
|
|
|
批量删除(已选 {selectedRoleIds.length} 项)
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
)}
|
2026-04-29 14:26:01 +08:00
|
|
|
|
<Button type="primary" icon={<PlusOutlined />} onClick={handleAddRole}>新增角色</Button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<Row gutter={[16, 16]}>
|
|
|
|
|
|
{roles.length > 0 ? roles.map(r => (
|
|
|
|
|
|
<Col xs={24} sm={12} md={8} lg={6} key={r.roleId}>
|
2026-04-29 15:31:51 +08:00
|
|
|
|
<AntdCard
|
|
|
|
|
|
hoverable
|
|
|
|
|
|
style={{ borderRadius: 10, position: 'relative' }}
|
2026-04-29 14:26:01 +08:00
|
|
|
|
actions={[
|
|
|
|
|
|
<Button type="text" icon={<EditOutlined />} onClick={() => handleEditRole(r)}>编辑</Button>,
|
|
|
|
|
|
<Popconfirm onConfirm={() => handleDeleteRole(r.roleId)} title="确定删除?">
|
|
|
|
|
|
<Button type="text" danger>删除</Button>
|
|
|
|
|
|
</Popconfirm>
|
|
|
|
|
|
]}
|
|
|
|
|
|
>
|
2026-04-29 15:31:51 +08:00
|
|
|
|
<div style={{ position: 'absolute', top: 10, right: 10 }}>
|
|
|
|
|
|
<Checkbox
|
|
|
|
|
|
checked={selectedRoleIds.includes(r.roleId)}
|
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
|
if (e.target.checked) {
|
|
|
|
|
|
setSelectedRoleIds([...selectedRoleIds, r.roleId]);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
setSelectedRoleIds(selectedRoleIds.filter(id => id !== r.roleId));
|
|
|
|
|
|
}
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2026-04-29 14:26:01 +08:00
|
|
|
|
<Card.Meta
|
|
|
|
|
|
title={<strong>{r.roleName}</strong>}
|
|
|
|
|
|
description={
|
|
|
|
|
|
<Space direction="vertical" size={2}>
|
|
|
|
|
|
<Text type="secondary">权限:{r.roleKey}</Text>
|
|
|
|
|
|
<Text type="secondary">状态:{r.status == 1 ? '正常' : '停用'}</Text>
|
|
|
|
|
|
{r.admin && <Tag color="red">超级管理员</Tag>}
|
|
|
|
|
|
</Space>
|
|
|
|
|
|
}
|
|
|
|
|
|
/>
|
2026-04-29 15:31:51 +08:00
|
|
|
|
</AntdCard>
|
2026-04-29 14:26:01 +08:00
|
|
|
|
</Col>
|
|
|
|
|
|
)) : <EmptyData height={260} />}
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
|
|
|
|
<div style={{ textAlign: 'right', marginTop: 20 }}>
|
|
|
|
|
|
<Pagination
|
|
|
|
|
|
current={rolePagination.pageNum}
|
|
|
|
|
|
pageSize={rolePagination.pageSize}
|
|
|
|
|
|
total={rolePagination.total}
|
|
|
|
|
|
showSizeChanger
|
|
|
|
|
|
showTotal={(t) => `共 ${t} 条`}
|
|
|
|
|
|
onChange={(p, s) => setRolePagination({ pageNum: p, pageSize: s, total: rolePagination.total })}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</TabPane>
|
|
|
|
|
|
</Tabs>
|
2026-04-29 15:31:51 +08:00
|
|
|
|
</AntdCard>
|
2026-04-29 14:26:01 +08:00
|
|
|
|
|
|
|
|
|
|
{/* ========== 角色弹窗 ========== */}
|
|
|
|
|
|
<Modal title={editRole ? '编辑角色' : '新增角色'} open={roleModalVisible}
|
|
|
|
|
|
onCancel={() => setRoleModalVisible(false)} onOk={handleSaveRole} width={560}>
|
|
|
|
|
|
<Form form={roleForm} layout="vertical">
|
|
|
|
|
|
<Form.Item name="roleName" label="角色名称" rules={[{ required: true }]}><Input /></Form.Item>
|
|
|
|
|
|
<Form.Item name="roleKey" label="权限标识" rules={[{ required: true }]}><Input /></Form.Item>
|
|
|
|
|
|
<Form.Item name="roleSort" label="排序"><InputNumber style={{ width: '100%' }} /></Form.Item>
|
|
|
|
|
|
<Form.Item name="status" label="状态" valuePropName="checked"><Switch checkedChildren="正常" unCheckedChildren="停用" /></Form.Item>
|
|
|
|
|
|
<Divider>菜单权限</Divider>
|
|
|
|
|
|
<Tree checkable treeData={menuTree} checkedKeys={checkedKeys} onCheck={setCheckedKeys} defaultExpandAll />
|
|
|
|
|
|
</Form>
|
|
|
|
|
|
</Modal>
|
|
|
|
|
|
|
|
|
|
|
|
{/* ========== 用户弹窗 ========== */}
|
|
|
|
|
|
<Modal title={currentUser ? '编辑用户' : '新增用户'} open={modalVisible}
|
|
|
|
|
|
onCancel={() => setModalVisible(false)} onOk={handleSaveUser} width={680} destroyOnClose>
|
|
|
|
|
|
<Form form={form} layout="vertical">
|
|
|
|
|
|
<Row gutter={16}>
|
|
|
|
|
|
<Col span={12}><Form.Item name="userName" label="账号" rules={[{ required: true }]}><Input /></Form.Item></Col>
|
|
|
|
|
|
<Col span={12}><Form.Item name="nickName" label="昵称" rules={[{ required: true }]}><Input /></Form.Item></Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
<Row gutter={16}>
|
|
|
|
|
|
<Col span={12}><Form.Item name="phonenumber" label="手机"><Input /></Form.Item></Col>
|
|
|
|
|
|
<Col span={12}><Form.Item name="email" label="邮箱"><Input /></Form.Item></Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
<Row gutter={16}>
|
|
|
|
|
|
<Col span={12}><Form.Item name="password" label="密码"><Input.Password placeholder="不填不修改" /></Form.Item></Col>
|
|
|
|
|
|
<Col span={12}><Form.Item name="language" label="语言"><Select><Select.Option value="zh-CN">中文</Select.Option><Select.Option value="en">英语</Select.Option></Select></Form.Item></Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
<Row gutter={16}>
|
2026-04-29 15:31:51 +08:00
|
|
|
|
<Col span={12}><Form.Item name="roleIds" label="分配角色" rules={[{ required: true }]}><Select mode="multiple" placeholder="选择角色">{rolesOption.map(i => <Select.Option key={i.roleId} value={i.roleId}>{i.roleName}</Select.Option>)}</Select></Form.Item></Col>
|
2026-04-29 14:26:01 +08:00
|
|
|
|
<Col span={12}><Form.Item name="status" label="状态" initialValue="0"><Select><Select.Option value="0">正常</Select.Option><Select.Option value="1">停用</Select.Option></Select></Form.Item></Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
<Form.Item name="siteId" label="场站ID"><Input /></Form.Item>
|
|
|
|
|
|
<Form.Item name="sex" label="性别" initialValue="2"><Select><Select.Option value="0">男</Select.Option><Select.Option value="1">女</Select.Option><Select.Option value="2">未知</Select.Option></Select></Form.Item>
|
|
|
|
|
|
</Form>
|
|
|
|
|
|
</Modal>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|