1234567891011121314151617181920212223242526272829 |
- /**
- * 按钮权限验证
- * uni中使用vue自定义指令报错
- * @author yxk
- */
- import store from '../store'
- import { deepCopy } from '../utils/lib.js'
- /**
- * 权限验证
- * @param {String} action 权限动作 eg: crm.leads.delete
- */
- export default function check_permission(action) {
- if (!action) return true
- let authData = deepCopy(store.state.user.authData || null)
- if (!authData) return false
- const arr = action.split('.')
- if (arr.length === 0) return true
- for (let i = 0; i < arr.length; i++) {
- const key = arr[i]
- authData = authData[key]
- if (!authData) {
- return false
- } else if (arr.length - 1 === i) {
- return true
- }
- }
- }
|