This commit is contained in:
joylink_cuiweidong 2019-11-14 17:03:54 +08:00
commit 52c4d0e08d
7 changed files with 52 additions and 51 deletions

View File

@ -126,7 +126,7 @@
</el-table-column>
</template>
</el-table>
<div v-if="!queryList.selectCheckShow" style="margin-top: 8px; margin-left: 8px;">
<div v-if="queryList.selectCheckShow" style="margin-top: 8px; margin-left: 8px;">
<el-button
size="mini"
:type="'primary'"

View File

@ -16,6 +16,14 @@ function hasPermission(roles, permissionRoles) {
const whiteList = ['/login', '/design/login', '/xty/login', '/designxty/login']; // 不重定向白名单
const designPageRegex = [/^\/design/, /^\/scriptDisplay/, /^\/publish/, /^\/orderauthor/, /^\/system/, /^\/display\/record/, /^\/display\/manage/, /^\/apply/, /^\/plan/, /^\/display\/plan/];
function isDesignPage(toRoutePath) {
return designPageRegex.some(item => {
return item.test(toRoutePath);
});
}
const loginPage = whiteList[0];
const loginDesignPage = whiteList[1];
@ -32,17 +40,9 @@ function getRouteInfo(to) {
if (/^\/designxty/.test(toRoutePath)) {
loginPath = loginDesignXtyPage;
clientId = LoginParams.Design.clientId;
} else if (/^\/design/.test(toRoutePath) || /^\/scriptDisplay/.test(toRoutePath) || /^\/publish/.test(toRoutePath) || /^\/orderauthor/.test(toRoutePath) || /^\/system/.test(toRoutePath) || /^\/display\/record/.test(toRoutePath) || /^\/display\/manage/.test(toRoutePath) || /^\/apply/.test(toRoutePath)) {
} else if (isDesignPage(toRoutePath)) {
loginPath = getSessionStorage('project') === 'designxty' ? loginDesignXtyPage : loginDesignPage;
clientId = LoginParams.Design.clientId;
} else if (/^\/plan/.test(toRoutePath) || /^\/display\/plan/.test(toRoutePath)) {
if (getSessionStorage('project').startsWith('design')) {
loginPath = getSessionStorage('project') === 'designxty' ? loginDesignXtyPage : loginDesignPage;
clientId = LoginParams.Design.clientId;
} else {
loginPath = getSessionStorage('project') === 'xty' ? loginXtyPage : loginPage;
clientId = null;
}
} else if ( /^\/xty/.test(toRoutePath)) {
loginPath = loginXtyPage;
clientId = null;

View File

@ -134,7 +134,7 @@ export const userLesson = '012'; // 教学系统
export const userSimulation = '013'; // 仿真系统
export const userScreen = '014'; // 大屏系统
export const userPlan = '015'; // 计划系统
export const userDesign = '016'; // 设计系统
export const userTrainingPlatform = '016'; // 实训平台
// const isDev = process.env.NODE_ENV === 'development';
export const UrlConfig = {
@ -288,7 +288,7 @@ export const asyncRouter = [
component: Layout,
redirect: '/design/home',
meta: {
roles: [admin, user, userDesign]
roles: [admin, user]
},
children: [
{
@ -376,7 +376,7 @@ export const asyncRouter = [
redirect: '/design/userlist/home',
component: Layout,
meta: {
roles: [admin, user, userDesign]
roles: [admin, user]
},
children: [
{
@ -453,7 +453,7 @@ export const asyncRouter = [
component: Layout,
hidden: true,
meta: {
roles: [admin, userSimulation, user]
roles: [admin, userSimulation, user, userTrainingPlatform]
},
children: [
{
@ -550,7 +550,7 @@ export const asyncRouter = [
component: Layout,
meta: {
i18n: 'router.pulishManage',
roles: [admin, userDesign]
roles: [admin]
},
children: [
{ // 发布地图
@ -629,7 +629,7 @@ export const asyncRouter = [
component: Layout,
meta: {
i18n: 'router.orderAuthorityManage',
roles: [admin, userDesign]
roles: [admin]
},
children: [
{
@ -721,7 +721,7 @@ export const asyncRouter = [
component: Layout,
meta: {
i18n: 'router.systemManage',
roles: [admin, userDesign]
roles: [admin]
},
children: [
{
@ -820,7 +820,7 @@ export const asyncRouter = [
component: Layout,
meta: {
i18n: 'router.releaseApplication',
roles: [admin, userDesign]
roles: [admin]
},
children: [
{

View File

@ -1,4 +1,4 @@
import { asyncRouter, constantRoutes, user, userLesson, userExam, userSimulation, userScreen, userPlan, superAdmin, admin, userDesign } from '@/router';
import { asyncRouter, constantRoutes, user, userLesson, userExam, userSimulation, userScreen, userPlan, superAdmin, admin, userTrainingPlatform } from '@/router';
import { PermissionType } from '@/utils/PermissionType';
import { UrlConfig } from '@/router/index';
import { getSessionStorage } from '@/utils/auth';
@ -36,7 +36,7 @@ function hasPermission(roles, route, parentsRoles) {
roles = roles.filter(function (role) {
return route.meta.roles.indexOf(role) >= 0;
});
return roles.some(role => route.meta.roles.indexOf(role) >= 0) && route.meta.roles.indexOf(userDesign) < 0;
return roles.some(role => route.meta.roles.indexOf(role) >= 0) && route.meta.roles.indexOf(userTrainingPlatform) > 0;
}
} else if (parentsRoles) {
// 如果没有本级路由,有父级路由,则使用父级路由过滤

View File

@ -2,8 +2,8 @@ const trainingList = {
namespaced: true,
state: {
index: 0, //当前选择实训索引
trainingList: [], //实训初始列表
index: 0, // 当前选择实训索引
trainingList: [] // 实训初始列表
},
getters: {
trainingList: (state) => {
@ -36,7 +36,7 @@ const trainingList = {
} else {
state.trainingList = [];
}
},
}
},
actions: {
setIndex({ commit }, index) {
@ -63,4 +63,4 @@ const trainingList = {
}
};
export default trainingList;
export default trainingList;

View File

@ -53,6 +53,18 @@ const user = {
Cookies.remove('UserDesignToken');
Cookies.remove('UserName');
Cookies.remove('UserToken');
},
SUBSCRIBE: (state, {header, type}) => {
if (type == 'design') {
creatSubscribe(commonTopic, header);
} else {
creatSubscribe(perpetualTopic, header);
creatSubscribe(commonTopic, header);
}
},
SUBSCRIBE_UN: () => {
clearSubscribe(perpetualTopic);
clearSubscribe(commonTopic);
}
},
@ -61,41 +73,32 @@ const user = {
Login({ commit }, userInfo) {
const username = userInfo.username.trim();
const password = userInfo.password.trim();
const type = userInfo.type;
return new Promise((resolve, reject) => {
let params = null;
let execFunc = null;
if (userInfo.type == 'design') {
params = Object.assign({ account: username, password }, LoginParams.Design);
execFunc = (header) => {
creatSubscribe(commonTopic, header);
};
} else {
params = Object.assign({ account: username, password }, LoginParams.LianKeTang);
execFunc = (header) => {
creatSubscribe(perpetualTopic, header);
creatSubscribe(commonTopic, header);
};
}
// 登录系统
const params = Object.assign({ account: username, password }, type == 'design' ? LoginParams.Design : LoginParams.LianKeTang);
login(params).then(resp => {
const token = resp.data;
commit('SET_TOKEN', token);
const header = { group: '', 'X-Token': token };
setToken(token);
execFunc({ group: '', 'X-Token': token });
commit('SET_TOKEN', token);
commit('SUBSCRIBE', {header, type});
resolve();
}).catch(error => { reject(error); });
});
},
// 扫码登陆设置
QrLoginSetting({ dispatch, commit }, token) {
QrLoginSetting({ dispatch, commit }, tokeninfo) {
return new Promise((resolve, reject) => {
// 设置user域token值
commit(token.key, token.value);
const header = { group: '', 'X-Token': token.value };
creatSubscribe(perpetualTopic, header);
creatSubscribe(commonTopic, header);
const header = { group: '', 'X-Token': tokeninfo.value };
const mutAction = tokeninfo.key;
const mutParams = tokeninfo.value;
const type = tokeninfo.type;
setToken(tokeninfo.value);
commit(mutAction, mutParams);
commit('SUBSCRIBE', {header, type});
// 获取用户参数
dispatch('GetUserConfigInfo').then(response => {
resolve(response);
@ -140,8 +143,7 @@ const user = {
},
// 前端登出
FedLogOut({ commit }) {
clearSubscribe(perpetualTopic);
clearSubscribe(commonTopic);
commit('SUBSCRIBE_UN');
commit('SET_TOKEN', '');
commit('SET_ID', '');
removeToken();

View File

@ -100,7 +100,6 @@ import QrcodeVue from 'qrcode.vue';
import { getLoginWmurl, checkLoginStatus } from '@/api/login';
import { LoginParams } from '@/utils/login';
import bgImg from '@/assets/bg1.jpg';
import { setToken } from '@/utils/auth';
import { loginInfo } from '@/scripts/ConstDic';
import { removeToken } from '@/utils/auth';
import LangStorage from '@/utils/lang';
@ -238,14 +237,14 @@ export default {
if (this && this._isDestroyed) {
return;
}
//
//
this.clearTimer(this.checkLogin);
this.checkLogin = setTimeout(() => {
checkLoginStatus(self.sessionId).then(response => {
setToken(response.data.token);
//
self.$store.dispatch('QrLoginSetting', { key: 'SET_TOKEN', value: response.data.token }).then(() => {
self.$store.dispatch('QrLoginSetting', { key: 'SET_TOKEN', value: response.data.token, type: this.modelType }).then(() => {
//
self.clearTimer(self.checkLogin);
this.handleLoginSucessRoute();