权限基本完善
This commit is contained in:
7
env.js
7
env.js
@@ -9,13 +9,14 @@ const currentEnv = import.meta.env?.MODE || process.env.NODE_ENV;
|
||||
// 环境配置映射
|
||||
const envConfig = {
|
||||
[ENV.DEV]: {
|
||||
baseURL: 'http://192.168.2.59:8081',//http://192.168.2.56:8081
|
||||
//baseURL: 'http://1.95.137.212:59015',//http://192.168.2.56:8081
|
||||
//baseURL: 'http://192.168.2.59:8081',//http://192.168.2.56:8081
|
||||
baseURL: 'http://1.95.137.212:59015',//http://192.168.2.56:8081
|
||||
WS_URL: 'ws://192.168.2.56:9002/ws/',
|
||||
},
|
||||
[ENV.PROD]: {
|
||||
// baseURL: 'http://192.168.2.56:8081',
|
||||
baseURL: 'https://serviceri.satabot.com',
|
||||
baseURL: 'http://1.95.137.212:59015',//http://192.168.2.56:8081
|
||||
//baseURL: 'https://serviceri.satabot.com',
|
||||
WS_URL: 'wss://ri.satabot.com/ws/'
|
||||
},
|
||||
};
|
||||
|
||||
@@ -50,7 +50,6 @@ export default function StationManage() {
|
||||
|
||||
// ====================== 获取组织列表(根据 userId 过滤) ======================
|
||||
const getOrgData = () => {
|
||||
console.log(userInfo, "userInfo")
|
||||
const params = {
|
||||
pageNum: 1,
|
||||
pageSize: 9999,
|
||||
@@ -65,13 +64,11 @@ export default function StationManage() {
|
||||
|
||||
// ====================== 获取场站列表(分页) ======================
|
||||
const getStationData = () => {
|
||||
|
||||
const params = {
|
||||
pageNum: pagination.pageNum,
|
||||
pageSize: pagination.pageSize,
|
||||
orgId: userInfo?.orgId, // 根据用户所属组织过滤场站
|
||||
orgId: userInfo?.orgId,
|
||||
};
|
||||
|
||||
getStationList(params).then(res => {
|
||||
if (res.code === 200) {
|
||||
setStationList(res.rows || []);
|
||||
@@ -95,7 +92,7 @@ export default function StationManage() {
|
||||
// 初始化加载
|
||||
useEffect(() => {
|
||||
getStationData();
|
||||
getOrgData(); // 进入页面就加载组织
|
||||
getOrgData();
|
||||
}, [pagination.pageNum, pagination.pageSize]);
|
||||
|
||||
// ====================== 新增 / 编辑 场站 ======================
|
||||
@@ -234,10 +231,8 @@ export default function StationManage() {
|
||||
<div style={{ padding: '20px' }}>
|
||||
{contextHolder}
|
||||
|
||||
{/* 统一卡片样式 */}
|
||||
<Card title="场站管理" style={{ borderRadius: 8 }}>
|
||||
<div style={{ marginBottom: 16, display: 'flex', justifyContent: 'space-between' }}>
|
||||
<div></div>
|
||||
<Button type="primary" icon={<PlusOutlined />} onClick={handleAdd}>
|
||||
新增场站
|
||||
</Button>
|
||||
@@ -286,9 +281,10 @@ export default function StationManage() {
|
||||
<Form.Item name="orgId" label="所属组织" rules={[{ required: true }]}>
|
||||
<Select placeholder="请选择所属组织" allowClear>
|
||||
{orgList.map(item => (
|
||||
<Select.Option key={item.id} value={item.orgId}>
|
||||
// ✅ 这里修复了!原来是 item.orgId,现在是 item.id
|
||||
<Option key={item.id} value={item.id}>
|
||||
{item.orgName}
|
||||
</Select.Option>
|
||||
</Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
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,
|
||||
Input, Popconfirm, Divider, InputNumber, Pagination, Table, Select,
|
||||
Tag, Checkbox, App
|
||||
} from 'antd';
|
||||
import {
|
||||
@@ -17,16 +17,16 @@ import { RootState } from '../store';
|
||||
import { getOrgList } from '../api/organization';
|
||||
import { getSiteByOrgId } from '../api/stationManage';
|
||||
|
||||
|
||||
const { Text } = Typography;
|
||||
const { TabPane } = Tabs;
|
||||
const AntdCard = Card as any;
|
||||
|
||||
export default function UserRolePage() {
|
||||
// ====================== 角色管理状态 ======================
|
||||
// ====================== 全局提示 ======================
|
||||
const [messageApi, contextHolder] = message.useMessage();
|
||||
const { modal } = App.useApp();
|
||||
|
||||
// ====================== 角色管理状态 ======================
|
||||
const [roles, setRoles] = useState([]);
|
||||
const [menuTree, setMenuTree] = useState([]);
|
||||
const [checkedKeys, setCheckedKeys] = useState<number[]>([]);
|
||||
@@ -43,13 +43,18 @@ export default function UserRolePage() {
|
||||
const [rolesOption, setRolesOption] = useState([]);
|
||||
const [selectedUserIds, setSelectedUserIds] = useState<number[]>([]);
|
||||
const { userInfo } = useSelector((state: RootState) => state.user);
|
||||
const [roleDetail, setRoleDetail] = useState(null);
|
||||
const [orgList, setOrgList] = useState([]);
|
||||
const [siteList, setSiteList] = useState([]);
|
||||
// ✅ 控制是否显示所属场站
|
||||
const [showSite, setShowSite] = useState(true);
|
||||
// 全局缓存:所有场站(用于表格展示)
|
||||
const [allSiteList, setAllSiteList] = useState([]);
|
||||
|
||||
// ====================== 统一分页 ======================
|
||||
const [showSite, setShowSite] = useState(true);
|
||||
const [siteDisabled, setSiteDisabled] = useState(false);
|
||||
const isEditSelf = currentUser?.userId == userInfo?.userId;
|
||||
|
||||
|
||||
|
||||
// ====================== 分页 ======================
|
||||
const [rolePagination, setRolePagination] = useState({
|
||||
pageNum: 1, pageSize: 12, total: 0
|
||||
});
|
||||
@@ -58,32 +63,44 @@ export default function UserRolePage() {
|
||||
});
|
||||
|
||||
// 获取组织列表
|
||||
const getOrgData = () => {
|
||||
getOrgList({ pageNum: 1, pageSize: 9999, userId: userInfo?.userId }).then(res => {
|
||||
if (res.code === 200) setOrgList(res.rows || []);
|
||||
});
|
||||
const getOrgData = async () => {
|
||||
const res = await getOrgList({ pageNum: 1, pageSize: 9999, userId: userInfo?.userId });
|
||||
if (res.code === 200) {
|
||||
const orgs = res.rows || [];
|
||||
setOrgList(orgs);
|
||||
// 预加载所有组织下的场站,缓存
|
||||
await loadAllSite(orgs);
|
||||
}
|
||||
};
|
||||
|
||||
// 根据组织ID获取场站
|
||||
// 预加载全部场站
|
||||
const loadAllSite = async (orgs) => {
|
||||
let totalSite = [];
|
||||
for (const org of orgs) {
|
||||
const res = await getSiteByOrgId({ id: org.id }).catch(() => ({ code: 200, data: [] }));
|
||||
if (res.code === 200) {
|
||||
const list = res.data || res.rows || [];
|
||||
totalSite = [...totalSite, ...list];
|
||||
}
|
||||
}
|
||||
setAllSiteList(totalSite);
|
||||
};
|
||||
|
||||
// 根据组织ID获取场站(弹窗下拉用)
|
||||
const getSiteByOrg = (orgId) => {
|
||||
if (!orgId) {
|
||||
setSiteList([]);
|
||||
return;
|
||||
}
|
||||
getSiteByOrgId({ id: orgId }).then(res => {
|
||||
if (res.code === 200) setSiteList(res.data || res.rows || []);
|
||||
}).catch(() => setSiteList([]));
|
||||
const list = allSiteList.filter(item => item.orgId == orgId);
|
||||
setSiteList(list);
|
||||
};
|
||||
|
||||
// ====================== 获取角色列表 ======================
|
||||
// 获取角色列表
|
||||
const getRoleData = () => {
|
||||
const params = {
|
||||
pageNum: rolePagination.pageNum,
|
||||
pageSize: rolePagination.pageSize,
|
||||
};
|
||||
const params = { pageNum: rolePagination.pageNum, pageSize: rolePagination.pageSize };
|
||||
getRoleList(params).then(res => {
|
||||
if (res.code === 200) {
|
||||
// 根据 roleSort 升序排序(越小越靠前)
|
||||
let sortedRoles = (res.data || []).sort((a, b) => (a.roleSort || 999) - (b.roleSort || 999));
|
||||
setRoles(sortedRoles);
|
||||
setRolePagination({
|
||||
@@ -94,7 +111,7 @@ export default function UserRolePage() {
|
||||
});
|
||||
};
|
||||
|
||||
// ====================== 获取菜单树(只加载一次) ======================
|
||||
// 获取菜单树
|
||||
const getMenuData = () => {
|
||||
getMenuList({ pageNum: 1, pageSize: 1000 }).then(res => {
|
||||
if (res.code == 200) {
|
||||
@@ -104,14 +121,13 @@ export default function UserRolePage() {
|
||||
});
|
||||
};
|
||||
|
||||
// ====================== 获取用户列表 ======================
|
||||
// 获取用户列表
|
||||
const getUserData = () => {
|
||||
const params = {
|
||||
pageNum: userPagination.pageNum,
|
||||
pageSize: userPagination.pageSize,
|
||||
orgId: userInfo?.orgId,
|
||||
siteId: userInfo?.siteId,
|
||||
//userId: userInfo?.userId
|
||||
};
|
||||
getUser(params).then(res => {
|
||||
if (res.code === 200) {
|
||||
@@ -124,11 +140,9 @@ export default function UserRolePage() {
|
||||
});
|
||||
};
|
||||
|
||||
// ====================== 获取角色下拉框 ======================
|
||||
// 角色下拉选项
|
||||
const getRoleForSelect = () => {
|
||||
getRoleAllocate({
|
||||
pageNum: 1, pageSize: 1000,
|
||||
}).then(res => {
|
||||
getRoleAllocate({ pageNum: 1, pageSize: 1000 }).then(res => {
|
||||
if (res.code === 200) {
|
||||
let sortedRoles = (res.data || []).sort((a, b) => (a.roleSort || 999) - (b.roleSort || 999));
|
||||
setRolesOption(sortedRoles);
|
||||
@@ -136,15 +150,7 @@ export default function UserRolePage() {
|
||||
});
|
||||
};
|
||||
|
||||
// ====================== 获取当前角色详情 ======================
|
||||
const getRoleById = () => {
|
||||
if (!userInfo?.roleId) return;
|
||||
getRoleDetailById(userInfo.roleId).then(res => {
|
||||
if (res.code == 200) setRoleDetail(res.data);
|
||||
});
|
||||
};
|
||||
|
||||
// ====================== 初始化加载 ======================
|
||||
// 初始化
|
||||
useEffect(() => {
|
||||
getMenuData();
|
||||
getOrgData();
|
||||
@@ -164,21 +170,17 @@ export default function UserRolePage() {
|
||||
roleForm.resetFields();
|
||||
setCheckedKeys([]);
|
||||
setEditRole(null);
|
||||
// 默认值
|
||||
roleForm.setFieldsValue({ status: true, roleSort: 1, roleLevel: 1 });
|
||||
setRoleModalVisible(true);
|
||||
};
|
||||
|
||||
const handleEditRole = (record) => {
|
||||
setEditRole(record);
|
||||
roleForm.setFieldsValue({
|
||||
...record,
|
||||
roleLevel: record.roleLevel
|
||||
});
|
||||
roleForm.setFieldsValue({ ...record, roleLevel: record.roleLevel });
|
||||
|
||||
const getAllLeafKeys = (tree) => {
|
||||
let leaves = [];
|
||||
function traverse(nodes) {
|
||||
let leaves: number[] = [];
|
||||
function traverse(nodes: any[]) {
|
||||
nodes.forEach(node => {
|
||||
if (!node.children || node.children.length === 0) {
|
||||
leaves.push(node.key);
|
||||
@@ -190,15 +192,12 @@ export default function UserRolePage() {
|
||||
};
|
||||
|
||||
const leafKeys = getAllLeafKeys(menuTree);
|
||||
const leafChecked = (record.menuIds || [])
|
||||
.map(Number)
|
||||
.filter(id => leafKeys.includes(id));
|
||||
|
||||
const leafChecked = (record.menuIds || []).map(Number).filter(id => leafKeys.includes(id));
|
||||
setCheckedKeys(leafChecked);
|
||||
setRoleModalVisible(true);
|
||||
};
|
||||
|
||||
const handleDeleteRole = (roleId) => {
|
||||
const handleDeleteRole = (roleId: number) => {
|
||||
deleteRole([roleId]).then(res => {
|
||||
if (res.code == 200) {
|
||||
messageApi.success('删除成功');
|
||||
@@ -229,7 +228,7 @@ export default function UserRolePage() {
|
||||
|
||||
const handleSaveRole = () => {
|
||||
roleForm.validateFields().then(values => {
|
||||
const getParentKeys = (key, tree) => {
|
||||
const getParentKeys = (key: number, tree: any[]) => {
|
||||
for (let node of tree) {
|
||||
if (node.key === key) return [node.key];
|
||||
if (node.children) {
|
||||
@@ -240,7 +239,7 @@ export default function UserRolePage() {
|
||||
return [];
|
||||
};
|
||||
|
||||
let allMenuIds = [];
|
||||
let allMenuIds: number[] = [];
|
||||
checkedKeys.forEach(key => {
|
||||
allMenuIds.push(...getParentKeys(key, menuTree));
|
||||
});
|
||||
@@ -254,7 +253,6 @@ export default function UserRolePage() {
|
||||
roleLevel: values.roleLevel
|
||||
};
|
||||
if (editRole) params.roleId = editRole.roleId;
|
||||
|
||||
const api = editRole ? editRoleApi : addRole;
|
||||
api(params).then(res => {
|
||||
if (res.code == 200) {
|
||||
@@ -268,63 +266,71 @@ export default function UserRolePage() {
|
||||
};
|
||||
|
||||
// ====================== 用户操作 ======================
|
||||
// 新增用户
|
||||
const handleAddUser = () => {
|
||||
setCurrentUser(null);
|
||||
setShowSite(true);
|
||||
setSiteList([]);
|
||||
setShowSite(true); // ✅ 默认显示
|
||||
form.resetFields();
|
||||
|
||||
const defaultOrgId = userInfo?.orgId ?? '';
|
||||
const defaultSiteId = userInfo?.siteId ?? '';
|
||||
|
||||
form.setFieldsValue({
|
||||
orgId: defaultOrgId,
|
||||
siteId: defaultSiteId
|
||||
});
|
||||
|
||||
setSiteDisabled(!!defaultSiteId);
|
||||
|
||||
if (defaultOrgId) {
|
||||
getSiteByOrg(defaultOrgId);
|
||||
}
|
||||
setModalVisible(true);
|
||||
};
|
||||
|
||||
const handleEditUser = (record) => {
|
||||
// 编辑用户
|
||||
const handleEditUser = (record: any) => {
|
||||
setCurrentUser(record);
|
||||
// ✅ 1. 先拿到当前用户的角色ID(优先取roles里的,兼容roleId字段)
|
||||
const userRoleId = record.roles?.[0]?.roleId ?? record.roleId;
|
||||
// ✅ 2. 从角色下拉选项里,找到匹配ID的「中文名称」
|
||||
const targetRole = rolesOption.find(item => item.roleId == userRoleId);
|
||||
const targetRole = rolesOption.find(item => String(item.roleId) === String(userRoleId));
|
||||
|
||||
// ✅ 3. 回填表单:roleIds 赋值「角色ID」,确保下拉框显示中文
|
||||
form.setFieldsValue({
|
||||
...record,
|
||||
roleIds: targetRole?.roleId ?? userRoleId, // 用找到的角色ID(确保匹配)
|
||||
roleIds: targetRole?.roleId ?? userRoleId,
|
||||
});
|
||||
|
||||
const isOrgAdmin = targetRole?.roleKey == 'manager';
|
||||
const isOrgAdmin = targetRole?.roleKey === 'manager';
|
||||
setShowSite(!isOrgAdmin);
|
||||
|
||||
|
||||
|
||||
setSiteList([]);
|
||||
if (record.orgId) {
|
||||
getSiteByOrg(record.orgId);
|
||||
setTimeout(() => {
|
||||
form.setFieldsValue({ siteId: record.siteId });
|
||||
}, 300);
|
||||
}, 200);
|
||||
}
|
||||
|
||||
setModalVisible(true);
|
||||
};
|
||||
|
||||
const handleResetPassword = () => {
|
||||
// 重置密码
|
||||
const handleResetPassword = (user: any) => {
|
||||
modal.confirm({
|
||||
title: '重置密码',
|
||||
content: '确定将密码重置为 123456 吗?',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
editUser({
|
||||
userId: currentUser.userId,
|
||||
password: '123456'
|
||||
}).then(res => {
|
||||
if (res.code === 200) {
|
||||
messageApi.success('密码已重置为:123456');
|
||||
} else {
|
||||
messageApi.error('重置失败');
|
||||
}
|
||||
editUser({ userId: user.userId, password: '123456' }).then(res => {
|
||||
res.code === 200 ? messageApi.success('密码已重置为:123456') : messageApi.error('重置失败');
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const handleDeleteUser = (userId) => {
|
||||
const handleDeleteUser = (userId: number) => {
|
||||
deleteUser(userId).then(res => {
|
||||
if (res.code === 200) {
|
||||
messageApi.success('删除成功');
|
||||
@@ -357,12 +363,10 @@ export default function UserRolePage() {
|
||||
...values,
|
||||
roleIds: [values.roleIds].flat()
|
||||
};
|
||||
|
||||
if (currentUser) {
|
||||
params.userId = currentUser.userId;
|
||||
delete params.password;
|
||||
}
|
||||
|
||||
const api = currentUser ? editUser : addUser;
|
||||
api(params).then(res => {
|
||||
if (res.code === 200) {
|
||||
@@ -376,7 +380,7 @@ export default function UserRolePage() {
|
||||
});
|
||||
};
|
||||
|
||||
// ====================== 页面主体 ======================
|
||||
// ====================== 页面渲染 ======================
|
||||
return (
|
||||
<div style={{
|
||||
height: '100%',
|
||||
@@ -388,11 +392,9 @@ export default function UserRolePage() {
|
||||
background: '#f5f7fa'
|
||||
}}>
|
||||
{contextHolder}
|
||||
|
||||
<AntdCard style={{ borderRadius: 12, boxShadow: '0 2px 10px rgba(0,0,0,0.06)' }}>
|
||||
<Tabs defaultActiveKey="user" type="card" size="large" style={{ marginBottom: 20 }}>
|
||||
|
||||
{/* ========== 用户管理 ========== */}
|
||||
{/* 用户管理 */}
|
||||
<TabPane tab="用户管理" key="user">
|
||||
<div style={{ marginBottom: 16, display: 'flex', justifyContent: 'space-between' }}>
|
||||
{selectedUserIds.length > 0 && (
|
||||
@@ -402,7 +404,6 @@ export default function UserRolePage() {
|
||||
)}
|
||||
<Button type="primary" icon={<PlusOutlined />} onClick={handleAddUser}>新增用户</Button>
|
||||
</div>
|
||||
|
||||
<Table
|
||||
rowKey="userId"
|
||||
rowSelection={{
|
||||
@@ -414,47 +415,44 @@ export default function UserRolePage() {
|
||||
{ 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>
|
||||
title: '所属机构',
|
||||
render: (_, r) => {
|
||||
const org = orgList.find(o => o.id == r.orgId);
|
||||
return org ? org.orgName : '—';
|
||||
}
|
||||
},
|
||||
// 所属场站(纯缓存匹配,无接口)
|
||||
{
|
||||
title: '所属场站',
|
||||
render: (_, r) => {
|
||||
if (!r.siteId) return '—';
|
||||
const site = allSiteList.find(s => s.id == r.siteId);
|
||||
return site ? site.siteName : '—';
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '角色',
|
||||
render: (_, r) => (r.roles || []).map(i => (
|
||||
<Tag color="blue" key={i.roleId}>{i?.roleKey}</Tag>
|
||||
))
|
||||
},
|
||||
{
|
||||
title: '状态', render: (_, s) => s.status == '0' ?
|
||||
<Tag color="green">正常</Tag> : <Tag color="red">停用</Tag>
|
||||
title: '状态',
|
||||
render: (_, s) => s.status === '0'
|
||||
? <Tag color="green">正常</Tag>
|
||||
: <Tag color="red">停用</Tag>
|
||||
},
|
||||
{
|
||||
title: '操作', render: (_, r) => (
|
||||
title: '操作',
|
||||
render: (_, r) => (
|
||||
<Space>
|
||||
<Button
|
||||
type="text"
|
||||
icon={<EditOutlined style={{ color: '#1890ff' }} />}
|
||||
onClick={() => handleEditUser(r)}
|
||||
>
|
||||
编辑
|
||||
</Button>
|
||||
<Popconfirm
|
||||
onConfirm={() => handleDeleteUser(r.userId)}
|
||||
title="确定删除该用户吗?"
|
||||
>
|
||||
<Button
|
||||
type="text"
|
||||
danger
|
||||
icon={<DeleteOutlined />}
|
||||
>
|
||||
删除
|
||||
</Button>
|
||||
<Button type="text" icon={<EditOutlined style={{ color: '#1890ff' }} />} onClick={() => handleEditUser(r)}>编辑</Button>
|
||||
<Popconfirm onConfirm={() => handleDeleteUser(r.userId)} title="确定删除该用户吗?">
|
||||
<Button type="text" danger icon={<DeleteOutlined />}>删除</Button>
|
||||
</Popconfirm>
|
||||
<Button
|
||||
type="text"
|
||||
icon={<UserOutlined style={{ color: '#faad14' }} />}
|
||||
onClick={() => {
|
||||
setCurrentUser(r);
|
||||
handleResetPassword();
|
||||
}}
|
||||
>
|
||||
重置密码
|
||||
</Button>
|
||||
<Button type="text" icon={<UserOutlined style={{ color: '#faad14' }} />} onClick={() => { setCurrentUser(r); handleResetPassword(r); }}>重置密码</Button>
|
||||
</Space>
|
||||
)
|
||||
}
|
||||
@@ -467,13 +465,13 @@ export default function UserRolePage() {
|
||||
showSizeChanger: true,
|
||||
showTotal: t => `共 ${t} 条`
|
||||
}}
|
||||
onChange={(p) => setUserPagination({ ...userPagination, pageNum: p.current, pageSize: p.pageSize })}
|
||||
onChange={(p) => setUserPagination({ ...userPagination, pageNum: p.current!, pageSize: p.pageSize! })}
|
||||
bordered
|
||||
size="middle"
|
||||
/>
|
||||
</TabPane>
|
||||
|
||||
{/* ========== 角色管理 ========== */}
|
||||
{/* 角色管理 */}
|
||||
{userInfo?.userId == 1 && (
|
||||
<TabPane tab="角色管理" key="role">
|
||||
<div style={{ marginBottom: 16, display: 'flex', justifyContent: 'space-between' }}>
|
||||
@@ -484,7 +482,6 @@ export default function UserRolePage() {
|
||||
)}
|
||||
<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}>
|
||||
@@ -524,7 +521,6 @@ export default function UserRolePage() {
|
||||
</Col>
|
||||
)) : <EmptyData height={260} />}
|
||||
</Row>
|
||||
|
||||
<div style={{ textAlign: 'right', marginTop: 20 }}>
|
||||
<Pagination
|
||||
current={rolePagination.pageNum}
|
||||
@@ -537,11 +533,10 @@ export default function UserRolePage() {
|
||||
</div>
|
||||
</TabPane>
|
||||
)}
|
||||
|
||||
</Tabs>
|
||||
</AntdCard>
|
||||
|
||||
{/* ========== 角色弹窗 ========== */}
|
||||
{/* 角色弹窗 */}
|
||||
<Modal
|
||||
title={editRole ? '编辑角色' : '新增角色'}
|
||||
open={roleModalVisible}
|
||||
@@ -562,7 +557,6 @@ export default function UserRolePage() {
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Row gutter={16}>
|
||||
<Col span={12}>
|
||||
<Form.Item name="roleSort" label="排序">
|
||||
@@ -570,11 +564,7 @@ export default function UserRolePage() {
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item
|
||||
name="roleLevel"
|
||||
label="角色等级"
|
||||
rules={[{ required: true, message: '请输入角色等级' }]}
|
||||
>
|
||||
<Form.Item name="roleLevel" label="角色等级" rules={[{ required: true, message: '请输入角色等级' }]}>
|
||||
<InputNumber style={{ width: '100%' }} placeholder="1~100" min={1} max={100} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
@@ -596,6 +586,7 @@ export default function UserRolePage() {
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
{/* 用户弹窗 */}
|
||||
<Modal
|
||||
title={currentUser ? '编辑用户' : '新增用户'}
|
||||
open={modalVisible}
|
||||
@@ -613,13 +604,10 @@ export default function UserRolePage() {
|
||||
<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={currentUser ? "编辑不显示,重置为123456" : "请输入密码"}
|
||||
/>
|
||||
<Input.Password placeholder={currentUser ? "编辑不显示,重置为123456" : "请输入密码"} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
@@ -632,34 +620,51 @@ export default function UserRolePage() {
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
{/* ====== 自动适应布局:隐藏角色时,状态自动占满一行 ====== */}
|
||||
<Row gutter={16}>
|
||||
<Col span={12}>
|
||||
<Form.Item name="roleIds" label="分配角色" rules={[{ required: true }]}>
|
||||
<Select
|
||||
placeholder="选择角色"
|
||||
onChange={(val) => {
|
||||
// ✅ 选择角色时判断是否为机构管理员
|
||||
const role = rolesOption.find(item => item.roleId == val);
|
||||
if (role?.roleKey == 'manager') {
|
||||
setShowSite(false);
|
||||
form.setFieldsValue({ siteId: null });
|
||||
} else {
|
||||
setShowSite(true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{rolesOption.map(i => <Select.Option key={i.roleId} value={i.roleId}>{i.roleName}</Select.Option>)}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<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>
|
||||
{!isEditSelf ? (
|
||||
<>
|
||||
<Col span={12}>
|
||||
<Form.Item name="roleIds" label="分配角色" rules={[{ required: true }]}>
|
||||
<Select
|
||||
placeholder="选择角色"
|
||||
key={rolesOption.length}
|
||||
onChange={(val) => {
|
||||
const role = rolesOption.find(item => String(item.roleId) === String(val));
|
||||
if (role?.roleKey === 'manager') {
|
||||
setShowSite(false);
|
||||
form.setFieldsValue({ siteId: null });
|
||||
} else {
|
||||
setShowSite(true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{rolesOption.map(i => (
|
||||
<Select.Option key={i.roleId} value={i.roleId}>{i.roleName}</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<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>
|
||||
</>
|
||||
) : (
|
||||
// 编辑自己 → 状态占满一行 span=24
|
||||
<Col span={24}>
|
||||
<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>
|
||||
|
||||
<Row gutter={16}>
|
||||
@@ -672,7 +677,6 @@ export default function UserRolePage() {
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
|
||||
<Col span={12}>
|
||||
<Form.Item name="orgId" label="所属组织">
|
||||
<Select
|
||||
@@ -689,12 +693,14 @@ export default function UserRolePage() {
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
|
||||
{/* ✅ 机构管理员不显示所属场站 */}
|
||||
{showSite && siteList.length > 0 && (
|
||||
<Col span={12}>
|
||||
<Form.Item name="siteId" label="所属场站">
|
||||
<Select placeholder="请选择场站" allowClear>
|
||||
<Select
|
||||
placeholder="请选择场站"
|
||||
allowClear
|
||||
disabled={siteDisabled}
|
||||
>
|
||||
{siteList.map(item => (
|
||||
<Select.Option key={item.id} value={item.id}>{item.siteName}</Select.Option>
|
||||
))}
|
||||
|
||||
@@ -21,14 +21,14 @@ export default defineConfig(({ mode }) => {
|
||||
react(),
|
||||
tailwindcss(),
|
||||
// 复制 Cesium 静态资源
|
||||
viteStaticCopy({
|
||||
targets: [
|
||||
{
|
||||
src: 'node_modules/cesium/Build/Cesium',
|
||||
dest: '',
|
||||
},
|
||||
],
|
||||
}),
|
||||
//viteStaticCopy({
|
||||
// targets: [
|
||||
// {
|
||||
// src: 'node_modules/cesium/Build/Cesium',
|
||||
// dest: '',
|
||||
// },
|
||||
// ],
|
||||
//}),
|
||||
],
|
||||
|
||||
resolve: {
|
||||
@@ -49,33 +49,33 @@ export default defineConfig(({ mode }) => {
|
||||
rollupOptions: {
|
||||
output: {
|
||||
// ---- 手动分包策略 ----
|
||||
manualChunks(id) {
|
||||
// 1. 将 React 生态单独打包(利用浏览器缓存)
|
||||
if (id.includes('node_modules/react') || id.includes('node_modules/react-dom')) {
|
||||
return 'react-vendor';
|
||||
}
|
||||
// 2. Ant Design 单独打包
|
||||
if (id.includes('node_modules/antd') || id.includes('node_modules/@ant-design')) {
|
||||
return 'antd-vendor';
|
||||
}
|
||||
// 3. Cesium 单独打包(体积巨大)
|
||||
if (id.includes('node_modules/cesium') || id.includes('cesium')) {
|
||||
return 'cesium-vendor';
|
||||
}
|
||||
// 4. 其他 node_modules 合并
|
||||
if (id.includes('node_modules')) {
|
||||
return 'vendor';
|
||||
}
|
||||
},
|
||||
//manualChunks(id) {
|
||||
// // 1. 将 React 生态单独打包(利用浏览器缓存)
|
||||
// if (id.includes('node_modules/react') || id.includes('node_modules/react-dom')) {
|
||||
// return 'react-vendor';
|
||||
// }
|
||||
// // 2. Ant Design 单独打包
|
||||
// if (id.includes('node_modules/antd') || id.includes('node_modules/@ant-design')) {
|
||||
// return 'antd-vendor';
|
||||
// }
|
||||
// // 3. Cesium 单独打包(体积巨大)
|
||||
// if (id.includes('node_modules/cesium') || id.includes('cesium')) {
|
||||
// return 'cesium-vendor';
|
||||
// }
|
||||
// // 4. 其他 node_modules 合并
|
||||
// if (id.includes('node_modules')) {
|
||||
// return 'vendor';
|
||||
// }
|
||||
//},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
define: {
|
||||
// Cesium 路径注入
|
||||
CESIUM_BASE_URL: JSON.stringify(
|
||||
'/Cesium'
|
||||
),
|
||||
//CESIUM_BASE_URL: JSON.stringify(
|
||||
// '/Cesium'
|
||||
//),
|
||||
// 环境变量注入
|
||||
'import.meta.env.VITE_API_BASE_URL': JSON.stringify(env.VITE_API_BASE_URL ?? env.baseURL ?? ''),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user