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