|
@@ -70,11 +70,6 @@
|
|
|
:route="{ name: nav.url }"
|
|
|
>
|
|
|
<span>{{ nav.name }}</span>
|
|
|
- <span
|
|
|
- class="nav-item-info"
|
|
|
- v-if="nav.url === 'WaitTask' && waitTaskCount"
|
|
|
- >{{ waitTaskCount }}</span
|
|
|
- >
|
|
|
</el-menu-item>
|
|
|
</el-submenu>
|
|
|
<el-menu-item
|
|
@@ -124,15 +119,14 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { mapState, mapActions } from "vuex";
|
|
|
-import localMenus from "@/constants/menus-data";
|
|
|
-import { sysMenu, logout } from "../modules/login/api";
|
|
|
-import ResetPwd from "../modules/base/components/ResetPwd.vue";
|
|
|
+import { mapState } from "vuex";
|
|
|
+import { logout } from "../modules/login/api";
|
|
|
import { SYS_ADMIN_NAME } from "@/constants/enumerate";
|
|
|
-import staticMenu from "../constants/staticMenu";
|
|
|
+import { logoutHandle } from "../plugins/logout";
|
|
|
+
|
|
|
+import ResetPwd from "../modules/base/components/ResetPwd.vue";
|
|
|
import SwitchSchoolDialog from "../modules/login/components/SwitchSchoolDialog.vue";
|
|
|
import ViewFooter from "../components/ViewFooter.vue";
|
|
|
-import { logoutHandle } from "../plugins/logout";
|
|
|
|
|
|
const HOME_PAGE_ROUTE = "HomePage";
|
|
|
|
|
@@ -149,13 +143,10 @@ export default {
|
|
|
const IS_SUPER_ADMIN = user.loginName === SYS_ADMIN_NAME;
|
|
|
|
|
|
return {
|
|
|
- privileges: [],
|
|
|
- menus: [],
|
|
|
curMenu: { url: "", children: [] },
|
|
|
curRouteName: "",
|
|
|
curSubMenuNames: [],
|
|
|
breadcrumbs: [],
|
|
|
- validRoutes: [],
|
|
|
username: user.realName,
|
|
|
userRoles: user.roleList,
|
|
|
schoolLogo: this.$ls.get("schoolLogo"),
|
|
@@ -181,6 +172,7 @@ export default {
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState("exam", ["waitTaskCount"]),
|
|
|
+ ...mapState("app", ["menus", "privilegeMap", "validRoutes", "privileges"]),
|
|
|
IS_HOME_PAGE() {
|
|
|
return this.$route.name === HOME_PAGE_ROUTE;
|
|
|
},
|
|
@@ -189,71 +181,18 @@ export default {
|
|
|
},
|
|
|
},
|
|
|
created() {
|
|
|
- // this.initData1();
|
|
|
this.initData();
|
|
|
},
|
|
|
methods: {
|
|
|
- ...mapActions("exam", ["updateWaitTaskCount"]),
|
|
|
- initData1() {
|
|
|
- // 开发阶段专用
|
|
|
- const privileges = [...staticMenu, ...localMenus];
|
|
|
- this.initPrivilegeMap(privileges);
|
|
|
- this.privileges = this.transformMenu(privileges);
|
|
|
- this.menus = this.getMenu();
|
|
|
-
|
|
|
- if (this.IS_HOME_PAGE) return;
|
|
|
-
|
|
|
- if (this.$route.name === "Home") {
|
|
|
- this.$router.replace({
|
|
|
- name: HOME_PAGE_ROUTE,
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (!this.validRoutes.includes(this.$route.name)) {
|
|
|
- this.$router.replace({
|
|
|
- name: "404",
|
|
|
- });
|
|
|
+ initData() {
|
|
|
+ this.updateWaitTypes();
|
|
|
+ if (this.IS_HOME_PAGE) {
|
|
|
+ this.curMenu = { url: HOME_PAGE_ROUTE };
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- 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() {
|
|
|
- const data = await sysMenu();
|
|
|
- const privileges = [...staticMenu, ...data.privileges];
|
|
|
- this.initPrivilegeMap(privileges);
|
|
|
- this.privileges = this.transformMenu(privileges);
|
|
|
- this.menus = this.getMenu();
|
|
|
-
|
|
|
- if (this.IS_HOME_PAGE) return;
|
|
|
-
|
|
|
if (this.$route.name === "Home") {
|
|
|
this.toMenu(this.menus[0]);
|
|
|
- // if (this.IS_SUPER_ADMIN) {
|
|
|
- // this.toMenu(this.menus[0]);
|
|
|
- // } else {
|
|
|
- // this.$router.replace({
|
|
|
- // name: HOME_PAGE_ROUTE
|
|
|
- // });
|
|
|
- // }
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (!this.validRoutes.includes(this.$route.name)) {
|
|
|
- this.$router.replace({
|
|
|
- name: "404",
|
|
|
- });
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -262,52 +201,6 @@ export default {
|
|
|
(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() {
|
|
|
- const getChildren = (id) => {
|
|
|
- return this.privileges
|
|
|
- .filter((item) => item.parentId === id)
|
|
|
- .map((item) => {
|
|
|
- return { ...item };
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- let menus = getChildren("-1");
|
|
|
- let validRoutes = [];
|
|
|
- const toTree = (menus) => {
|
|
|
- menus.forEach((menu) => {
|
|
|
- const children = getChildren(menu.id);
|
|
|
- if (children.length) {
|
|
|
- menu.children = children;
|
|
|
- toTree(menu.children);
|
|
|
- } else {
|
|
|
- validRoutes.push(menu.url);
|
|
|
- }
|
|
|
- });
|
|
|
- };
|
|
|
- toTree(menus);
|
|
|
-
|
|
|
- this.validRoutes = validRoutes;
|
|
|
- // console.log(JSON.stringify(menus));
|
|
|
- return menus;
|
|
|
},
|
|
|
getCurMenuFirstRouter() {
|
|
|
let firstRouteName = "";
|
|
@@ -319,25 +212,7 @@ export default {
|
|
|
|
|
|
return firstRouteName;
|
|
|
},
|
|
|
- initPrivilegeMap(data) {
|
|
|
- let privilegeMap = {};
|
|
|
- const pageSetTypes = ["conditions", "buttons", "lists", "links"];
|
|
|
- data.forEach((item) => {
|
|
|
- privilegeMap[item.url] = [item.id];
|
|
|
- pageSetTypes.forEach((type, index) => {
|
|
|
- if (item[type] && item[type].length) {
|
|
|
- item[type].forEach((elem) => {
|
|
|
- privilegeMap[item.url].push(
|
|
|
- `${elem.type}_${elem.url}`.toLowerCase()
|
|
|
- );
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- this.$store.commit("setPrivilegeMap", privilegeMap);
|
|
|
- this.$ls.set("privilegeMap", privilegeMap);
|
|
|
-
|
|
|
- // wait-types
|
|
|
+ updateWaitTypes() {
|
|
|
const filterFunc = {
|
|
|
flow: () => {
|
|
|
return (
|
|
@@ -360,7 +235,6 @@ export default {
|
|
|
},
|
|
|
menuChange(menu) {
|
|
|
this.curMenu = menu;
|
|
|
-
|
|
|
this.curSubMenuNames = this.privileges
|
|
|
.filter((item) => item.parentId === menu.id)
|
|
|
.map((item) => item.url);
|
|
@@ -384,7 +258,7 @@ export default {
|
|
|
},
|
|
|
updateBreadcrumbs() {
|
|
|
this.curRouteName = this.$route.name;
|
|
|
- let breadcrumbs = [];
|
|
|
+ const breadcrumbs = [];
|
|
|
let curBreadcrumb = this.privileges.find(
|
|
|
(item) => item.url === this.curRouteName
|
|
|
);
|
|
@@ -401,20 +275,11 @@ export default {
|
|
|
},
|
|
|
routerChange() {
|
|
|
this.updateBreadcrumbs();
|
|
|
- // console.log(this.breadcrumbs);
|
|
|
- // console.log(this.curMenu);
|
|
|
|
|
|
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();
|
|
|
- }
|
|
|
},
|
|
|
toLogout() {
|
|
|
this.$confirm("确定要退出登录吗?", "提示", {
|
|
@@ -426,7 +291,10 @@ export default {
|
|
|
.catch(() => {});
|
|
|
},
|
|
|
toSelectSchool() {
|
|
|
- if (this.IS_SUPER_ADMIN) this.$router.push({ name: "SelectSchool" });
|
|
|
+ if (this.IS_SUPER_ADMIN) {
|
|
|
+ this.$router.push({ name: "SelectSchool" });
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (this.hasMoreSchool) {
|
|
|
this.$refs.SwitchSchoolDialog.open();
|
|
|
}
|