|
@@ -131,7 +131,8 @@ import { SYS_ADMIN_NAME } from "@/constants/enumerate";
|
|
const MENU_ICONS = {
|
|
const MENU_ICONS = {
|
|
base: "base",
|
|
base: "base",
|
|
exam: "exam",
|
|
exam: "exam",
|
|
- customer: "customer"
|
|
|
|
|
|
+ customer: "customer",
|
|
|
|
+ stmms: "book"
|
|
};
|
|
};
|
|
|
|
|
|
export default {
|
|
export default {
|
|
@@ -165,7 +166,7 @@ export default {
|
|
watch: {
|
|
watch: {
|
|
$route(val) {
|
|
$route(val) {
|
|
if (val.name === "Home") return;
|
|
if (val.name === "Home") return;
|
|
- this.actCurNav();
|
|
|
|
|
|
+ this.routerChange();
|
|
}
|
|
}
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
@@ -178,15 +179,12 @@ export default {
|
|
...mapActions("exam", ["updateWaitTaskCount"]),
|
|
...mapActions("exam", ["updateWaitTaskCount"]),
|
|
initData1() {
|
|
initData1() {
|
|
// 开发阶段专用
|
|
// 开发阶段专用
|
|
- this.privileges = localMenus;
|
|
|
|
|
|
+ this.initPrivilegeMap(localMenus);
|
|
|
|
+ this.privileges = this.transformMenu(localMenus);
|
|
this.menus = this.getMenu();
|
|
this.menus = this.getMenu();
|
|
- this.initPrivilegeMap(this.privileges);
|
|
|
|
|
|
|
|
if (this.$route.name === "Home") {
|
|
if (this.$route.name === "Home") {
|
|
- const firstRouteName = this.getFirstRouter();
|
|
|
|
- this.$router.replace({
|
|
|
|
- name: firstRouteName
|
|
|
|
- });
|
|
|
|
|
|
+ this.toMenu(this.menus[0]);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -197,19 +195,26 @@ export default {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- this.actCurNav();
|
|
|
|
|
|
+ this.updateBreadcrumbs();
|
|
|
|
+ const curMenu = this.menus.find(
|
|
|
|
+ menu => menu.url === this.breadcrumbs[0].url
|
|
|
|
+ );
|
|
|
|
+ this.menuChange(curMenu);
|
|
|
|
+ if (
|
|
|
|
+ this.validRoutes.includes("WaitTask") &&
|
|
|
|
+ this.curMenu.url === "exam"
|
|
|
|
+ ) {
|
|
|
|
+ this.updateWaitTaskCount();
|
|
|
|
+ }
|
|
},
|
|
},
|
|
async initData() {
|
|
async initData() {
|
|
const data = await sysMenu();
|
|
const data = await sysMenu();
|
|
- this.privileges = data.privileges;
|
|
|
|
- this.menus = this.getMenu();
|
|
|
|
this.initPrivilegeMap(data.privileges);
|
|
this.initPrivilegeMap(data.privileges);
|
|
|
|
+ this.privileges = this.transformMenu(data.privileges);
|
|
|
|
+ this.menus = this.getMenu();
|
|
|
|
|
|
if (this.$route.name === "Home") {
|
|
if (this.$route.name === "Home") {
|
|
- const firstRouteName = this.getFirstRouter();
|
|
|
|
- this.$router.replace({
|
|
|
|
- name: firstRouteName
|
|
|
|
- });
|
|
|
|
|
|
+ this.toMenu(this.menus[0]);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -220,16 +225,44 @@ export default {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- this.actCurNav();
|
|
|
|
|
|
+ this.updateBreadcrumbs();
|
|
|
|
+ const curMenu = this.menus.find(
|
|
|
|
+ menu => menu.url === this.breadcrumbs[0].url
|
|
|
|
+ );
|
|
|
|
+ this.menuChange(curMenu);
|
|
|
|
+
|
|
|
|
+ if (
|
|
|
|
+ this.validRoutes.includes("WaitTask") &&
|
|
|
|
+ this.curMenu.url === "exam"
|
|
|
|
+ ) {
|
|
|
|
+ this.updateWaitTaskCount();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ transformMenu(list) {
|
|
|
|
+ return list.map(item => {
|
|
|
|
+ return {
|
|
|
|
+ id: item.id,
|
|
|
|
+ parentId: item.parentId,
|
|
|
|
+ name: item.name,
|
|
|
|
+ type: item.type,
|
|
|
|
+ url: item.url
|
|
|
|
+ };
|
|
|
|
+ });
|
|
},
|
|
},
|
|
getMenu() {
|
|
getMenu() {
|
|
- let menus = this.privileges.filter(item => item.parentId === "-1");
|
|
|
|
|
|
+ const getChildren = id => {
|
|
|
|
+ return this.privileges
|
|
|
|
+ .filter(item => item.parentId === id)
|
|
|
|
+ .map(item => {
|
|
|
|
+ return { ...item };
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ let menus = getChildren("-1");
|
|
let validRoutes = [];
|
|
let validRoutes = [];
|
|
const toTree = menus => {
|
|
const toTree = menus => {
|
|
menus.forEach(menu => {
|
|
menus.forEach(menu => {
|
|
- const children = this.privileges.filter(
|
|
|
|
- item => item.parentId === menu.id
|
|
|
|
- );
|
|
|
|
|
|
+ const children = getChildren(menu.id);
|
|
if (children.length) {
|
|
if (children.length) {
|
|
menu.children = children;
|
|
menu.children = children;
|
|
toTree(menu.children);
|
|
toTree(menu.children);
|
|
@@ -244,14 +277,12 @@ export default {
|
|
// console.log(JSON.stringify(menus));
|
|
// console.log(JSON.stringify(menus));
|
|
return menus;
|
|
return menus;
|
|
},
|
|
},
|
|
- getFirstRouter() {
|
|
|
|
- let childNavs = this.privileges;
|
|
|
|
|
|
+ getCurMenuFirstRouter() {
|
|
let firstRouteName = "";
|
|
let firstRouteName = "";
|
|
- while (childNavs.length) {
|
|
|
|
- firstRouteName = childNavs[0].url;
|
|
|
|
- childNavs = this.privileges.filter(
|
|
|
|
- item => item.parentId === childNavs[0].id
|
|
|
|
- );
|
|
|
|
|
|
+ let menu = this.curMenu;
|
|
|
|
+ while (menu) {
|
|
|
|
+ firstRouteName = menu.url;
|
|
|
|
+ menu = menu.children && menu.children[0];
|
|
}
|
|
}
|
|
|
|
|
|
return firstRouteName;
|
|
return firstRouteName;
|
|
@@ -278,19 +309,21 @@ export default {
|
|
this.$store.commit("setPrivilegeMap", privilegeMap);
|
|
this.$store.commit("setPrivilegeMap", privilegeMap);
|
|
this.$ls.set("privilegeMap", privilegeMap);
|
|
this.$ls.set("privilegeMap", privilegeMap);
|
|
},
|
|
},
|
|
- getSubMenus(menu) {
|
|
|
|
- return this.privileges.filter(
|
|
|
|
- m => m.parentId === menu.id && m.type === "MENU"
|
|
|
|
- );
|
|
|
|
- },
|
|
|
|
- toMenu(menu) {
|
|
|
|
- if (this.curMenu.url === menu.url) return;
|
|
|
|
|
|
+ menuChange(menu) {
|
|
this.curMenu = menu;
|
|
this.curMenu = menu;
|
|
|
|
|
|
this.curSubMenuNames = this.privileges
|
|
this.curSubMenuNames = this.privileges
|
|
.filter(item => item.parentId === menu.id)
|
|
.filter(item => item.parentId === menu.id)
|
|
.map(item => item.url);
|
|
.map(item => item.url);
|
|
},
|
|
},
|
|
|
|
+ toMenu(menu) {
|
|
|
|
+ if (this.curMenu.url === menu.url) return;
|
|
|
|
+ this.menuChange(menu);
|
|
|
|
+ const firstRouteName = this.getCurMenuFirstRouter();
|
|
|
|
+ this.$router.replace({
|
|
|
|
+ name: firstRouteName
|
|
|
|
+ });
|
|
|
|
+ },
|
|
updateBreadcrumbs() {
|
|
updateBreadcrumbs() {
|
|
this.curRouteName = this.$route.name;
|
|
this.curRouteName = this.$route.name;
|
|
let breadcrumbs = [];
|
|
let breadcrumbs = [];
|
|
@@ -308,9 +341,8 @@ export default {
|
|
|
|
|
|
this.breadcrumbs = breadcrumbs;
|
|
this.breadcrumbs = breadcrumbs;
|
|
},
|
|
},
|
|
- actCurNav() {
|
|
|
|
|
|
+ routerChange() {
|
|
this.updateBreadcrumbs();
|
|
this.updateBreadcrumbs();
|
|
- this.toMenu(this.breadcrumbs[0]);
|
|
|
|
|
|
|
|
if (
|
|
if (
|
|
this.validRoutes.includes("WaitTask") &&
|
|
this.validRoutes.includes("WaitTask") &&
|
|
@@ -342,6 +374,24 @@ export default {
|
|
},
|
|
},
|
|
resetPwdModified() {
|
|
resetPwdModified() {
|
|
this.logoutAction();
|
|
this.logoutAction();
|
|
|
|
+ },
|
|
|
|
+ // other
|
|
|
|
+ getSubMenus(menu) {
|
|
|
|
+ return this.privileges.filter(
|
|
|
|
+ m => m.parentId === menu.id && m.type === "MENU"
|
|
|
|
+ );
|
|
|
|
+ },
|
|
|
|
+ getFirstRouter() {
|
|
|
|
+ let childNavs = this.privileges;
|
|
|
|
+ let firstRouteName = "";
|
|
|
|
+ while (childNavs.length) {
|
|
|
|
+ firstRouteName = childNavs[0].url;
|
|
|
|
+ childNavs = this.privileges.filter(
|
|
|
|
+ item => item.parentId === childNavs[0].id
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return firstRouteName;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|