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
97edfa8c
Commit
97edfa8c
authored
Nov 09, 2020
by
张烨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: 整理userManager
parent
aa8f5119
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
38 deletions
+50
-38
UserManage.js
src/pages/userCenter/UserManage.js
+45
-38
UserManage.less
src/pages/userCenter/UserManage.less
+5
-0
No files found.
src/pages/userCenter/UserManage.js
View file @
97edfa8c
...
...
@@ -41,6 +41,10 @@ import {
getUserByKey
,
getUserRelationList
,
getUserTree
,
addUser
as
postAddUser
,
deleteUser
as
postDeleteUser
,
setUserState
as
postSetUserState
,
editUser
as
postEditUser
,
updateUserPassword
,
}
from
'@/services/userCenter/userManage/api'
;
...
...
@@ -55,7 +59,7 @@ const UserManage = () => {
const
[
treeData2
,
setTreeData2
]
=
useState
([]);
const
[
tableData
,
setTableData
]
=
useState
([]);
// 用户表
const
[
searchData
,
setSearchData
]
=
useState
([]);
const
[
currentSelect
,
setCurrentSelect
]
=
useState
([]);
const
[
currentSelect
Org
,
setCurrentSelectOrg
]
=
useState
([]);
const
[
userVisible
,
setUserVisible
]
=
useState
(
false
);
const
[
searchUserVisible
,
setSearchUserVisible
]
=
useState
(
false
);
...
...
@@ -66,7 +70,6 @@ const UserManage = () => {
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
);
...
...
@@ -74,7 +77,7 @@ const UserManage = () => {
const
[
orgTitle
,
setOrgTitle
]
=
useState
(
'机构'
);
const
[
orgID
,
setOrgID
]
=
useState
();
const
[
newOrgID
,
setNewOrgID
]
=
useState
();
const
[
userID
,
setUserID
]
=
useState
(
);
const
[
currentUser
,
setCurrentUser
]
=
useState
({}
);
const
[
rolelist
,
setRolelist
]
=
useState
([]);
const
[
stationlist
,
setStationlist
]
=
useState
([]);
...
...
@@ -101,11 +104,6 @@ const UserManage = () => {
setStationValueList
(
result
);
},
[]);
let
freezeText
=
'即将冻结该用户,是否确认冻结?'
;
if
(
userState
)
{
freezeText
=
'即将激活该用户,是否确认激活?'
;
}
// 用户表列名
const
columns
=
[
{
...
...
@@ -285,12 +283,12 @@ const UserManage = () => {
const
onSelect
=
props
=>
{
setTableLoading
(
true
);
if
(
!
props
[
0
])
{
setCurrentSelect
(
currentSelect
);
setCurrentSelect
Org
(
currentSelectOrg
);
}
else
{
setCurrentSelect
(
props
[
0
]);
setCurrentSelect
Org
(
props
[
0
]);
}
setOrgID
(
props
[
0
]
||
currentSelect
);
getOneOUUserListNew
(
props
[
0
]
||
currentSelect
)
setOrgID
(
props
[
0
]
||
currentSelect
Org
);
getOneOUUserListNew
(
props
[
0
]
||
currentSelect
Org
)
.
then
(
res
=>
{
if
(
res
.
success
)
{
setTableLoading
(
false
);
...
...
@@ -342,29 +340,29 @@ const UserManage = () => {
setTreeState
(
true
);
};
// 在
userID
变化后获取
// 在
currentUser
变化后获取
useEffect
(()
=>
{
if
(
userID
)
{
if
(
currentUser
)
{
getRoleList
();
}
},
[
userID
]);
},
[
currentUser
]);
// 右侧表格相关操作
const
relateRole
=
record
=>
{
setRoleVisible
(
true
);
set
UserID
(
record
.
userID
);
set
CurrentUser
(
record
);
};
const
changeOrg
=
record
=>
{
setChangeOrgVisible
(
true
);
setTreeData2
(
treeData1
);
set
UserID
(
record
.
userID
);
set
CurrentUser
(
record
);
};
const
changePassword
=
record
=>
{
setPasswordVisible
(
true
);
passwordForm
.
setFieldsValue
({
oldpassword
:
record
.
password
,
});
set
UserID
(
record
.
userID
);
set
CurrentUser
(
record
);
};
const
editUser
=
record
=>
{
// console.log(record);
...
...
@@ -375,15 +373,15 @@ const UserManage = () => {
phone
:
record
.
phone
||
''
,
email
:
record
.
email
||
''
,
});
set
UserID
(
record
.
userID
);
set
CurrentUser
(
record
);
};
const
freezeUser
=
record
=>
{
setFreezeUserVisible
(
true
);
set
UserID
(
record
.
userID
);
set
CurrentUser
(
record
);
};
const
deleteUser
=
record
=>
{
setDeleteUserVisible
(
true
);
set
UserID
(
record
.
userID
);
set
CurrentUser
(
record
);
};
// 查找用户
const
submitSearchUser
=
()
=>
{
...
...
@@ -406,7 +404,7 @@ const UserManage = () => {
};
// 提交-添加用户
const
submitAddUser
=
()
=>
{
a
ddUser
({
postA
ddUser
({
OUID
:
orgID
,
loginName
:
addUserForm
.
getFieldValue
(
'loginName'
),
userName
:
addUserForm
.
getFieldValue
(
'userName'
),
...
...
@@ -514,7 +512,7 @@ const UserManage = () => {
const
getRoleList
=
()
=>
{
setLoading
(
true
);
getUserRelationList
(
userID
)
getUserRelationList
(
currentUser
.
userID
)
.
then
(
res
=>
{
setLoading
(
false
);
if
(
res
.
success
)
{
...
...
@@ -535,7 +533,7 @@ const UserManage = () => {
});
};
const
submitRole
=
()
=>
{
addToOrg
(
userID
,
orgID
,
newOrgID
)
addToOrg
(
currentUser
.
userID
,
orgID
,
newOrgID
)
.
then
(
res
=>
{
if
(
res
.
success
)
{
setChangeOrgVisible
(
false
);
...
...
@@ -556,7 +554,7 @@ const UserManage = () => {
});
};
const
submitChangeOrg
=
()
=>
addToOrg
(
userID
,
orgID
,
newOrgID
)
addToOrg
(
currentUser
.
userID
,
orgID
,
newOrgID
)
.
then
(
res
=>
{
if
(
res
.
success
)
{
setChangeOrgVisible
(
false
);
...
...
@@ -577,7 +575,7 @@ const UserManage = () => {
});
const
submitChangePassword
=
()
=>
updateUserPassword
(
userID
,
currentUser
.
userID
,
passwordForm
.
getFieldValue
(
'password'
),
passwordForm
.
getFieldValue
(
'newPassword'
),
passwordForm
.
getFieldValue
(
'passwordConfirm'
),
...
...
@@ -601,8 +599,8 @@ const UserManage = () => {
message
.
error
(
err
);
});
const
submitEditUser
=
()
=>
e
ditUser
(
userID
,
postE
ditUser
(
currentUser
.
userID
,
editUserForm
.
getFieldValue
(
'loginName'
),
editUserForm
.
getFieldValue
(
'userName'
),
editUserForm
.
getFieldValue
(
'phone'
)
||
''
,
...
...
@@ -628,7 +626,7 @@ const UserManage = () => {
message
.
error
(
err
);
});
const
submitFreezeUser
=
()
=>
{
setUserState
(
userID
,
+!
userS
tate
)
postSetUserState
(
currentUser
.
userID
,
+!
currentUser
.
s
tate
)
.
then
(
res
=>
{
if
(
res
.
success
)
{
setFreezeUserVisible
(
false
);
...
...
@@ -637,7 +635,6 @@ const UserManage = () => {
notification
.
success
({
message
:
'提交成功'
,
});
setUserState
(
+!
userState
);
}
else
{
notification
.
error
({
message
:
'提交失败'
,
...
...
@@ -651,7 +648,7 @@ const UserManage = () => {
});
};
const
submitDeleteUser
=
()
=>
{
deleteUser
(
userID
)
postDeleteUser
(
currentUser
.
userID
)
.
then
(
res
=>
{
if
(
res
.
success
)
{
setDeleteUserVisible
(
false
);
...
...
@@ -702,7 +699,7 @@ const UserManage = () => {
showLine
=
"true"
showIcon
=
"true"
defaultExpandAll
=
"true"
selectedKeys
=
{[
currentSelect
]}
selectedKeys
=
{[
currentSelect
Org
]}
loading
=
{
treeLoading
}
onSelect
=
{
onSelect
}
treeData
=
{
treeData
.
map
(
t
=>
mapTree
(
t
))}
...
...
@@ -919,22 +916,23 @@ const UserManage = () => {
cancelText
=
"取消"
width
=
"330px"
>
{
treeData2
.
length
>
0
&&
(
<
span
>
请选择要更改的目标机构:
<
/span
>
{
changeOrgVisible
&&
treeData2
.
length
>
0
&&
(
<
Tree
showLine
=
"true"
showIcon
=
"true"
defaultExpandAll
=
"true"
// selectedKeys={[currentSelect
]}
defaultSelectedKeys
=
{[
currentSelectOrg
]}
onSelect
=
{
props
=>
{
setNewOrgID
(
props
[
0
]);
}}
treeData
=
{
mapTree1
(
treeData2
)}
treeData
=
{
treeData2
.
map
(
t
=>
mapTree1
(
t
)
)}
/
>
)}
<
/Modal
>
{
/* 修改密码 */
}
<
Modal
title
=
"
编辑用户
"
title
=
"
修改密码
"
visible
=
{
passwordVisible
}
onOk
=
{
submitChangePassword
}
onCancel
=
{()
=>
setPasswordVisible
(
false
)}
...
...
@@ -1017,7 +1015,12 @@ const UserManage = () => {
okText
=
"确认"
cancelText
=
"取消"
>
<
p
>
{
freezeText
}
<
/p
>
<
p
>
即将
{
+
currentUser
.
state
?
'激活'
:
'冻结'
}
用户
{
' '
}
<
span
className
=
{
styles
.
redText
}
>
{
currentUser
.
userName
}
<
/span
>
,是否确认
{
+
currentUser
.
state
?
'激活'
:
'冻结'
}
?
<
/p
>
<
/Modal
>
<
Modal
title
=
"确认删除用户"
...
...
@@ -1027,7 +1030,11 @@ const UserManage = () => {
okText
=
"确认"
cancelText
=
"取消"
>
<
p
>
即将关联删除
主站点
用户关系,是否确认删除?
<
/p
>
<
p
>
将删除用户
<
span
className
=
{
styles
.
redText
}
>
{
currentUser
.
userName
}
<
/span>
,
是否确认删除?
<
/p
>
<
/Modal
>
<
/div
>
<
/PageContainer
>
...
...
src/pages/userCenter/UserManage.less
View file @
97edfa8c
.redText{
color: red;
cursor: pointer;
}
.userManageContainer{
.ant-tree-treenode{
width: 100% !important;
...
...
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