init : 初始化仓库
This commit is contained in:
20
src/directives/fixedtableheight.js
Normal file
20
src/directives/fixedtableheight.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { useDebounce } from "../utils/publicvoid"
|
||||
|
||||
let dom
|
||||
export const fixedHeight = (el, binding, vnode) => {
|
||||
dom = el
|
||||
// 获取相对距离
|
||||
const relativeObj = el.getBoundingClientRect()
|
||||
// 获取网页高度
|
||||
const clientHeight = document.body.clientHeight
|
||||
// 70为分页器高度
|
||||
el.style.height = (clientHeight - relativeObj.top - 70) + 'px'
|
||||
el.style.overflow = 'auto'
|
||||
}
|
||||
|
||||
window.addEventListener('resize', () => {
|
||||
if (dom) {
|
||||
const resizeHeight = useDebounce(fixedHeight(dom), 2000, false)
|
||||
resizeHeight()
|
||||
}
|
||||
})
|
||||
20
src/directives/permission.js
Normal file
20
src/directives/permission.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { useAuthStore } from '@/stores/userstore.js'
|
||||
|
||||
export const hasPerm = (el, binding, vnode) => {
|
||||
const authStore = useAuthStore()
|
||||
const allPermission = "*:*:*"; //所有权限
|
||||
const { value } = binding
|
||||
const permisstions = authStore.permisstions
|
||||
if (value && value instanceof Array && value.length > 0) {
|
||||
const permissiosFlag = value
|
||||
const hasPermission = permisstions.some(permission => {
|
||||
return allPermission === permission || permissiosFlag.includes(permission)
|
||||
})
|
||||
console.log(hasPermission);
|
||||
if (!hasPermission) {
|
||||
el.parentNode && el.parentNode.removeChild(el)
|
||||
}
|
||||
} else {
|
||||
throw new Error('操作权限标识应为string[]')
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user