Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-4
Overview
Overview
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
office
haoban-4
Commits
6f552b41
Commit
6f552b41
authored
Aug 13, 2020
by
无尘
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修改管理员角色菜单
parent
13744cef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
16 deletions
+35
-16
vue-office-header.vue
src/components/vue-office-header.vue
+13
-2
edit-role.vue
src/views/enterprise/edit-role.vue
+22
-14
No files found.
src/components/vue-office-header.vue
View file @
6f552b41
...
...
@@ -124,12 +124,23 @@ export default {
}
}
else
{
that
.
setleftData
(
menuItem
);
that
.
$router
.
push
(
menuItem
.
menuUrl
);
let
childRoute
=
{};
that
.
roleMenuData
.
forEach
(
ele
=>
{
// 如果第一层级下没有菜单,直接跳转
if
(
menuItem
.
menuCode
==
ele
.
menuCode
&&
!
ele
.
children
.
length
)
{
childRoute
=
ele
;
}
// 如果第一层级下有菜单,就需要跳转第一层的url
if
(
menuItem
.
menuCode
==
ele
.
menuCode
&&
ele
.
children
.
length
)
{
childRoute
=
ele
.
children
[
0
];
}
})
that
.
$router
.
push
(
childRoute
.
menuUrl
);
}
},
setleftData
(
menuItem
)
{
const
that
=
this
;
let
arr
=
[]
let
arr
=
[]
;
that
.
roleMenuData
.
forEach
(
ele
=>
{
if
(
menuItem
.
menuCode
==
ele
.
menuCode
)
{
arr
.
push
(
ele
);
...
...
src/views/enterprise/edit-role.vue
View file @
6f552b41
...
...
@@ -147,7 +147,7 @@ export default {
if
(
allMenuIds
.
some
(
item
=>
item
==
el
.
menuId
))
{
let
allSubId
=
[];
if
(
Array
.
isArray
(
el
.
children
))
{
allSubId
=
getAllSubMenuIds
(
el
.
children
);
allSubId
=
el
.
children
.
map
(
item
=>
item
.
menuId
);
}
// 如果el的allSubId都在allMenuIds中,则认为el需要被勾选,需要把el.menuId放入result中
if
(
allSubId
.
length
==
0
||
allSubId
.
every
(
el
=>
allMenuIds
.
some
(
item
=>
item
==
el
)))
{
...
...
@@ -160,16 +160,6 @@ export default {
})
return
result
;
}
function
getAllSubMenuIds
(
menuList
)
{
let
result
=
[];
menuList
.
forEach
(
el
=>
{
result
.
push
(
el
.
menuId
);
if
(
Array
.
isArray
(
el
.
children
))
{
result
=
result
.
concat
(
getAllSubMenuIds
(
el
.
children
));
}
})
return
result
;
}
},
// 将平铺的数据转为树形结构
flatDataToTree
(
data
)
{
...
...
@@ -195,24 +185,42 @@ export default {
// 同时更新roleData中menuIds的数据
onCheckedChange
(
checkedId
)
{
let
menuIds
=
[];
let
flatMenu
=
[];
let
allMenuIds
=
[];
for
(
let
key
in
checkedId
)
{
menuIds
=
menuIds
.
concat
(
checkedId
[
key
]);
}
this
.
tabList
=
this
.
tabList
.
map
(
el
=>
{
if
(
el
.
appType
==
this
.
activeType
)
{
el
.
checkedId
=
checkedId
;
flatMenu
=
el
.
flatMenu
;
}
return
el
;
})
// 根据选择的菜单,设置对应选择的 ids
// 根据任意层级的子节点向上查找全部的父节点,存入allMenuIds中,然后过滤掉重复的menuId
menuIds
.
map
(
el
=>
{
allMenuIds
=
allMenuIds
.
concat
(
getParentIds
(
el
,
flatMenu
));
})
allMenuIds
=
allMenuIds
.
filter
((
el
,
index
)
=>
index
==
allMenuIds
.
findIndex
(
item
=>
item
==
el
));
if
(
this
.
roleData
.
menuIds
.
some
(
el
=>
el
.
appType
==
this
.
activeType
))
{
this
.
roleData
.
menuIds
.
forEach
(
el
=>
{
if
(
el
.
appType
==
this
.
activeType
)
{
el
.
menuIds
=
m
enuIds
;
el
.
menuIds
=
allM
enuIds
;
}
})
}
else
{
this
.
roleData
.
menuIds
.
push
({
appType
:
this
.
activeType
,
menuIds
:
menuIds
});
this
.
roleData
.
menuIds
.
push
({
appType
:
this
.
activeType
,
menuIds
:
allMenuIds
});
}
function
getParentIds
(
menuId
,
menuList
)
{
let
result
=
[
menuId
];
menuList
.
some
(
el
=>
{
if
(
el
.
menuId
==
menuId
&&
el
.
parentId
>
0
)
{
result
=
result
.
concat
(
getParentIds
(
el
.
parentId
,
menuList
));
}
return
el
.
menuId
==
menuId
;
})
return
result
;
}
},
// 新建、编辑角色的保存
...
...
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