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
0639e6ec
Commit
0639e6ec
authored
Dec 08, 2020
by
陈前坚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: 角色全选/全不选
parent
d14f9c98
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletion
+29
-1
index.jsx
src/components/CheckGroup/index.jsx
+28
-1
UserManage.less
src/pages/userCenter/UserManage.less
+1
-0
No files found.
src/components/CheckGroup/index.jsx
View file @
0639e6ec
import
React
,
{
useState
,
useEffect
}
from
'react'
;
import
React
,
{
useState
,
useEffect
}
from
'react'
;
import
{
Spin
,
Button
,
Empty
}
from
'antd'
;
import
{
Spin
,
Checkbox
,
Button
,
Empty
}
from
'antd'
;
import
_
from
'lodash'
;
import
_
from
'lodash'
;
import
ListCardItem
from
'./ItemCard'
;
import
ListCardItem
from
'./ItemCard'
;
import
styles
from
'./ItemCard.less'
;
import
styles
from
'./ItemCard.less'
;
...
@@ -60,6 +60,32 @@ const ListCard = props => {
...
@@ -60,6 +60,32 @@ const ListCard = props => {
// console.timeEnd('updateValueList:');
// console.timeEnd('updateValueList:');
};
};
const
checkAll
=
e
=>
{
if
(
e
.
target
.
checked
)
{
const
result
=
dataList
.
map
(
item
=>
getAllID
(
item
)).
flat
(
Infinity
);
setValueList
(
result
);
// eslint-disable-next-line no-unused-expressions
onChange
&&
onChange
(
result
);
}
else
{
setValueList
([]);
// eslint-disable-next-line no-unused-expressions
onChange
&&
onChange
([]);
}
};
const
getAllID
=
item
=>
{
let
result
=
[];
const
haveChildren
=
Array
.
isArray
(
item
.
children
)
&&
item
.
children
.
length
>
0
;
// 统一使用 getId
result
.
push
(
getId
(
item
));
if
(
haveChildren
)
{
// 每次递归result被置空,所以要另外保存
result
=
[...
item
.
children
.
map
(
i
=>
getAllID
(
i
)),
...
result
];
}
return
result
;
};
return
(
return
(
<
div
>
<
div
>
{
loading
?
(
{
loading
?
(
...
@@ -77,6 +103,7 @@ const ListCard = props => {
...
@@ -77,6 +103,7 @@ const ListCard = props => {
/>
/>
)
:
(
)
:
(
<>
<>
<
Checkbox
onChange=
{
checkAll
}
>
全选/全不选
</
Checkbox
>
{
dataList
&&
dataList
.
length
>
0
?
(
{
dataList
&&
dataList
.
length
>
0
?
(
dataList
dataList
.
filter
(
d
=>
d
.
type
===
'widgetGroup'
||
'widget'
)
.
filter
(
d
=>
d
.
type
===
'widgetGroup'
||
'widget'
)
...
...
src/pages/userCenter/UserManage.less
View file @
0639e6ec
...
@@ -185,6 +185,7 @@
...
@@ -185,6 +185,7 @@
.ant-tree-switcher{
.ant-tree-switcher{
line-height: 1;
line-height: 1;
color:#1890FF;
color:#1890FF;
margin-right: 0px !important;
}
}
.ant-checkbox-group .ant-checkbox-group-item {
.ant-checkbox-group .ant-checkbox-group-item {
margin-right: 0px !important;
margin-right: 0px !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