Commit 975f5d33 authored by 张烨's avatar 张烨
parents 02a9c759 8bd2d251
...@@ -51,6 +51,7 @@ import { ...@@ -51,6 +51,7 @@ import {
deleteOrg as postDeleteOrg, deleteOrg as postDeleteOrg,
updateUserPassword, updateUserPassword,
setUserRelation, setUserRelation,
setUserRelations,
multiDeleteUsers, multiDeleteUsers,
} from '@/services/userCenter/userManage/api'; } from '@/services/userCenter/userManage/api';
import classnames from 'classnames'; import classnames from 'classnames';
...@@ -97,6 +98,7 @@ const UserManage = () => { ...@@ -97,6 +98,7 @@ const UserManage = () => {
const [orgIDs, setOrgIDs] = useState(''); // 批量操作的机构 const [orgIDs, setOrgIDs] = useState(''); // 批量操作的机构
const [multiDelete, setMultiDelete] = useState(false); // 是否批量删除用户 const [multiDelete, setMultiDelete] = useState(false); // 是否批量删除用户
const [multiChangeOrgs, setMultiChangeOrgs] = useState(false); // 是否批量更改机构 const [multiChangeOrgs, setMultiChangeOrgs] = useState(false); // 是否批量更改机构
const [multiRelateRoles, setMultiRelateRoles] = useState(false); // 是否批量更改机构
const [rolelist, setRolelist] = useState([]); // 角色列表 const [rolelist, setRolelist] = useState([]); // 角色列表
const [stationlist, setStationlist] = useState([]); // 站点列表 const [stationlist, setStationlist] = useState([]); // 站点列表
...@@ -279,7 +281,7 @@ const UserManage = () => { ...@@ -279,7 +281,7 @@ const UserManage = () => {
onChange: (selectedRowKeys, selectedRows) => { onChange: (selectedRowKeys, selectedRows) => {
console.log(selectedRowKeys.toString()); console.log(selectedRowKeys.toString());
console.log(selectedRows.map(item => item.OUID).toString()); console.log(selectedRows.map(item => item.OUID).toString());
setUserIDs(selectedRowKeys.toString()); setUserIDs(selectedRowKeys.toString()); // 数组转字符串,逗号连接
setOrgIDs(selectedRows.map(item => item.OUID).toString()); setOrgIDs(selectedRows.map(item => item.OUID).toString());
// 选中行数大于1时设置批量操作可行 // 选中行数大于1时设置批量操作可行
if (selectedRows.length > 1) { if (selectedRows.length > 1) {
...@@ -451,7 +453,9 @@ const UserManage = () => { ...@@ -451,7 +453,9 @@ const UserManage = () => {
/** ***用户批量操作****** */ /** ***用户批量操作****** */
// 用户关联 // 用户关联
const relateRoles = () => { const relateRoles = () => {
getEmptyRoleList();
setRoleVisible(true); setRoleVisible(true);
setMultiRelateRoles(true);
}; };
// 更改机构 // 更改机构
const changeOrgs = () => { const changeOrgs = () => {
...@@ -667,6 +671,29 @@ const UserManage = () => { ...@@ -667,6 +671,29 @@ const UserManage = () => {
message.error(err); message.error(err);
}); });
}; };
// 获取全部未勾选的角色列表与站点列表
const getEmptyRoleList = () => {
setLoading(true);
getUserRelationList('')
.then(res => {
setLoading(false);
if (res.roleList && res.roleList.length > 0) {
const { roleList, stationList } = res;
setRolelist(roleList);
setStationlist(stationList);
} else {
notification.error({
message: '提交失败',
description: res.message,
});
}
})
.catch(err => {
setLoading(false);
setTableLoading(false);
message.error(err);
});
};
// 提交-关联角色 // 提交-关联角色
const submitRole = () => { const submitRole = () => {
setUserRelation( setUserRelation(
...@@ -698,6 +725,38 @@ const UserManage = () => { ...@@ -698,6 +725,38 @@ const UserManage = () => {
message.error(err); message.error(err);
}); });
}; };
// 提交-批量关联角色
const submitRoles = () => {
setUserRelations(
userIDs,
Object.keys(roleValueList)
.map(k => roleValueList[k])
.flat()
.toString(),
Object.keys(stationValueList)
.map(k => stationValueList[k])
.flat()
.toString(),
)
.then(res => {
if (res.code === 0) {
setRoleVisible(false);
// 跳转到组织
onSelect([currentSelectOrg]);
notification.success({
message: '提交成功',
});
} else {
notification.error({
message: '提交失败',
description: '角色不能为空',
});
}
})
.catch(err => {
message.error(err);
});
};
// 提交-更改机构 // 提交-更改机构
const submitChangeOrg = () => const submitChangeOrg = () =>
addToOrg(currentUser.userID, currentUser.OUID, newOrgID) addToOrg(currentUser.userID, currentUser.OUID, newOrgID)
...@@ -727,6 +786,10 @@ const UserManage = () => { ...@@ -727,6 +786,10 @@ const UserManage = () => {
if (res.code === 0) { if (res.code === 0) {
setChangeOrgVisible(false); setChangeOrgVisible(false);
// 跳转到新组织机构下的用户表 // 跳转到新组织机构下的用户表
const temp = orgIDs.split(',');
// 批量更改机构成功后设置老的orgIDs为全部是newOrgID的数组,并转字符串
setOrgIDs(temp.map(() => newOrgID).toString());
// console.log(temp.map(() => newOrgID).toString());
onSelect([newOrgID]); onSelect([newOrgID]);
notification.success({ notification.success({
message: '提交成功', message: '提交成功',
...@@ -1144,8 +1207,11 @@ const UserManage = () => { ...@@ -1144,8 +1207,11 @@ const UserManage = () => {
<Modal <Modal
title="用户关联" title="用户关联"
visible={roleVisible} visible={roleVisible}
onOk={submitRole} onOk={multiRelateRoles ? submitRoles : submitRole}
onCancel={() => setRoleVisible(false)} onCancel={() => {
setRoleVisible(false);
setMultiRelateRoles(false);
}}
okText="确认" okText="确认"
cancelText="取消" cancelText="取消"
width="960px" width="960px"
...@@ -1272,7 +1338,7 @@ const UserManage = () => { ...@@ -1272,7 +1338,7 @@ const UserManage = () => {
}, },
]} ]}
> >
<Input placeholder="请输入手机号码" /> <Input placeholder="请输入手机号码" autoComplete="off" />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
name="email" name="email"
......
...@@ -176,3 +176,9 @@ export const setUserRelation = (userID, roleList = [], stationList) => ...@@ -176,3 +176,9 @@ export const setUserRelation = (userID, roleList = [], stationList) =>
}, },
}, },
); );
export const setUserRelations = (userIDs, roleList, stationList) =>
get(`${PUBLISH_SERVICE}/UserCenter/SetUserRoleMap`, {
userIds: userIDs,
roleIds: roleList || '',
stationList: stationList || '',
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment