dataease-dm/frontend/src/utils/permission.js
2021-06-11 14:04:30 +08:00

20 lines
461 B
JavaScript

import store from '@/store'
export function checkPermission(pers) {
const permissions = store.getters.permissions
const hasPermission = pers.every(needP => {
const result = permissions.includes(needP)
return result
})
return hasPermission
}
export function hasDataPermission(pTarget, pSource) {
if (store.state.user.user.isAdmin) {
return true
}
if (pSource && pTarget) {
return pSource.indexOf(pTarget) > -1
}
return false
}