/** * 权限控制按钮显示指令 * @params {Array[String,Boolean]} [权限code码,其他控制条件] */ Vue.directive('haspms', { inserted: function(el, binding) { if (!permissionJudge(binding.value)) { el.parentNode.removeChild(el) } function permissionJudge(value) { let [code,otherFlag=true] = value const list = Store.getters.user.permissionCodeList const hasPms = list.includes(code) return hasPms && otherFlag } } })
使用如下:
<el-button type="primary" size="small" @click="openTransDialog" v-haspms="['YW.AC.GJZFP',scope.row.status === 3]"> 分配 </el-button>