提交 | 用户 | 时间
|
fd2207
|
1 |
/** |
懒 |
2 |
* v-hasPermi 操作权限处理 |
|
3 |
* Copyright (c) 2019 ruoyi |
|
4 |
*/ |
|
5 |
|
|
6 |
import store from '@/store' |
|
7 |
|
|
8 |
export default { |
|
9 |
inserted(el, binding, vnode) { |
|
10 |
const { value } = binding |
|
11 |
const all_permission = "*:*:*"; |
|
12 |
const permissions = store.getters && store.getters.permissions |
|
13 |
|
|
14 |
if (value && value instanceof Array && value.length > 0) { |
|
15 |
const permissionFlag = value |
|
16 |
|
|
17 |
const hasPermissions = permissions.some(permission => { |
|
18 |
return all_permission === permission || permissionFlag.includes(permission) |
|
19 |
}) |
|
20 |
|
|
21 |
if (!hasPermissions) { |
|
22 |
el.parentNode && el.parentNode.removeChild(el) |
|
23 |
} |
|
24 |
} else { |
|
25 |
throw new Error(`请设置操作权限标签值`) |
|
26 |
} |
|
27 |
} |
|
28 |
} |