12345678910111213141516171819202122232425262728293031 |
- /* eslint-disable no-console */
- /* eslint-disable no-param-reassign */
- import Vue from 'vue';
- import { Message } from 'element-ui';
- const Plugin = {
- install(vue, options) {
- vue.prototype.$power = org => {
- const orgId = window.sessionStorage.getItem('orgId');
- const roles = window.sessionStorage.getItem('roles');
- const role = JSON.parse(roles).filter(p => p == 'superadmin' || p == 'admin');
- if (role.length <= 0) {
- if (!orgId) {
- Message.error('没有权限');
- return false;
- }
- if (!org || !org.orgId || org.orgId == null) {
- Message.error('没有权限');
- return false;
- }
- if (!org.orgId.startsWith(orgId)) {
- Message.error('没有权限');
- return false;
- }
- }
- return true;
- };
- },
- };
- Vue.use(Plugin);
|