21 lines
649 B
JavaScript
21 lines
649 B
JavaScript
import { usePermissionStore } from '@/store/permission';
|
|
|
|
export default {
|
|
checkPermission(el, binding) {
|
|
const store = usePermissionStore();
|
|
const { value } = binding;
|
|
const permissions = store.buttonPermissions;
|
|
const all_permission = '*'
|
|
if (typeof value === 'string' && permissions && permissions.length>0) {
|
|
const hasPermission = permissions.some((permission) => {
|
|
return all_permission==permission || value === permission;
|
|
})
|
|
|
|
if (!hasPermission) {
|
|
el.parentNode && el.parentNode.removeChild(el);
|
|
}
|
|
} else {
|
|
throw new Error(`请设置操作权限标签值`)
|
|
}
|
|
}
|
|
} |