Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
TOSTUMI
Project
Project
Details
Activity
Releases
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
Maple
TOSTUMI
Commits
e695c59c
Commit
e695c59c
authored
Dec 21, 2020
by
cellee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决权限模块大栏目与小栏目选择多带或者少带问题。
Signed-off-by:
cellee
<
893264950@qq.com
>
parent
7f401616
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
12 deletions
+31
-12
AccountEdit.tsx
src/pages/AccountManagement/account/AccountEdit.tsx
+31
-12
No files found.
src/pages/AccountManagement/account/AccountEdit.tsx
View file @
e695c59c
import
React
,
{
useState
,
useEffect
,
useRef
}
from
'react'
;
import
React
,
{
useState
,
useEffect
,
useRef
}
from
'react'
;
import
{
Form
,
Input
,
Button
,
Spin
,
message
,
Descriptions
,
Modal
,
Tree
,
Radio
}
from
'antd'
;
import
{
Form
,
Input
,
Button
,
Spin
,
message
,
Descriptions
,
Tree
,
Radio
}
from
'antd'
;
import
{
connect
,
history
}
from
'umi'
;
import
{
connect
,
history
}
from
'umi'
;
import
{
SearchOutlined
,
PoweroffOutlined
,
EditOutlined
,
LeftOutlined
}
from
'@ant-design/icons'
;
import
{
EditOutlined
,
LeftOutlined
}
from
'@ant-design/icons'
;
import
{
getCookie
}
from
'@/utils/method'
;
import
{
getCookie
}
from
'@/utils/method'
;
import
'./Account.less'
;
import
'./Account.less'
;
...
@@ -12,8 +12,6 @@ import SelectCommunity from '@/components/SelectCommunity';
...
@@ -12,8 +12,6 @@ import SelectCommunity from '@/components/SelectCommunity';
import
{
getNumber
}
from
'@/utils/string'
;
// 正则
import
{
getNumber
}
from
'@/utils/string'
;
// 正则
import
{
RA
}
from
'@/utils/method'
;
import
{
RA
}
from
'@/utils/method'
;
import
moment
from
'moment'
;
const
Account
=
(
props
:
any
)
=>
{
const
Account
=
(
props
:
any
)
=>
{
const
module
=
'Account'
;
const
module
=
'Account'
;
...
@@ -24,7 +22,7 @@ const Account = (props: any) => {
...
@@ -24,7 +22,7 @@ const Account = (props: any) => {
const
[
expandedKeys
,
setExpandedKeys
]
=
useState
<
string
[]
>
([]);
// 展开栏目
const
[
expandedKeys
,
setExpandedKeys
]
=
useState
<
string
[]
>
([]);
// 展开栏目
const
[
checkedKeys
,
setCheckedKeys
]
=
useState
<
string
[]
>
([]);
// 默认已选栏目
const
[
checkedKeys
,
setCheckedKeys
]
=
useState
<
string
[]
>
([]);
// 默认已选栏目
const
[
selectedKeys
,
setSelectedKeys
]
=
useState
<
string
[]
>
([]);
// 设置选中的树节点
const
[
selectedKeys
,
setSelectedKeys
]
=
useState
<
string
[]
>
([]);
// 设置选中的树
大
节点
const
[
autoExpandParent
,
setAutoExpandParent
]
=
useState
<
boolean
>
(
true
);
// 树形菜单展开关闭
const
[
autoExpandParent
,
setAutoExpandParent
]
=
useState
<
boolean
>
(
true
);
// 树形菜单展开关闭
// 单选 二级还是三级管理员
// 单选 二级还是三级管理员
...
@@ -64,10 +62,6 @@ const Account = (props: any) => {
...
@@ -64,10 +62,6 @@ const Account = (props: any) => {
let
_a
=
user
.
currentUser
.
permission
;
// 当前账户权限
let
_a
=
user
.
currentUser
.
permission
;
// 当前账户权限
let
_p
=
treeDatas
[
0
].
children
;
// 所有权限列表
let
_p
=
treeDatas
[
0
].
children
;
// 所有权限列表
for
(
let
i
in
_p
)
{
console
.
log
(
_p
[
i
].
key
);
}
let
arr
:
any
=
[];
// 一级栏目权限
let
arr
:
any
=
[];
// 一级栏目权限
let
erArr
:
any
=
[];
// 一级栏目权限
let
erArr
:
any
=
[];
// 一级栏目权限
// 循环一级 判断当前账户有没有权限修改增加
// 循环一级 判断当前账户有没有权限修改增加
...
@@ -86,8 +80,6 @@ const Account = (props: any) => {
...
@@ -86,8 +80,6 @@ const Account = (props: any) => {
}
}
}
}
}
}
console
.
log
(
_p
);
// 赋值改变
// 赋值改变
treeDatas
[
0
].
children
=
_p
;
treeDatas
[
0
].
children
=
_p
;
setCheckedKeys
(
treeDatas
as
any
);
// 可勾选列表
setCheckedKeys
(
treeDatas
as
any
);
// 可勾选列表
...
@@ -98,10 +90,37 @@ const Account = (props: any) => {
...
@@ -98,10 +90,37 @@ const Account = (props: any) => {
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
Permission
!=
null
)
{
if
(
Permission
!=
null
)
{
let
newPer
=
eval
(
'('
+
Permission
+
')'
);
let
newPer
=
eval
(
'('
+
Permission
+
')'
);
let
data
:
any
=
[];
let
data
:
any
=
[];
// 编辑的账户的权限
for
(
let
i
in
newPer
)
{
for
(
let
i
in
newPer
)
{
data
[
i
]
=
newPer
[
i
]
+
''
;
data
[
i
]
=
newPer
[
i
]
+
''
;
}
}
// console.log(data); // 编辑的账户的权限
let
_p
=
treeData
[
0
].
children
;
// 所有权限列表
// console.log(_p); // 所有权限列表
for
(
let
i
in
_p
)
{
let
arr
=
_p
[
i
].
children
;
// 每个权限
let
newArr
=
[];
// 每个权限下的子权限列表
for
(
let
j
in
arr
)
{
newArr
.
push
(
arr
[
j
].
key
);
}
// console.log(newArr);
if
(
!
newArr
.
every
((
val
)
=>
data
.
includes
(
val
)))
{
// 判断数组是否包含另一个数组
// console.log('不包含' + _p[i].key);
// 不全部包含就删除数组的元素
var
index
=
data
.
indexOf
(
_p
[
i
].
key
);
if
(
index
>
-
1
)
{
data
.
splice
(
index
,
1
);
}
}
else
{
// console.log('包含' + _p[i].key);
}
}
// console.log(data);
// 再赋值给列表
setCheckedKeys
(
data
);
setCheckedKeys
(
data
);
}
}
},
[
Permission
]);
},
[
Permission
]);
...
...
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