|
|
@@ -92,15 +92,20 @@ const router = new VueRouter({
|
|
|
});
|
|
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
+ let exports = ["ROLE_EXPERT", "ROLE_DISTRICT_STAFF"];
|
|
|
+ let exportsInfo = store.state.roles.find(item => {
|
|
|
+ return exports.includes(item);
|
|
|
+ });
|
|
|
+ let inspectors = ["ROLE_SUPERVISOR"];
|
|
|
+ let inspectorsInfo = store.state.roles.find(item => {
|
|
|
+ return inspectors.includes(item);
|
|
|
+ });
|
|
|
if (!store.state.userInfo && to.path !== "/login" && to.meta.checkLogin) {
|
|
|
store
|
|
|
.dispatch("getUserInfo")
|
|
|
.then(() => {
|
|
|
if (to.name === "inspectorList") {
|
|
|
- if (
|
|
|
- store.state.role === "ROLE_EXPERT" ||
|
|
|
- store.state.role === "ROLE_DISTRICT_STAFF"
|
|
|
- ) {
|
|
|
+ if (exportsInfo) {
|
|
|
next("/expertList");
|
|
|
} else {
|
|
|
next();
|
|
|
@@ -114,12 +119,9 @@ router.beforeEach((to, from, next) => {
|
|
|
next("/login");
|
|
|
});
|
|
|
} else if (store.state.userInfo && to.name === "inspectorList") {
|
|
|
- if (store.state.role === "ROLE_SUPERVISOR") {
|
|
|
+ if (inspectorsInfo) {
|
|
|
next();
|
|
|
- } else if (
|
|
|
- store.state.role === "ROLE_EXPERT" ||
|
|
|
- store.state.role === "ROLE_DISTRICT_STAFF"
|
|
|
- ) {
|
|
|
+ } else if (exportsInfo) {
|
|
|
next("/expertList");
|
|
|
}
|
|
|
} else if (!to.matched.length) {
|