import store from '../store' /** * 判断是否有权限 */ export function hasPermission(permission) { const btns = store.getters.btns return btns.some(btn => { // 遍历btns,查找btn.url是否有匹配的permission,有则返回true,否则返回false return btn.url === permission }) } // 根据用户权限判断是否要显示井类型下拉框 export function showWellType() { console.log('是否显示井类型下拉') const wellTypes = store.getters.wellTypes if (wellTypes.length > 1) return true else return false } // 根据用户权限判断是否要显示设备类型下拉框 export function showDeviceType() { const deviceTypes = store.getters.deviceTypes if (deviceTypes.length > 1) return true else return false } // 根据用户权限判断是否要显示IP配置项,集中器不显示ip export function showIpConfig() { const communications = store.getters.communications return communications.some(communication => { // 遍历通讯方式,只要没有1(集中器)就是返回true return communication !== '1' }) } export function notContainConcentrator() { const communications = store.getters.communications return communications.some(communication => { // 遍历通讯方式,只要有1(集中器)就是返回true return communication === '1' }) } // 判断用户是否为运维人员或其他管理员 export function isOperation() { const roleTips = store.getters.roleTips return roleTips.some(tip => { // 遍历btns,查找btn.url是否有匹配的permission,有则返回true,否则返回false return (tip === 'operation' || tip === 'administrator') }) }