代码调整
This commit is contained in:
parent
6fcba825f2
commit
595747be2a
@ -20,104 +20,104 @@ import { getSessionStorage } from '@/utils/auth';
|
||||
import LangStorage from '@/utils/lang';
|
||||
|
||||
export default {
|
||||
name: 'Entry',
|
||||
components: {
|
||||
DeomonList,
|
||||
Qcode
|
||||
},
|
||||
data() {
|
||||
name: 'Entry',
|
||||
components: {
|
||||
DeomonList,
|
||||
Qcode
|
||||
},
|
||||
data() {
|
||||
|
||||
return {
|
||||
entryList: [
|
||||
{
|
||||
name: 'global.designPlatformEntrance',
|
||||
handle: this.goToDesign,
|
||||
hidden: getSessionStorage('project').startsWith('design')
|
||||
},
|
||||
{
|
||||
name: 'global.trainingPlatformEntrance',
|
||||
handle: this.goToTraining,
|
||||
hidden: !getSessionStorage('project').startsWith('design')
|
||||
},
|
||||
{
|
||||
name: 'global.scan',
|
||||
handle: this.qcodeEntry,
|
||||
hidden: process.env.NODE_ENV != 'development' || getSessionStorage('project') === 'design'
|
||||
},
|
||||
{
|
||||
name: 'global.quickEntry',
|
||||
handle: this.quickEntry,
|
||||
hidden: getSessionStorage('project').startsWith('design')
|
||||
},
|
||||
{
|
||||
name: LangStorage.getLang('zh')==='zh'?'English':'中文',
|
||||
handle: this.switchLanguage,
|
||||
tip: true
|
||||
}
|
||||
],
|
||||
stomp: null,
|
||||
header: null,
|
||||
lang: 'zh'
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
username() {
|
||||
return this.$store.state.user.nickname;
|
||||
},
|
||||
project() {
|
||||
return getSessionStorage('project');
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
},
|
||||
mounted() {
|
||||
const nowLang = LangStorage.getLang('zh');
|
||||
if (nowLang === 'zh') {
|
||||
this.lang = 'en';
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
quickEntry() {
|
||||
this.$refs.deomonList.doShow();
|
||||
},
|
||||
qcodeEntry() {
|
||||
this.$refs.qcode.doShow();
|
||||
},
|
||||
goToDesign() {
|
||||
const routeData = this.$router.resolve({
|
||||
path: this.getPath()
|
||||
});
|
||||
window.open(routeData.href, '_blank');
|
||||
},
|
||||
goToTraining() {
|
||||
const routeData = this.$router.resolve({
|
||||
path: this.getPath()
|
||||
});
|
||||
window.open(routeData.href, '_blank');
|
||||
},
|
||||
switchLanguage() {
|
||||
this.$i18n.locale = this.lang;
|
||||
LangStorage.setLang(this.lang);
|
||||
},
|
||||
getPath() {
|
||||
let path = '/';
|
||||
switch (this.project) {
|
||||
case 'login':
|
||||
path = '/design/login';
|
||||
break;
|
||||
case 'xty':
|
||||
path='/designxty/login';
|
||||
break;
|
||||
case 'design':
|
||||
path = '/login';
|
||||
break;
|
||||
case 'designxty':
|
||||
path= '/xty/login';
|
||||
break;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
return {
|
||||
entryList: [
|
||||
{
|
||||
name: 'global.designPlatformEntrance',
|
||||
handle: this.goToDesign,
|
||||
hidden: getSessionStorage('project').startsWith('design')
|
||||
},
|
||||
{
|
||||
name: 'global.trainingPlatformEntrance',
|
||||
handle: this.goToTraining,
|
||||
hidden: !getSessionStorage('project').startsWith('design')
|
||||
},
|
||||
{
|
||||
name: 'global.scan',
|
||||
handle: this.qcodeEntry,
|
||||
hidden: process.env.NODE_ENV != 'development' || getSessionStorage('project').startsWith('design')
|
||||
},
|
||||
{
|
||||
name: 'global.quickEntry',
|
||||
handle: this.quickEntry,
|
||||
hidden: getSessionStorage('project').startsWith('design')
|
||||
},
|
||||
{
|
||||
name: LangStorage.getLang('zh') === 'zh' ? 'English' : '中文',
|
||||
handle: this.switchLanguage,
|
||||
tip: true
|
||||
}
|
||||
],
|
||||
stomp: null,
|
||||
header: null,
|
||||
lang: 'zh'
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
username() {
|
||||
return this.$store.state.user.nickname;
|
||||
},
|
||||
project() {
|
||||
return getSessionStorage('project');
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
},
|
||||
mounted() {
|
||||
const nowLang = LangStorage.getLang('zh');
|
||||
if (nowLang === 'zh') {
|
||||
this.lang = 'en';
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
quickEntry() {
|
||||
this.$refs.deomonList.doShow();
|
||||
},
|
||||
qcodeEntry() {
|
||||
this.$refs.qcode.doShow();
|
||||
},
|
||||
goToDesign() {
|
||||
const routeData = this.$router.resolve({
|
||||
path: this.getPath()
|
||||
});
|
||||
window.open(routeData.href, '_blank');
|
||||
},
|
||||
goToTraining() {
|
||||
const routeData = this.$router.resolve({
|
||||
path: this.getPath()
|
||||
});
|
||||
window.open(routeData.href, '_blank');
|
||||
},
|
||||
switchLanguage() {
|
||||
this.$i18n.locale = this.lang;
|
||||
LangStorage.setLang(this.lang);
|
||||
},
|
||||
getPath() {
|
||||
let path = '/';
|
||||
switch (this.project) {
|
||||
case 'login':
|
||||
path = '/design/login';
|
||||
break;
|
||||
case 'xty':
|
||||
path = '/designxty/login';
|
||||
break;
|
||||
case 'design':
|
||||
path = '/login';
|
||||
break;
|
||||
case 'designxty':
|
||||
path = '/xty/login';
|
||||
break;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -68,9 +68,6 @@ function handleRoute(to, from, next, routeInfo) {
|
||||
store.dispatch('GetInfo', routeInfo.getTokenInfo).then(res => {
|
||||
// 根据roles权限生成可访问的路由表
|
||||
const roles = res.roles;
|
||||
if (getSessionStorage('project').startsWith('design')) {
|
||||
roles.push(userDesign);
|
||||
}
|
||||
store.dispatch('GenerateRoutes', { roles, clientId: routeInfo.clientId }).then(() => {
|
||||
// 动态添加可访问路由表
|
||||
router.addRoutes(store.getters.addRouters);
|
||||
|
@ -4,19 +4,19 @@ import { UrlConfig } from '@/router/index';
|
||||
import { getSessionStorage } from '@/utils/auth';
|
||||
|
||||
function setHonePagePath(route, roles) {
|
||||
if (roles && roles.length === 2 && roles.indexOf(user) >= 0 && (route.path === '/' || route.path === 'dashboard')) {
|
||||
if (roles.indexOf(userLesson) >= 0) {
|
||||
route.redirect = `${UrlConfig.teach.home}`;
|
||||
} else if (roles.indexOf(userExam) >= 0) {
|
||||
route.redirect = `${UrlConfig.exam.home}`;
|
||||
} else if (roles.indexOf(userSimulation) >= 0) {
|
||||
route.redirect = `${UrlConfig.demonstration.home}`;
|
||||
} else if (roles.indexOf(userScreen) >= 0) {
|
||||
route.redirect = `${UrlConfig.dp.home}`;
|
||||
} else if (roles.indexOf(userPlan) >= 0) {
|
||||
route.redirect = `${UrlConfig.plan.home}`;
|
||||
}
|
||||
}
|
||||
if (roles && roles.length === 2 && roles.indexOf(user) >= 0 && (route.path === '/' || route.path === 'dashboard')) {
|
||||
if (roles.indexOf(userLesson) >= 0) {
|
||||
route.redirect = `${UrlConfig.teach.home}`;
|
||||
} else if (roles.indexOf(userExam) >= 0) {
|
||||
route.redirect = `${UrlConfig.exam.home}`;
|
||||
} else if (roles.indexOf(userSimulation) >= 0) {
|
||||
route.redirect = `${UrlConfig.demonstration.home}`;
|
||||
} else if (roles.indexOf(userScreen) >= 0) {
|
||||
route.redirect = `${UrlConfig.dp.home}`;
|
||||
} else if (roles.indexOf(userPlan) >= 0) {
|
||||
route.redirect = `${UrlConfig.plan.home}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -25,48 +25,26 @@ function setHonePagePath(route, roles) {
|
||||
* @param route
|
||||
*/
|
||||
function hasPermission(roles, route, parentsRoles) {
|
||||
setHonePagePath(route, roles);
|
||||
if (route.meta && route.meta.roles) {
|
||||
// 如果存在本级路由,则使用自己的roles过滤
|
||||
// debugger;
|
||||
// if (getSessionStorage('design')) {
|
||||
// if (route.meta.roles.indexOf(userDesign)===-1) {
|
||||
// route.hidden = true;
|
||||
// } else {
|
||||
// if ((route.meta.roles.indexOf(admin)>=0 && roles.indexOf(admin)>=0)) {
|
||||
// route.hidden = false;
|
||||
// } else if (route.meta.roles.indexOf(user)>=0 && roles.indexOf(user)>=0) {
|
||||
// route.hidden = false;
|
||||
// } else {
|
||||
// route.hidden = true;
|
||||
// }
|
||||
// }
|
||||
setHonePagePath(route, roles);
|
||||
if (route.meta && route.meta.roles) {
|
||||
// 如果存在本级路由,则使用自己的roles过滤
|
||||
|
||||
// } else {
|
||||
// if (route.meta.roles.indexOf(userDesign)>0) {
|
||||
// route.hidden = true;
|
||||
// }
|
||||
// }
|
||||
// return roles.some(role => route.meta.roles.indexOf(role) >= 0);
|
||||
if (getSessionStorage('project').startsWith('design')) {
|
||||
roles= roles.filter(function (role) {
|
||||
return route.meta.roles.indexOf(role) >= 0;
|
||||
});
|
||||
const result=roles.every(role => route.meta.roles.indexOf(role) >= 0);
|
||||
return result && ((roles.indexOf(admin)>=0 && route.meta.roles.indexOf(admin)>=0) || (roles.indexOf(user)>=0 && route.meta.roles.indexOf(user)>=0 ));
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
} else if (parentsRoles) {
|
||||
// 如果没有本级路由,有父级路由,则使用父级路由过滤
|
||||
return roles.some(role => parentsRoles.indexOf(role) >= 0);
|
||||
} else {
|
||||
// 如果父级和本级都没有则默认不需要过滤
|
||||
return true;
|
||||
}
|
||||
if (getSessionStorage('project').startsWith('design')) {
|
||||
const result = roles.filter(role => route.meta.roles.indexOf(role) >= 0) || [];
|
||||
return result.length;
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
} else if (parentsRoles) {
|
||||
// 如果没有本级路由,有父级路由,则使用父级路由过滤
|
||||
return roles.some(role => parentsRoles.indexOf(role) >= 0);
|
||||
} else {
|
||||
// 如果父级和本级都没有则默认不需要过滤
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,17 +53,17 @@ function hasPermission(roles, route, parentsRoles) {
|
||||
* @param type
|
||||
*/
|
||||
function convertRouterRoles({ roles, permissionType }) {
|
||||
if (roles && roles.indexOf(user) >= 0) {
|
||||
switch (permissionType) {
|
||||
case PermissionType.LESSON: roles.push(userLesson); break;
|
||||
case PermissionType.EXAM: roles.push(userExam); break;
|
||||
case PermissionType.SIMULATION: roles.push(userSimulation); break;
|
||||
case PermissionType.SCREEN: roles.push(userScreen); break;
|
||||
case PermissionType.PLAN: roles.push(userPlan); break;
|
||||
}
|
||||
}
|
||||
if (roles && roles.indexOf(user) >= 0) {
|
||||
switch (permissionType) {
|
||||
case PermissionType.LESSON: roles.push(userLesson); break;
|
||||
case PermissionType.EXAM: roles.push(userExam); break;
|
||||
case PermissionType.SIMULATION: roles.push(userSimulation); break;
|
||||
case PermissionType.SCREEN: roles.push(userScreen); break;
|
||||
case PermissionType.PLAN: roles.push(userPlan); break;
|
||||
}
|
||||
}
|
||||
|
||||
return { roles };
|
||||
return { roles };
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,51 +72,51 @@ function convertRouterRoles({ roles, permissionType }) {
|
||||
* @param roles
|
||||
*/
|
||||
function filterAsyncRouter(asyncRouter, roles, parentsRoles) {
|
||||
return asyncRouter.filter(route => {
|
||||
if (route.name === '大屏系统' && roles.indexOf(admin)===-1 && roles.indexOf(userScreen) ===-1) {
|
||||
route.hidden = true;
|
||||
}
|
||||
if (hasPermission(roles, route, parentsRoles)) {
|
||||
if (route.children && route.children.length) {
|
||||
route.children = filterAsyncRouter(route.children, roles, route.meta ? route.meta.roles : undefined);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return asyncRouter.filter(route => {
|
||||
if (route.name === '大屏系统' && roles.indexOf(admin) === -1 && roles.indexOf(userScreen) === -1) {
|
||||
route.hidden = true;
|
||||
}
|
||||
if (hasPermission(roles, route, parentsRoles)) {
|
||||
if (route.children && route.children.length) {
|
||||
route.children = filterAsyncRouter(route.children, roles, route.meta ? route.meta.roles : undefined);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
const permission = {
|
||||
state: {
|
||||
routes: constantRoutes,
|
||||
addRouters: []
|
||||
},
|
||||
mutations: {
|
||||
SET_ROUTERS: (state, routes) => {
|
||||
state.addRouters = routes;
|
||||
state.routes = constantRoutes.concat(routes);
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
// 生成其他权限路由
|
||||
GenerateRoutes({ commit }, data) {
|
||||
return new Promise(resolve => {
|
||||
const { roles } = convertRouterRoles(data);
|
||||
let accessedRouters;
|
||||
if (roles.indexOf(superAdmin) >= 0 && roles.indexOf(admin) < 0) {
|
||||
roles.push(admin);
|
||||
}
|
||||
// if (roles.indexOf(superAdmin) >= 0) {
|
||||
// accessedRouters = asyncRouter;
|
||||
// } else {
|
||||
// eslint-disable-next-line prefer-const
|
||||
accessedRouters = filterAsyncRouter(asyncRouter, roles);
|
||||
// }
|
||||
commit('SET_ROUTERS', accessedRouters);
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
}
|
||||
state: {
|
||||
routes: constantRoutes,
|
||||
addRouters: []
|
||||
},
|
||||
mutations: {
|
||||
SET_ROUTERS: (state, routes) => {
|
||||
state.addRouters = routes;
|
||||
state.routes = constantRoutes.concat(routes);
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
// 生成其他权限路由
|
||||
GenerateRoutes({ commit }, data) {
|
||||
return new Promise(resolve => {
|
||||
const { roles } = convertRouterRoles(data);
|
||||
let accessedRouters;
|
||||
if (roles.indexOf(superAdmin) >= 0 && roles.indexOf(admin) < 0) {
|
||||
roles.push(admin);
|
||||
}
|
||||
// if (roles.indexOf(superAdmin) >= 0) {
|
||||
// accessedRouters = asyncRouter;
|
||||
// } else {
|
||||
// eslint-disable-next-line prefer-const
|
||||
accessedRouters = filterAsyncRouter(asyncRouter, roles);
|
||||
// }
|
||||
commit('SET_ROUTERS', accessedRouters);
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default permission;
|
||||
|
@ -407,7 +407,7 @@ export default {
|
||||
name: 'systermOut',
|
||||
params: {
|
||||
width: 600,
|
||||
contextList: resp.data
|
||||
contextList: resp.data.length > 0 ? resp.data : ['检查成功']
|
||||
}
|
||||
});
|
||||
}).catch(() => {
|
||||
|
@ -21,49 +21,49 @@
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: 'SystermOut',
|
||||
components: {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogShow: false,
|
||||
loading: false,
|
||||
params: {
|
||||
width: 400,
|
||||
contextList: []
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
title() {
|
||||
return this.$t('planMonitor.updateStation.systemOutPut');
|
||||
},
|
||||
width() {
|
||||
if (this.params.width) {
|
||||
return this.params.width;
|
||||
} else {
|
||||
return 400;
|
||||
}
|
||||
},
|
||||
context() {
|
||||
return this.params.contextList.join('\n') || '';
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
methods: {
|
||||
doShow(params) {
|
||||
this.params = params || {};
|
||||
this.dialogShow = true;
|
||||
},
|
||||
doClose() {
|
||||
this.loading = false;
|
||||
this.dialogShow = false;
|
||||
},
|
||||
handleCommit() {
|
||||
this.doClose();
|
||||
}
|
||||
}
|
||||
name: 'SystermOut',
|
||||
components: {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogShow: false,
|
||||
loading: false,
|
||||
params: {
|
||||
width: 400,
|
||||
contextList: []
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
title() {
|
||||
return this.$t('planMonitor.updateStation.systemOutPut');
|
||||
},
|
||||
width() {
|
||||
if (this.params.width) {
|
||||
return this.params.width;
|
||||
} else {
|
||||
return 400;
|
||||
}
|
||||
},
|
||||
context() {
|
||||
return this.params.contextList.join('\n') || '';
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
methods: {
|
||||
doShow(params) {
|
||||
this.params = params || {};
|
||||
this.dialogShow = true;
|
||||
},
|
||||
doClose() {
|
||||
this.loading = false;
|
||||
this.dialogShow = false;
|
||||
},
|
||||
handleCommit() {
|
||||
this.doClose();
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
|
@ -12,7 +12,7 @@
|
||||
<div v-if="isNotUser" class="li_plan" @click="handleModifyingTask">{{ $t('planMonitor.modifyTask') }}</div>
|
||||
</ul>
|
||||
<ul class="ul-box tool">
|
||||
<div v-if="isNotUser" class="li_plan" @click="handlePlanEffectiveCheck">{{ $t('planMonitor.validityCheck') }}</div>
|
||||
<div class="li_plan" @click="handlePlanEffectiveCheck">{{ $t('planMonitor.validityCheck') }}</div>
|
||||
<div class="li_plan" @click="handleTestRunPlan">{{ $t('planMonitor.testRunning') }}</div>
|
||||
</ul>
|
||||
</div>
|
||||
@ -117,11 +117,11 @@ export default {
|
||||
name: 'systermOut',
|
||||
params: {
|
||||
width: 600,
|
||||
contextList: resp.data
|
||||
contextList: resp.data.length > 0 ? resp.data : ['检查成功']
|
||||
}
|
||||
});
|
||||
}).catch(() => {
|
||||
this.$messageBox(this.$t('tip.runGraphVerificationFailed'));
|
||||
}).catch(error => {
|
||||
this.$messageBox(error.message + ' ' + this.$t('tip.runGraphVerificationFailed'));
|
||||
});
|
||||
} else {
|
||||
this.$messageBox(this.$t('tip.selectARunGraphFirst'));
|
||||
|
Loading…
Reference in New Issue
Block a user