diff --git a/src/main.js b/src/main.js index f03cf5b..1e1939d 100644 --- a/src/main.js +++ b/src/main.js @@ -27,13 +27,15 @@ import 'babel-polyfill' // import '../mock' // simulation data -import { hasPermission, showWellType, showDeviceType, showIpConfig, isOperation } from './utils/permission' +import { hasPermission, showWellType, showDeviceType, showIpConfig, isOperation, isAdministrator } from './utils/permission' Vue.prototype.hasPerm = hasPermission Vue.prototype.showWellType = showWellType Vue.prototype.showDeviceType = showDeviceType Vue.prototype.showIpConfig = showIpConfig Vue.prototype.isOperation = isOperation +Vue.prototype.isAdmin = isAdministrator + // 引入Element-ui Vue.use(ElementUI, { locale }) diff --git a/src/main.js b/src/main.js index f03cf5b..1e1939d 100644 --- a/src/main.js +++ b/src/main.js @@ -27,13 +27,15 @@ import 'babel-polyfill' // import '../mock' // simulation data -import { hasPermission, showWellType, showDeviceType, showIpConfig, isOperation } from './utils/permission' +import { hasPermission, showWellType, showDeviceType, showIpConfig, isOperation, isAdministrator } from './utils/permission' Vue.prototype.hasPerm = hasPermission Vue.prototype.showWellType = showWellType Vue.prototype.showDeviceType = showDeviceType Vue.prototype.showIpConfig = showIpConfig Vue.prototype.isOperation = isOperation +Vue.prototype.isAdmin = isAdministrator + // 引入Element-ui Vue.use(ElementUI, { locale }) diff --git a/src/utils/permission.js b/src/utils/permission.js index 8fee27f..244155d 100644 --- a/src/utils/permission.js +++ b/src/utils/permission.js @@ -42,3 +42,10 @@ return (tip === 'operation' || tip === 'administrator') }) } +// 判断用户是否为运维人员或其他管理员 +export function isAdministrator() { + const roleTips = store.getters.roleTips + return roleTips.some(tip => { // 遍历btns,查找btn.url是否有匹配的permission,有则返回true,否则返回false + return (tip === 'administrator') + }) +}