code init

This commit is contained in:
chenxiaoxi
2021-05-25 18:06:45 +08:00
parent 02698d6dab
commit f54a8d4fa1
1367 changed files with 540755 additions and 21713 deletions
+59
View File
@@ -0,0 +1,59 @@
/**
* @description: 按钮级权限
* @author: liuyan
*/
import Vue from 'vue'
import store from '@/store'
const btnPermission = Vue.directive('btnPermission', {
bind (el, binding, vnode) {
// 获取按钮权限
let btnPermission = binding.value
// 没有这个权限则移除
if (!Vue.prototype.$_has(btnPermission)) {
Vue.nextTick(() => {
el.parentNode.removeChild(el)
})
}
}
})
const tableBtnPermission = Vue.directive('tableBtnPermission', {
bind (el, binding, vnode) {
// 获取按钮权限
let btnPermission = binding.value
console.log(el, binding, vnode)
function handler(event) {
console.log(event)
event.stopImmediatePropagation()
return false
}
el.addEventListener('click', handler, true)
// 没有这个权限则移除
// if (!Vue.prototype.$_has(btnPermission)) {
// Vue.nextTick(() => {
// el.parentNode.removeChild(el)
// })
// }
}
})
// 权限检查方法
Vue.prototype.$_has = function (value) {
let has = false
let menuList = store.getters.getMenuList
if (menuList === '') {
return false
} else {
menuList.map((menu) => {
if (menu.id === value || value === undefined || value === '') {
has = true
}
})
}
return has
}
export {
btnPermission
}