Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivManage
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
CivManage
Commits
c6e87c79
Commit
c6e87c79
authored
Nov 05, 2020
by
陈前坚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: 用户管理更改机构
parent
86f2ec75
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
21 deletions
+97
-21
UserManage.js
src/pages/userCenter/UserManage.js
+97
-21
No files found.
src/pages/userCenter/UserManage.js
View file @
c6e87c79
...
...
@@ -30,19 +30,24 @@ const UserManage = () => {
const
[
treeLoading
,
setTreeLoading
]
=
useState
(
false
);
const
[
tableLoading
,
setTableLoading
]
=
useState
(
false
);
const
[
treeData
,
setTreeData
]
=
useState
([]);
// 用户机构树
const
[
treeData1
,
setTreeData1
]
=
useState
([]);
const
[
treeData2
,
setTreeData2
]
=
useState
([]);
const
[
tableData
,
setTableData
]
=
useState
([]);
// 用户表
const
[
currentSelect
,
setCurrentSelect
]
=
useState
([]);
const
[
userVisible
,
setUserVisible
]
=
useState
(
false
);
const
[
addOrgVisible
,
setAddOrgVisible
]
=
useState
(
false
);
const
[
editOrgVisible
,
setEditOrgVisible
]
=
useState
(
false
);
const
[
deleteOrgVisible
,
setDeleteOrgVisible
]
=
useState
(
false
);
const
[
changeOrgVisible
,
setChangeOrgVisible
]
=
useState
(
false
);
const
[
passwordVisible
,
setPasswordVisible
]
=
useState
(
false
);
const
[
editUserVisible
,
setEditUserVisible
]
=
useState
(
false
);
const
[
userState
,
setUserState
]
=
useState
(
0
);
const
[
treeState
,
setTreeState
]
=
useState
(
true
);
const
[
freezeUserVisible
,
setFreezeUserVisible
]
=
useState
(
false
);
const
[
deleteUserVisible
,
setDeleteUserVisible
]
=
useState
(
false
);
const
[
orgTitle
,
setOrgTitle
]
=
useState
(
'机构'
);
const
[
orgID
,
setOrgID
]
=
useState
();
const
[
newOrgID
,
setNewOrgID
]
=
useState
();
const
[
userID
,
setUserID
]
=
useState
();
const
[
addUserForm
]
=
Form
.
useForm
();
const
[
addOrgForm
]
=
Form
.
useForm
();
...
...
@@ -53,7 +58,7 @@ const UserManage = () => {
if
(
userState
)
{
freezeText
=
'即将激活该用户,是否确认激活?'
;
}
// 渲染机构
目录
树
// 渲染机构树
const
mapTree
=
org
=>
{
const
haveChildren
=
Array
.
isArray
(
org
.
children
)
&&
org
.
children
.
length
>
0
;
return
{
...
...
@@ -82,6 +87,16 @@ const UserManage = () => {
children
:
haveChildren
?
org
.
children
.
map
(
i
=>
mapTree
(
i
))
:
[],
};
};
const
mapTree1
=
org
=>
{
const
haveChildren
=
Array
.
isArray
(
org
.
children
)
&&
org
.
children
.
length
>
0
;
return
{
title
:
`
${
org
.
text
}
`
,
key
:
org
.
id
,
// icon: <CaretDownOutlined />,
// 判断它是否存在子集,若果存在就进行再次进行遍历操作,知道不存在子集便对其他的元素进行操作
children
:
haveChildren
?
org
.
children
.
map
(
i
=>
mapTree1
(
i
))
:
[],
};
};
// 用户表列名
const
columns
=
[
{
...
...
@@ -170,14 +185,14 @@ const UserManage = () => {
},
];
// 获取用户机构
列表
// 获取用户机构
树
useEffect
(()
=>
{
getUserTree
(
-
1
,
-
1
);
},
[]);
const
getUserTree
=
(
selectOU
,
node
)
=>
{
setTreeLoading
(
true
);
get
(
`/Cityinterface/rest/services/OMS.svc/U_GetOUTree`
,
{
return
get
(
`/Cityinterface/rest/services/OMS.svc/U_GetOUTree`
,
{
_version
:
9999
,
_dc
:
time
.
getTime
(),
selectOU
,
...
...
@@ -186,9 +201,14 @@ const UserManage = () => {
.
then
(
res
=>
{
setTreeLoading
(
false
);
if
(
res
.
length
>
0
)
{
const
orgTree
=
res
.
map
(
org
=>
mapTree
(
org
));
setTreeData
(
orgTree
);
onSelect
([
res
[
0
].
id
]);
setTreeData1
(
res
);
const
newTree
=
res
.
map
(
org
=>
mapTree
(
org
));
setTreeData
(
newTree
);
// 第一次加载,默认选择第一个组织
if
(
treeState
)
{
onSelect
([
res
[
0
].
id
]);
setTreeState
(
false
);
}
}
})
.
catch
(
err
=>
{
...
...
@@ -205,20 +225,23 @@ const UserManage = () => {
}
else
{
setCurrentSelect
(
props
[
0
]);
}
setOrgID
(
props
[
0
]
||
currentSelect
);
get
(
`/Cityinterface/rest/services/OMS.svc/U_GetOneOUUserListNew`
,
{
_version
:
9999
,
_dc
:
time
.
getTime
(),
OUID
:
props
[
0
]
||
currentSelect
,
})
.
then
(
res
=>
{
setTableLoading
(
false
);
const
table
=
res
.
root
.
map
((
item
,
index
)
=>
{
item
.
key
=
index
;
item
.
ddid
=
item
.
ddid
?
'已绑定'
:
'未绑定'
;
item
.
wxid
=
item
.
wxid
?
'已绑定'
:
'未绑定'
;
return
item
;
});
setTableData
(
table
);
if
(
res
.
success
)
{
setTableLoading
(
false
);
const
table
=
res
.
root
.
map
((
item
,
index
)
=>
{
item
.
key
=
index
;
item
.
ddid
=
item
.
ddid
?
'已绑定'
:
'未绑定'
;
item
.
wxid
=
item
.
wxid
?
'已绑定'
:
'未绑定'
;
return
item
;
});
setTableData
(
table
);
}
})
.
catch
(
err
=>
{
setTableLoading
(
false
);
...
...
@@ -252,6 +275,8 @@ const UserManage = () => {
setDeleteOrgVisible
(
true
);
setOrgTitle
(
`在
${
title
}
下添加用户`
);
setOrgID
(
id
);
// 删除后默认选择第一个组织
setTreeState
(
true
);
};
// 右侧表格相关操作
...
...
@@ -260,7 +285,9 @@ const UserManage = () => {
setUserID
(
record
.
userID
);
};
const
changeOrg
=
record
=>
{
// setDeleteUserVisible(true);
setChangeOrgVisible
(
true
);
const
newTree
=
treeData1
.
map
(
org
=>
mapTree1
(
org
));
setTreeData2
(
newTree
);
setUserID
(
record
.
userID
);
};
const
changePassword
=
record
=>
{
...
...
@@ -337,8 +364,10 @@ const UserManage = () => {
message
:
'提交成功'
,
});
// 重新获取机构树与用户表
getUserTree
(
-
1
,
-
1
);
// onSelect([res.OUID]);
getUserTree
(
-
1
,
-
1
).
then
(()
=>
{
// 只能是字符串,数字没有选择效果
onSelect
([
`
${
res
.
OUID
}
`
]);
});
}
else
{
notification
.
error
({
message
:
'提交失败'
,
...
...
@@ -370,9 +399,9 @@ const UserManage = () => {
notification
.
success
({
message
:
'提交成功'
,
});
// 重新获取机构树与用户表
getUserTree
(
-
1
,
-
1
);
// 重新获取用户表
// onSelect([orgID]);
onSelect
([
orgID
]);
}
else
{
notification
.
error
({
message
:
'提交失败'
,
...
...
@@ -396,9 +425,8 @@ const UserManage = () => {
notification
.
success
({
message
:
'提交成功'
,
});
// 重新获取用户表
// 重新获取
机构树与
用户表
getUserTree
(
-
1
,
-
1
);
// onSelect([orgID]);
}
else
{
notification
.
error
({
message
:
'提交失败'
,
...
...
@@ -412,6 +440,33 @@ const UserManage = () => {
});
};
const
submitChangeOrg
=
()
=>
{
get
(
`/Cityinterface/rest/services/OMS.svc/U_JumpToAnotherOU`
,
{
_version
:
9999
,
_dc
:
time
.
getTime
(),
userID
,
oldOUID
:
orgID
,
newOUID
:
newOrgID
,
})
.
then
(
res
=>
{
if
(
res
.
success
)
{
setChangeOrgVisible
(
false
);
// 跳转到新组织机构下的用户表
onSelect
([
newOrgID
]);
notification
.
success
({
message
:
'提交成功'
,
});
}
else
{
notification
.
error
({
message
:
'提交失败'
,
description
:
res
.
message
,
});
}
})
.
catch
(
err
=>
{
message
.
error
(
err
);
});
};
const
submitChangePassword
=
()
=>
{
get
(
`/Cityinterface/rest/services/OMS.svc/U_UpdatePassword`
,
{
_version
:
9999
,
...
...
@@ -541,6 +596,7 @@ const UserManage = () => {
<
Tree
showLine
=
"true"
showIcon
=
"true"
defaultExpandAll
=
"true"
selectedKeys
=
{[
currentSelect
]}
loading
=
{
treeLoading
}
onSelect
=
{
onSelect
}
...
...
@@ -667,6 +723,26 @@ const UserManage = () => {
>
<
p
>
即将删除该机构,是否确认删除?
<
/p
>
<
/Modal
>
<
Modal
title
=
"更改机构"
visible
=
{
changeOrgVisible
}
onOk
=
{
submitChangeOrg
}
onCancel
=
{()
=>
setChangeOrgVisible
(
false
)}
okText
=
"确认"
cancelText
=
"取消"
width
=
"330px"
>
<
Tree
showLine
=
"true"
showIcon
=
"true"
defaultExpandAll
=
"true"
// selectedKeys={[currentSelect]}
onSelect
=
{
props
=>
{
setNewOrgID
(
props
[
0
]);
}}
treeData
=
{
treeData2
}
/
>
<
/Modal
>
{
/* 修改密码 */
}
<
Modal
title
=
"编辑用户"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment