You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
import { Directive, DirectiveBinding } from 'vue';
|
|
|
|
|
import { useUserStore } from "@/store/modules/user";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 按钮权限
|
|
|
|
|
*/
|
|
|
|
|
export const hasButton: Directive = {
|
|
|
|
|
mounted(el: HTMLElement, binding: DirectiveBinding) {
|
|
|
|
|
const userStore = useUserStore();
|
|
|
|
|
const { value } = binding;
|
|
|
|
|
// console.log("按钮权限",el,"-->",binding,"-->",value,"-->",userStore.myPower.menuButIdAry,"-->",userStore.myPower);
|
|
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
|
const requiredPerms = value; // DOM绑定需要的按钮权限标识
|
|
|
|
|
const hasPerm = userStore.myPower.menuButIdAry.some((perm: any) => {
|
|
|
|
|
return requiredPerms.includes(perm);
|
|
|
|
|
});
|
|
|
|
|
if (!hasPerm) {
|
|
|
|
|
el.parentNode?.removeChild(el);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|