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
3631a794
Commit
3631a794
authored
Aug 07, 2020
by
caoyanzhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
权限控制
parent
cfe1690f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
15 deletions
+24
-15
main.js
src/main.js
+14
-5
permission.js
src/utils/permission.js
+5
-5
edit-role.vue
src/views/enterprise/edit-role.vue
+3
-3
edit-store-role.vue
src/views/enterprise/edit-store-role.vue
+2
-2
No files found.
src/main.js
View file @
3631a794
...
...
@@ -17,13 +17,14 @@ import axios from 'axios';
import
ElementUI
from
'element-ui'
;
import
App
from
'./App.vue'
;
import
router
from
'./router'
;
import
{
routes
}
from
'./router/routes.js'
;
import
filters
from
'@/filters/index.js'
;
// import { isRequest, itemCode } from '@/config';
// eslint-disable-next-line
import
{
permission
,
itemPerm
}
from
'@/utils/permission.js'
;
Vue
.
use
(
VueRouter
);
Vue
.
use
(
ElementUI
);
// 请求头这种添加请求标识
// Object.assign(axios.defaults.headers.common, isRequest);
axios
.
defaults
.
withCredentials
=
true
;
Vue
.
prototype
.
axios
=
axios
;
...
...
@@ -37,8 +38,16 @@ Vue.config.productionTip = false;
Object
.
keys
(
filters
).
forEach
(
key
=>
{
Vue
.
filter
(
key
,
filters
[
key
]);
});
new
Vue
({
permission
({
whiteRoute
:
[
'/login'
,
'/gic-error'
,
'/403'
,
'/404'
,
'/500'
],
router
,
routes
,
createApp
()
{
new
Vue
({
router
,
render
:
h
=>
h
(
App
)
}).
$mount
(
'#app'
)
}).
$mount
(
'#app'
)
}
});
src/utils/permission.js
View file @
3631a794
...
...
@@ -9,10 +9,10 @@ let accessPath = [];
let
itemPermission
=
{};
function
getGicMenu
()
{
const
getUserMenu
=
request
({
url
:
'/hb-manage-web/
list-menus-auth
'
}).
then
(
res
=>
{
const
getUserMenu
=
request
({
url
:
'/hb-manage-web/
/list-staff-role-menu
'
}).
then
(
res
=>
{
accessPath
=
getProjectMenu
(
res
.
result
||
[]);
});
const
getUserOperation
=
request
({
url
:
'/hb-manage-web/list-
operation-auth
'
}).
then
(
res
=>
{
const
getUserOperation
=
request
({
url
:
'/hb-manage-web/list-
staff-role-opeation
'
}).
then
(
res
=>
{
itemPermission
=
getItemPerm
(
res
.
result
||
[]);
})
return
Promise
.
all
([
getUserMenu
,
getUserOperation
]);
...
...
@@ -75,7 +75,7 @@ function itemPerm(itemPermCode) {
}
let
permission
=
function
(
config
)
{
const
{
w
r
iteRoute
,
router
,
routes
,
createApp
}
=
config
;
const
{
w
h
iteRoute
,
router
,
routes
,
createApp
}
=
config
;
window
.
onload
=
async
function
()
{
// 获取菜单数据
...
...
@@ -84,8 +84,8 @@ let permission = function(config) {
if
(
path
.
indexOf
(
'/login'
)
==
-
1
)
{
await
getGicMenu
();
}
if
(
Array
.
isArray
(
w
r
iteRoute
))
{
accessPath
=
accessPath
.
concat
(
w
r
iteRoute
);
if
(
Array
.
isArray
(
w
h
iteRoute
))
{
accessPath
=
accessPath
.
concat
(
w
h
iteRoute
);
}
if
(
Array
.
isArray
(
routes
))
{
// 项目中路由文件配置的路径
...
...
src/views/enterprise/edit-role.vue
View file @
3631a794
...
...
@@ -100,7 +100,7 @@ export default {
// appType 1好办后台2应用后台3好办小程序4小程序应用
// roleType 1管理员角色 2门店角色
prom
.
push
(
menuList
(
Object
.
assign
({},
params
,
{
appType
:
el
.
appType
,
roleType
:
1
})).
then
(
res
=>
{
el
.
menuList
=
res
.
result
||
[]
;
el
.
menuList
=
this
.
flatDataToTree
(
res
.
result
||
[])
;
el
.
menuList
.
forEach
(
item
=>
{
this
.
$set
(
el
.
checkedId
,
item
.
menuId
,
[]);
});
...
...
@@ -141,11 +141,11 @@ export default {
flatDataToTree
(
data
)
{
return
data
.
filter
(
el
=>
{
// 返回当前节点下的子节点
const
children
=
data
.
filter
(
item
=>
item
.
parent
Id
==
el
.
menuId
);
const
children
=
data
.
filter
(
item
=>
item
.
parent
Code
==
el
.
menuCode
);
if
(
children
.
length
>
0
)
{
el
.
children
=
children
;
// 如果存在子级,则给父级添加一个children属性,并赋值
}
return
el
.
parent
Id
==
0
;
return
el
.
parent
Code
==
''
;
})
},
getActiveMenuList
()
{
...
...
src/views/enterprise/edit-store-role.vue
View file @
3631a794
...
...
@@ -173,11 +173,11 @@ export default {
flatDataToTree
(
data
)
{
return
data
.
filter
(
el
=>
{
// 返回当前节点下的子节点
const
children
=
data
.
filter
(
item
=>
item
.
parent
Id
==
el
.
menuId
);
const
children
=
data
.
filter
(
item
=>
item
.
parent
Code
==
el
.
menuCode
);
if
(
children
.
length
>
0
)
{
el
.
children
=
children
;
// 如果存在子级,则给父级添加一个children属性,并赋值
}
return
el
.
parent
Id
==
0
;
return
el
.
parent
Code
==
''
;
})
},
// 保存选中的子节点id
...
...
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