/**
  * 操作权限处理
  */

 import store from '../../store'
let modules = {};

modules = {
   inserted(el, binding, vnode) {
     let value = binding.value;
     let dispermissions = store.getters && store.getters.dispermissions;

     if (value && value instanceof Array && value.length > 0) {
       let permissionFlag = value;

       let hasNotPermissions = value.some(item => {
         return dispermissions.includes(item);
       });

       if (hasNotPermissions) {
         el.parentNode && el.parentNode.removeChild(el);
       }
     } else if (value && typeof(value) == 'string') {
       let permissionFlag = value;
       if (dispermissions.includes(permissionFlag)) {
         el.parentNode && el.parentNode.removeChild(el);
       }
     } else {
       throw new Error(`请设置操作权限标签值`);
     }
   }
 }

 export default modules
