缓存已打开菜单功能

This commit is contained in:
caorui 2024-09-25 15:33:14 +08:00
parent 2e45355843
commit a0f64edf2e
10 changed files with 790 additions and 290 deletions

View File

@ -11,14 +11,47 @@
</template> </template>
<script> <script>
import InnerLink from "../InnerLink/index" import InnerLink from "../InnerLink/index";
import { getCompanyId, getMenuNode } from "@/utils/auth";
export default { export default {
components: { InnerLink }, components: { InnerLink },
computed: { data(){
iframeViews() { return{
return this.$store.state.tagsView.iframeViews iframeViews:[]
} }
},
watch: {
"$store.getters.currentMenuNode": {
deep: true,
immediate: true,
handler(newVal, old) {
this.iframeViews = this.getVisitedViews();
},
},
},
methods:{
getVisitedViews() {
let url = getMenuNode();
let empty = [];
let data = this.$store.state.tagsView.iframeViews;
if (url) {
if (url.includes("Workbench")) {
return data[0];
} else if (url.includes("MasterDataCenter")) {
return data[1];
} else if (url.includes("IntegrationTaskCenter")) {
return data[2];
} else if (url.includes("businessCenter")) {
return data[3];
} else if (url.includes("ApplicationCenter")) {
return data[4];
} else {
return empty;
}
} else {
return empty;
}
},
} }
} };
</script> </script>

View File

@ -57,7 +57,14 @@
<script> <script>
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import { getInfo, setInfo, getCompanyId, setCompanyId } from "@/utils/auth"; import {
getInfo,
setInfo,
getCompanyId,
setCompanyId,
getMenuNode,
setMenuNode,
} from "@/utils/auth";
import { PersonDetail } from "@/api/apis/personnelSettings"; import { PersonDetail } from "@/api/apis/personnelSettings";
import logoImg from "@/assets/logo/tranLogo.png"; import logoImg from "@/assets/logo/tranLogo.png";
import personImg from "@/assets/images/person.png"; import personImg from "@/assets/images/person.png";
@ -83,13 +90,37 @@ export default {
}, },
}, },
watch: { watch: {
"$store.getters.currentMenuNode": {
deep: true,
immediate: true,
handler(newVal, old) {
let url = getMenuNode();
if (url) {
this.currentPath = url;
} else {
this.currentPath = "/index";
}
},
},
// //
$route(to, form) { $route: {
let route = { ...to }; deep: true,
if (this.currentPath == to.path) { immediate: true,
route.meta.affix = true; handler(to, old) {
this.$store.dispatch("tagsView/updateVisitedView", route); let route = { ...to };
} if (this.currentPath == to.path) {
if (
this.currentPath.includes("Workbench") ||
this.currentPath.includes("MasterDataCenter") ||
this.currentPath.includes("IntegrationTaskCenter") ||
this.currentPath.includes("businessCenter") ||
this.currentPath.includes("ApplicationCenter")
) {
route.meta.affix = true;
this.$store.dispatch("tagsView/addVisitedView", route);
}
}
},
}, },
}, },
data() { data() {
@ -150,17 +181,40 @@ export default {
}; };
}, },
created() { created() {
this.$router let url = getMenuNode();
.push({ if (url) {
path: "/index", if (
}) url.includes("Workbench") ||
.then(() => { url.includes("MasterDataCenter") ||
this.currentPath = this.$route.path; url.includes("IntegrationTaskCenter") ||
url.includes("businessCenter") ||
url.includes("ApplicationCenter")
) {
this.$store.dispatch("settings/changeSetting", {
key: "showTagsView",
value: true,
});
} else {
//
this.$store.dispatch("settings/changeSetting", { this.$store.dispatch("settings/changeSetting", {
key: "showTagsView", key: "showTagsView",
value: false, value: false,
}); });
}
this.$router.push({
path: url,
}); });
} else {
this.$store.dispatch("settings/changeSetting", {
key: "showTagsView",
value: false,
});
setMenuNode("/index");
this.$store.commit("SET_CURRENT_MENU_NODE", "/index");
this.$router.push({
path: "/index",
});
}
}, },
mounted() { mounted() {
// this.GetMessageCount(); // this.GetMessageCount();
@ -207,20 +261,29 @@ export default {
if (item.path == this.currentPath) { if (item.path == this.currentPath) {
return; return;
} }
this.currentPath = item.path; if (
this.$tab.closeAllPage(); item.path.includes("Workbench") ||
this.$store.dispatch("tagsView/clearVisted"); item.path.includes("MasterDataCenter") ||
this.$router item.path.includes("IntegrationTaskCenter") ||
.push({ item.path.includes("businessCenter") ||
path: item.path, item.path.includes("ApplicationCenter")
}) ) {
.then(() => { this.$store.dispatch("settings/changeSetting", {
// key: "showTagsView",
this.$store.dispatch("settings/changeSetting", { value: true,
key: "showTagsView",
value: false,
});
}); });
} else {
//
this.$store.dispatch("settings/changeSetting", {
key: "showTagsView",
value: false,
});
}
setMenuNode(item.path);
this.$store.commit("SET_CURRENT_MENU_NODE", item.path);
this.$router.push({
path: item.path,
});
}, },
// //
async getInfoDetail(id) { async getInfoDetail(id) {
@ -247,7 +310,8 @@ export default {
this.$store.dispatch("tagsView/delAllViews"); this.$store.dispatch("tagsView/delAllViews");
this.$store.dispatch("LogOut").then(() => { this.$store.dispatch("LogOut").then(() => {
Cookies.remove("automaticLogin"); Cookies.remove("automaticLogin");
setMenuNode("/index");
this.$store.commit("SET_CURRENT_MENU_NODE", "/index");
this.$router.replace({ path: "/login" }); this.$router.replace({ path: "/login" });
}); });
}) })

View File

@ -1,9 +1,5 @@
<template> <template>
<div <div id="tags-view-container" class="tags-view-container">
id="tags-view-container"
class="tags-view-container"
style="top:10px;margin:0 10px;"
>
<scroll-pane <scroll-pane
ref="scrollPane" ref="scrollPane"
class="tags-view-wrapper" class="tags-view-wrapper"
@ -59,9 +55,8 @@
<script> <script>
import ScrollPane from "./ScrollPane"; import ScrollPane from "./ScrollPane";
import path from "path"; import path from "path";
import { getCompanyId } from "@/utils/auth"; import { getCompanyId, getMenuNode } from "@/utils/auth";
import { ChangeCompany } from "@/api/apis/auth"; import { ChangeCompany } from "@/api/apis/auth";
export default { export default {
components: { components: {
ScrollPane, ScrollPane,
@ -73,12 +68,10 @@ export default {
left: 0, left: 0,
selectedTag: {}, selectedTag: {},
affixTags: [], affixTags: [],
visitedViews: [],
}; };
}, },
computed: { computed: {
visitedViews() {
return this.$store.state.tagsView.visitedViews;
},
routes() { routes() {
return this.$store.state.permission.routes; return this.$store.state.permission.routes;
}, },
@ -90,6 +83,13 @@ export default {
}, },
}, },
watch: { watch: {
"$store.getters.currentMenuNode": {
deep: true,
immediate: true,
handler(newVal, old) {
this.visitedViews = this.getVisitedViews();
},
},
$route() { $route() {
this.addTags(); this.addTags();
this.moveToCurrentTag(); this.moveToCurrentTag();
@ -113,12 +113,33 @@ export default {
}, },
}, },
mounted() { mounted() {
// if (!this.newVersionSystem) { // this.initTags();
// this.initTags(); // this.addTags();
// }
this.addTags();
}, },
methods: { methods: {
getVisitedViews() {
let url = getMenuNode();
let currentData = [];
let data = this.$store.state.tagsView.visitedViews || [];
if (url) {
if (url.includes("Workbench")) {
currentData = data[0];
} else if (url.includes("MasterDataCenter")) {
currentData = data[1];
} else if (url.includes("IntegrationTaskCenter")) {
currentData = data[2];
} else if (url.includes("businessCenter")) {
currentData = data[3];
} else if (url.includes("ApplicationCenter")) {
currentData = data[4];
} else {
currentData = [];
}
} else {
currentData = [];
}
return currentData;
},
async ChangeCompany(CompanyID) { async ChangeCompany(CompanyID) {
let params = { let params = {
CompanyID: CompanyID, CompanyID: CompanyID,
@ -184,6 +205,7 @@ export default {
}, },
initTags() { initTags() {
const affixTags = (this.affixTags = this.filterAffixTags(this.routes)); const affixTags = (this.affixTags = this.filterAffixTags(this.routes));
console.log(affixTags,"affixTags")
for (const tag of affixTags) { for (const tag of affixTags) {
// Must have tag name // Must have tag name
if (tag.name) { if (tag.name) {
@ -196,7 +218,7 @@ export default {
// this.$route.meta.noCache = false // this.$route.meta.noCache = false
if (name) { if (name) {
this.$store.dispatch("tagsView/addView", this.$route); this.$store.dispatch("tagsView/addView", this.$route);
if (this.$route.meta.link) { if (this.$route.meta && this.$route.meta.link) {
this.$store.dispatch("tagsView/addIframeView", this.$route); this.$store.dispatch("tagsView/addIframeView", this.$route);
} }
} }
@ -219,28 +241,89 @@ export default {
}, },
refreshSelectedTag(view) { refreshSelectedTag(view) {
this.$tab.refreshPage(view); this.$tab.refreshPage(view);
if (this.$route.meta.link) { if (this.$route.meta && this.$route.meta.link) {
this.$store.dispatch("tagsView/delIframeView", this.$route); this.$store.dispatch("tagsView/delIframeView", this.$route);
} }
}, },
closeSelectedTag(view) { closeSelectedTag(view) {
this.$tab.closePage(view).then(({ visitedViews }) => { this.$tab.closePage(view).then(({ visitedViews }) => {
let url = getMenuNode();
let currentData = [];
let data = visitedViews;
if (url) {
if (url.includes("Workbench")) {
currentData = data[0];
} else if (url.includes("MasterDataCenter")) {
currentData = data[1];
} else if (url.includes("IntegrationTaskCenter")) {
currentData = data[2];
} else if (url.includes("businessCenter")) {
currentData = data[3];
} else if (url.includes("ApplicationCenter")) {
currentData = data[4];
}
}
if (this.isActive(view)) { if (this.isActive(view)) {
this.toLastView(visitedViews, view); this.toLastView(currentData, view);
} }
}); });
}, },
closeRightTags() { closeRightTags() {
this.$tab.closeRightPage(this.selectedTag).then((visitedViews) => { this.$tab.closeRightPage(this.selectedTag).then((visitedViews) => {
if (!visitedViews.find((i) => i.fullPath === this.$route.fullPath)) { let url = getMenuNode();
this.toLastView(visitedViews); let INDEX = null;
if (url) {
if (url.includes("Workbench")) {
INDEX = 0;
} else if (url.includes("MasterDataCenter")) {
INDEX = 1;
} else if (url.includes("IntegrationTaskCenter")) {
INDEX = 2;
} else if (url.includes("businessCenter")) {
INDEX = 3;
} else if (url.includes("ApplicationCenter")) {
INDEX = 4;
}
}
if (INDEX != null) {
if (
!visitedViews[INDEX].find(
(i) => i.fullPath === this.$route.fullPath
)
) {
this.toLastView(visitedViews[INDEX]);
}
this.visitedViews = this.getVisitedViews();
} }
}); });
}, },
closeLeftTags() { closeLeftTags() {
this.$tab.closeLeftPage(this.selectedTag).then((visitedViews) => { this.$tab.closeLeftPage(this.selectedTag).then((visitedViews) => {
if (!visitedViews.find((i) => i.fullPath === this.$route.fullPath)) { let url = getMenuNode();
this.toLastView(visitedViews); let INDEX = null;
if (url) {
if (url.includes("Workbench")) {
INDEX = 0;
} else if (url.includes("MasterDataCenter")) {
INDEX = 1;
} else if (url.includes("IntegrationTaskCenter")) {
INDEX = 2;
} else if (url.includes("businessCenter")) {
INDEX = 3;
} else if (url.includes("ApplicationCenter")) {
INDEX = 4;
}
}
if (INDEX != null) {
if (
!visitedViews[INDEX].find(
(i) => i.fullPath === this.$route.fullPath
)
) {
this.toLastView(visitedViews[INDEX]);
}
this.visitedViews = this.getVisitedViews();
} }
}); });
}, },
@ -248,14 +331,33 @@ export default {
this.$router.push(this.selectedTag).catch(() => {}); this.$router.push(this.selectedTag).catch(() => {});
this.$tab.closeOtherPage(this.selectedTag).then(() => { this.$tab.closeOtherPage(this.selectedTag).then(() => {
this.moveToCurrentTag(); this.moveToCurrentTag();
this.visitedViews = this.getVisitedViews();
}); });
}, },
closeAllTags(view) { closeAllTags(view) {
this.$tab.closeAllPage().then(({ visitedViews }) => { this.$tab.closeAllPage().then(({ visitedViews }) => {
if (this.affixTags.some((tag) => tag.path === this.$route.path)) { let url = getMenuNode();
return; let INDEX = null;
if (url) {
if (url.includes("Workbench")) {
INDEX = 0;
} else if (url.includes("MasterDataCenter")) {
INDEX = 1;
} else if (url.includes("IntegrationTaskCenter")) {
INDEX = 2;
} else if (url.includes("businessCenter")) {
INDEX = 3;
} else if (url.includes("ApplicationCenter")) {
INDEX = 4;
}
}
if (INDEX != null) {
if (this.affixTags.some((tag) => tag.path === this.$route.path)) {
return;
}
this.toLastView(visitedViews[INDEX], view);
this.visitedViews = this.getVisitedViews();
} }
this.toLastView(visitedViews, view);
}); });
}, },
toLastView(visitedViews, view) { toLastView(visitedViews, view) {
@ -287,8 +389,11 @@ export default {
} else { } else {
this.left = left; this.left = left;
} }
this.top = e.clientY; if (this.newVersionSystem) {
this.top = e.clientY;
} else {
this.top = e.clientY - 40;
}
this.visible = true; this.visible = true;
this.selectedTag = tag; this.selectedTag = tag;
@ -313,16 +418,16 @@ export default {
.tags-view-container { .tags-view-container {
// height: 34px; // height: 34px;
width: 100%; width: calc(100% - 133px);
// width: calc(100% - 180px); // width: calc(100% - 180px);
margin-left: 10px; margin-left: 10px;
background: #fff; background: #fff !important;
border-radius: 4px; border-radius: 4px;
padding: 0px 10px; padding: 0px 10px;
// border-bottom: 1px solid #d8dce5; // border-bottom: 1px solid #d8dce5;
// box-shadow: 0 1px 3px 0 rgba(0, 0, 0, .12), 0 0 3px 0 rgba(0, 0, 0, .04); // box-shadow: 0 1px 3px 0 rgba(0, 0, 0, .12), 0 0 3px 0 rgba(0, 0, 0, .04);
position: fixed; position: fixed;
top: 55px; top: 10px;
// margin-top: 60px; // margin-top: 60px;
z-index: 1000; z-index: 1000;

View File

@ -108,7 +108,7 @@ export default {
}, },
mounted() { mounted() {
this.initTags(); this.initTags();
this.addTags(); // this.addTags();
}, },
methods: { methods: {
isActive(route) { isActive(route) {

View File

@ -18,6 +18,7 @@ const getters = {
sidebarRouters: state => state.permission.sidebarRouters, sidebarRouters: state => state.permission.sidebarRouters,
personInfo: state => state.permission.personInfo, personInfo: state => state.permission.personInfo,
companyID: state => state.user.companyID, companyID: state => state.user.companyID,
currentMenuNode: state => state.user.currentMenuNode,
// tableId: state => state.approval.tableId, // tableId: state => state.approval.tableId,
// isTried: state => state.approval.isTried, // isTried: state => state.approval.isTried,
// flowPermission1: state => state.approval.flowPermission1, // flowPermission1: state => state.approval.flowPermission1,

View File

@ -1,234 +1,506 @@
import { getMenuNode } from "@/utils/auth";
const state = { const state = {
visitedViews: [], visitedViews: [
cachedViews: [], [],
iframeViews: [] [],
[],
[],
[],
],
cachedViews: [
[],
[],
[],
[],
[],
],
iframeViews: [
[],
[],
[],
[],
[],
]
} }
const mutations = { const mutations = {
ADD_IFRAME_VIEW: (state, view) => { ADD_IFRAME_VIEW: (state, view) => {
if (state.iframeViews.some(v => v.path === view.path)) return let url = getMenuNode();
state.iframeViews.push( let Index = null
Object.assign({}, view, { if (url) {
title: view.meta.title || 'no-name' if (url.includes("Workbench")) {
}) Index = 0
) } else if (url.includes("MasterDataCenter")) {
}, Index = 1
ADD_VISITED_VIEW: (state, view) => { } else if (url.includes("IntegrationTaskCenter")) {
if (state.visitedViews.some(v => v.path === view.path)) return Index = 2
state.visitedViews.push( } else if (url.includes("businessCenter")) {
Object.assign({}, view, { Index = 3
title: view.meta.title || 'no-name' } else if (url.includes("ApplicationCenter")) {
}) Index = 4
) }
}, }
ADD_CACHED_VIEW: (state, view) => { if (Index != null) {
if (state.cachedViews.includes(view.name)) return if (state.iframeViews[Index].some(v => v.path === view.path)) return
if (view.meta && !view.meta.noCache) { state.iframeViews[Index].push(
state.cachedViews.push(view.name) Object.assign({}, view, {
} title: view.meta.title || 'no-name'
}, })
DEL_VISITED_VIEW: (state, view) => { )
for (const [i, v] of state.visitedViews.entries()) { }
if (v.path === view.path) { },
state.visitedViews.splice(i, 1) ADD_VISITED_VIEW: (state, view) => {
break let url = getMenuNode();
} let Index = null
} if (url) {
state.iframeViews = state.iframeViews.filter(item => item.path !== view.path) if (url.includes("Workbench")) {
}, Index = 0
DEL_IFRAME_VIEW: (state, view) => { } else if (url.includes("MasterDataCenter")) {
state.iframeViews = state.iframeViews.filter(item => item.path !== view.path) Index = 1
}, } else if (url.includes("IntegrationTaskCenter")) {
DEL_CACHED_VIEW: (state, view) => { Index = 2
const index = state.cachedViews.indexOf(view.name) } else if (url.includes("businessCenter")) {
index > -1 && state.cachedViews.splice(index, 1) Index = 3
}, } else if (url.includes("ApplicationCenter")) {
Index = 4
}
}
if (Index != null) {
if (state.visitedViews[Index].some(v => v.path === view.path)) return
if(view.meta.affix){
state.visitedViews[Index].unshift(
Object.assign({}, view, {
title: view.meta.title || 'no-name'
})
)
}else{
state.visitedViews[Index].push(
Object.assign({}, view, {
title: view.meta.title || 'no-name'
})
)
}
}
},
ADD_CACHED_VIEW: (state, view) => {
let url = getMenuNode();
let Index = null
if (url) {
if (url.includes("Workbench")) {
Index = 0
} else if (url.includes("MasterDataCenter")) {
Index = 1
} else if (url.includes("IntegrationTaskCenter")) {
Index = 2
} else if (url.includes("businessCenter")) {
Index = 3
} else if (url.includes("ApplicationCenter")) {
Index = 4
}
}
if (Index != null) {
if (state.cachedViews[Index].includes(view.name)) return
if (view.meta && !view.meta.noCache) {
state.cachedViews[Index].push(view.name)
}
}
},
DEL_VISITED_VIEW: (state, view) => {
let url = getMenuNode();
let Index = null
if (url) {
if (url.includes("Workbench")) {
Index = 0
} else if (url.includes("MasterDataCenter")) {
Index = 1
} else if (url.includes("IntegrationTaskCenter")) {
Index = 2
} else if (url.includes("businessCenter")) {
Index = 3
} else if (url.includes("ApplicationCenter")) {
Index = 4
}
}
if (Index != null) {
for (const [i, v] of state.visitedViews[Index].entries()) {
if (v.path === view.path) {
state.visitedViews[Index].splice(i, 1)
break
}
}
state.iframeViews[Index] = state.iframeViews[Index].filter(item => item.path !== view.path)
}
},
DEL_IFRAME_VIEW: (state, view) => {
let url = getMenuNode();
let Index = null
if (url) {
if (url.includes("Workbench")) {
Index = 0
} else if (url.includes("MasterDataCenter")) {
Index = 1
} else if (url.includes("IntegrationTaskCenter")) {
Index = 2
} else if (url.includes("businessCenter")) {
Index = 3
} else if (url.includes("ApplicationCenter")) {
Index = 4
}
}
if (Index != null) {
state.iframeViews[Index] = state.iframeViews[Index].filter(item => item.path !== view.path)
}
},
DEL_CACHED_VIEW: (state, view) => {
let url = getMenuNode();
let Index = null
if (url) {
if (url.includes("Workbench")) {
Index = 0
} else if (url.includes("MasterDataCenter")) {
Index = 1
} else if (url.includes("IntegrationTaskCenter")) {
Index = 2
} else if (url.includes("businessCenter")) {
Index = 3
} else if (url.includes("ApplicationCenter")) {
Index = 4
}
}
if (Index != null) {
const index = state.cachedViews[Index].indexOf(view.name)
index > -1 && state.cachedViews[Index].splice(index, 1)
}
},
DEL_OTHERS_VISITED_VIEWS: (state, view) => {
let url = getMenuNode();
let Index = null
if (url) {
if (url.includes("Workbench")) {
Index = 0
} else if (url.includes("MasterDataCenter")) {
Index = 1
} else if (url.includes("IntegrationTaskCenter")) {
Index = 2
} else if (url.includes("businessCenter")) {
Index = 3
} else if (url.includes("ApplicationCenter")) {
Index = 4
}
}
if (Index != null) {
state.visitedViews[Index] = state.visitedViews[Index].filter(v => {
return v.meta.affix || v.path === view.path
})
state.iframeViews[Index] = state.iframeViews[Index].filter(item => item.path === view.path)
}
},
DEL_OTHERS_CACHED_VIEWS: (state, view) => {
let url = getMenuNode();
let INDEX = null
if (url) {
if (url.includes("Workbench")) {
INDEX = 0
} else if (url.includes("MasterDataCenter")) {
INDEX = 1
} else if (url.includes("IntegrationTaskCenter")) {
INDEX = 2
} else if (url.includes("businessCenter")) {
INDEX = 3
} else if (url.includes("ApplicationCenter")) {
INDEX = 4
}
}
if (INDEX != null) {
const index = state.cachedViews[INDEX].indexOf(view.name)
if (index > -1) {
state.cachedViews[INDEX] = state.cachedViews[INDEX].slice(index, index + 1)
} else {
state.cachedViews[INDEX] = []
}
}
},
DEL_ALL_VISITED_VIEWS: state => {
// keep affix tags
let url = getMenuNode();
let INDEX = null
if (url) {
if (url.includes("Workbench")) {
INDEX = 0
} else if (url.includes("MasterDataCenter")) {
INDEX = 1
} else if (url.includes("IntegrationTaskCenter")) {
INDEX = 2
} else if (url.includes("businessCenter")) {
INDEX = 3
} else if (url.includes("ApplicationCenter")) {
INDEX = 4
}
}
if (INDEX != null) {
const affixTags = state.visitedViews[INDEX].filter(tag => tag.meta.affix)
state.visitedViews[INDEX] = affixTags
state.iframeViews[INDEX] = []
}
},
DEL_ALL_CACHED_VIEWS: state => {
let url = getMenuNode();
let INDEX = null
if (url) {
if (url.includes("Workbench")) {
INDEX = 0
} else if (url.includes("MasterDataCenter")) {
INDEX = 1
} else if (url.includes("IntegrationTaskCenter")) {
INDEX = 2
} else if (url.includes("businessCenter")) {
INDEX = 3
} else if (url.includes("ApplicationCenter")) {
INDEX = 4
}
}
if (INDEX != null) {
state.cachedViews[INDEX] = []
}
},
CLEAR_VISTEDVIEWS: state => {
let url = getMenuNode();
let INDEX = null
if (url) {
if (url.includes("Workbench")) {
INDEX = 0
} else if (url.includes("MasterDataCenter")) {
INDEX = 1
} else if (url.includes("IntegrationTaskCenter")) {
INDEX = 2
} else if (url.includes("businessCenter")) {
INDEX = 3
} else if (url.includes("ApplicationCenter")) {
INDEX = 4
}
}
if (INDEX != null) {
state.visitedViews[INDEX] = []
}
},
UPDATE_VISITED_VIEW: (state, view) => {
let url = getMenuNode();
let INDEX = null
if (url) {
if (url.includes("Workbench")) {
INDEX = 0
} else if (url.includes("MasterDataCenter")) {
INDEX = 1
} else if (url.includes("IntegrationTaskCenter")) {
INDEX = 2
} else if (url.includes("businessCenter")) {
INDEX = 3
} else if (url.includes("ApplicationCenter")) {
INDEX = 4
}
}
if (INDEX != null) {
for (let v of state.visitedViews[INDEX]) {
if (v.path === view.path) {
v = Object.assign(v, view)
break
}
}
}
},
DEL_RIGHT_VIEWS: (state, view) => {
let url = getMenuNode();
let INDEX = null
if (url) {
if (url.includes("Workbench")) {
INDEX = 0
} else if (url.includes("MasterDataCenter")) {
INDEX = 1
} else if (url.includes("IntegrationTaskCenter")) {
INDEX = 2
} else if (url.includes("businessCenter")) {
INDEX = 3
} else if (url.includes("ApplicationCenter")) {
INDEX = 4
}
}
if (INDEX != null) {
const index = state.visitedViews[INDEX].findIndex(v => v.path === view.path)
if (index === -1) {
return
}
state.visitedViews[INDEX] = state.visitedViews[INDEX].filter((item, idx) => {
if (idx <= index || (item.meta && item.meta.affix)) {
return true
}
const i = state.cachedViews[INDEX].indexOf(item.name)
if (i > -1) {
state.cachedViews[INDEX].splice(i, 1)
}
if (item.meta && item.meta.link) {
const fi = state.iframeViews[INDEX].findIndex(v => v.path === item.path)
state.iframeViews[INDEX].splice(fi, 1)
}
return false
})
}
},
DEL_LEFT_VIEWS: (state, view) => {
let url = getMenuNode();
let INDEX = null
if (url) {
if (url.includes("Workbench")) {
INDEX = 0
} else if (url.includes("MasterDataCenter")) {
INDEX = 1
} else if (url.includes("IntegrationTaskCenter")) {
INDEX = 2
} else if (url.includes("businessCenter")) {
INDEX = 3
} else if (url.includes("ApplicationCenter")) {
INDEX = 4
}
}
if (INDEX != null) {
const index = state.visitedViews[INDEX].findIndex(v => v.path === view.path)
if (index === -1) {
return
}
state.visitedViews[INDEX] = state.visitedViews[INDEX].filter((item, idx) => {
if (idx >= index || (item.meta && item.meta.affix)) {
return true
}
const i = state.cachedViews[INDEX].indexOf(item.name)
if (i > -1) {
state.cachedViews[INDEX].splice(i, 1)
}
if (item.meta && item.meta.link) {
const fi = state.iframeViews[INDEX].findIndex(v => v.path === item.path)
state.iframeViews[INDEX].splice(fi, 1)
}
return false
})
}
DEL_OTHERS_VISITED_VIEWS: (state, view) => {
state.visitedViews = state.visitedViews.filter(v => {
return v.meta.affix || v.path === view.path
})
state.iframeViews = state.iframeViews.filter(item => item.path === view.path)
},
DEL_OTHERS_CACHED_VIEWS: (state, view) => {
const index = state.cachedViews.indexOf(view.name)
if (index > -1) {
state.cachedViews = state.cachedViews.slice(index, index + 1)
} else {
state.cachedViews = []
} }
},
DEL_ALL_VISITED_VIEWS: state => {
// keep affix tags
const affixTags = state.visitedViews.filter(tag => tag.meta.affix)
state.visitedViews = affixTags
state.iframeViews = []
},
DEL_ALL_CACHED_VIEWS: state => {
state.cachedViews = []
},
UPDATE_VISITED_VIEW: (state, view) => {
for (let v of state.visitedViews) {
if (v.path === view.path) {
v = Object.assign(v, view)
break
}
}
},
DEL_RIGHT_VIEWS: (state, view) => {
const index = state.visitedViews.findIndex(v => v.path === view.path)
if (index === -1) {
return
}
state.visitedViews = state.visitedViews.filter((item, idx) => {
if (idx <= index || (item.meta && item.meta.affix)) {
return true
}
const i = state.cachedViews.indexOf(item.name)
if (i > -1) {
state.cachedViews.splice(i, 1)
}
if(item.meta.link) {
const fi = state.iframeViews.findIndex(v => v.path === item.path)
state.iframeViews.splice(fi, 1)
}
return false
})
},
CLEAR_VISTEDVIEWS:state =>{
state.visitedViews = []
},
DEL_LEFT_VIEWS: (state, view) => {
const index = state.visitedViews.findIndex(v => v.path === view.path)
if (index === -1) {
return
}
state.visitedViews = state.visitedViews.filter((item, idx) => {
if (idx >= index || (item.meta && item.meta.affix)) {
return true
}
const i = state.cachedViews.indexOf(item.name)
if (i > -1) {
state.cachedViews.splice(i, 1)
}
if(item.meta.link) {
const fi = state.iframeViews.findIndex(v => v.path === item.path)
state.iframeViews.splice(fi, 1)
}
return false
})
}
} }
const actions = { const actions = {
addView({ dispatch }, view) { addView({ dispatch }, view) {
dispatch('addVisitedView', view) dispatch('addVisitedView', view)
dispatch('addCachedView', view) dispatch('addCachedView', view)
}, },
clearVisted({commit}){ clearVisted({ commit }) {
commit('CLEAR_VISTEDVIEWS') commit('CLEAR_VISTEDVIEWS')
},
addIframeView({ commit }, view) { },
commit('ADD_IFRAME_VIEW', view)
}, addIframeView({ commit }, view) {
addVisitedView({ commit }, view) { commit('ADD_IFRAME_VIEW', view)
commit('ADD_VISITED_VIEW', view) },
}, addVisitedView({ commit }, view) {
addCachedView({ commit }, view) { commit('ADD_VISITED_VIEW', view)
commit('ADD_CACHED_VIEW', view) },
}, addCachedView({ commit }, view) {
delView({ dispatch, state }, view) { commit('ADD_CACHED_VIEW', view)
return new Promise(resolve => { },
dispatch('delVisitedView', view) delView({ dispatch, state }, view) {
dispatch('delCachedView', view) return new Promise(resolve => {
resolve({ dispatch('delVisitedView', view)
visitedViews: [...state.visitedViews], dispatch('delCachedView', view)
cachedViews: [...state.cachedViews] resolve({
}) visitedViews: [...state.visitedViews],
}) cachedViews: [...state.cachedViews]
}, })
delVisitedView({ commit, state }, view) { })
return new Promise(resolve => { },
commit('DEL_VISITED_VIEW', view) delVisitedView({ commit, state }, view) {
resolve([...state.visitedViews]) return new Promise(resolve => {
}) commit('DEL_VISITED_VIEW', view)
}, resolve([...state.visitedViews])
delIframeView({ commit, state }, view) { })
return new Promise(resolve => { },
commit('DEL_IFRAME_VIEW', view) delIframeView({ commit, state }, view) {
resolve([...state.iframeViews]) return new Promise(resolve => {
}) commit('DEL_IFRAME_VIEW', view)
}, resolve([...state.iframeViews])
delCachedView({ commit, state }, view) { })
return new Promise(resolve => { },
commit('DEL_CACHED_VIEW', view) delCachedView({ commit, state }, view) {
resolve([...state.cachedViews]) return new Promise(resolve => {
}) commit('DEL_CACHED_VIEW', view)
}, resolve([...state.cachedViews])
delOthersViews({ dispatch, state }, view) { })
return new Promise(resolve => { },
dispatch('delOthersVisitedViews', view) delOthersViews({ dispatch, state }, view) {
dispatch('delOthersCachedViews', view) return new Promise(resolve => {
resolve({ dispatch('delOthersVisitedViews', view)
visitedViews: [...state.visitedViews], dispatch('delOthersCachedViews', view)
cachedViews: [...state.cachedViews] resolve({
}) visitedViews: [...state.visitedViews],
}) cachedViews: [...state.cachedViews]
}, })
delOthersVisitedViews({ commit, state }, view) { })
return new Promise(resolve => { },
commit('DEL_OTHERS_VISITED_VIEWS', view) delOthersVisitedViews({ commit, state }, view) {
resolve([...state.visitedViews]) return new Promise(resolve => {
}) commit('DEL_OTHERS_VISITED_VIEWS', view)
}, resolve([...state.visitedViews])
delOthersCachedViews({ commit, state }, view) { })
return new Promise(resolve => { },
commit('DEL_OTHERS_CACHED_VIEWS', view) delOthersCachedViews({ commit, state }, view) {
resolve([...state.cachedViews]) return new Promise(resolve => {
}) commit('DEL_OTHERS_CACHED_VIEWS', view)
}, resolve([...state.cachedViews])
delAllViews({ dispatch, state }, view) { })
return new Promise(resolve => { },
dispatch('delAllVisitedViews', view) delAllViews({ dispatch, state }, view) {
dispatch('delAllCachedViews', view) return new Promise(resolve => {
resolve({ dispatch('delAllVisitedViews', view)
visitedViews: [...state.visitedViews], dispatch('delAllCachedViews', view)
cachedViews: [...state.cachedViews] resolve({
}) visitedViews: [...state.visitedViews],
}) cachedViews: [...state.cachedViews]
}, })
delAllVisitedViews({ commit, state }) { })
return new Promise(resolve => { },
commit('DEL_ALL_VISITED_VIEWS') delAllVisitedViews({ commit, state }) {
resolve([...state.visitedViews]) return new Promise(resolve => {
}) commit('DEL_ALL_VISITED_VIEWS')
}, resolve([...state.visitedViews])
delAllCachedViews({ commit, state }) { })
return new Promise(resolve => { },
commit('DEL_ALL_CACHED_VIEWS') delAllCachedViews({ commit, state }) {
resolve([...state.cachedViews]) return new Promise(resolve => {
}) commit('DEL_ALL_CACHED_VIEWS')
}, resolve([...state.cachedViews])
updateVisitedView({ commit }, view) { })
commit('UPDATE_VISITED_VIEW', view) },
}, updateVisitedView({ commit }, view) {
delRightTags({ commit }, view) { commit('UPDATE_VISITED_VIEW', view)
return new Promise(resolve => { },
commit('DEL_RIGHT_VIEWS', view) delRightTags({ commit }, view) {
resolve([...state.visitedViews]) return new Promise(resolve => {
}) commit('DEL_RIGHT_VIEWS', view)
}, resolve([...state.visitedViews])
delLeftTags({ commit }, view) { })
return new Promise(resolve => { },
commit('DEL_LEFT_VIEWS', view) delLeftTags({ commit }, view) {
resolve([...state.visitedViews]) return new Promise(resolve => {
}) commit('DEL_LEFT_VIEWS', view)
}, resolve([...state.visitedViews])
})
},
} }
export default { export default {
namespaced: true, namespaced: true,
state, state,
mutations, mutations,
actions actions
} }

View File

@ -19,7 +19,8 @@ const user = {
info: {}, info: {},
companyID: "", companyID: "",
companyListAll: [], companyListAll: [],
messageCount:0 messageCount:0,
currentMenuNode:"",//目的是 结合cokkie 实时监听当前导航栏的变化
}, },
mutations: { mutations: {
@ -49,7 +50,10 @@ const user = {
}, },
SET_MESSAGE_COUNT: (state, messageCount) => { SET_MESSAGE_COUNT: (state, messageCount) => {
state.messageCount = messageCount state.messageCount = messageCount
} },
SET_CURRENT_MENU_NODE: (state, currentMenuNode) => {
state.currentMenuNode = currentMenuNode
},
}, },
actions: { actions: {

View File

@ -3,6 +3,7 @@ import Cookies from 'js-cookie'
const TokenKey = 'zhongtai-Token' const TokenKey = 'zhongtai-Token'
const InfoKey = 'zhongtai-Info' const InfoKey = 'zhongtai-Info'
const CompanyId = 'Company-Id' const CompanyId = 'Company-Id'
const MenuNode = "Menu-Node"
export function getToken() { export function getToken() {
return Cookies.get(TokenKey) return Cookies.get(TokenKey)
@ -42,3 +43,14 @@ export function setCompanyId(info) {
export function removeCompanyId() { export function removeCompanyId() {
return Cookies.remove(CompanyId) return Cookies.remove(CompanyId)
} }
export function getMenuNode() {
return Cookies.get(MenuNode);
}
export function setMenuNode(info) {
return Cookies.set(MenuNode, info);
}
export function removeMenuNode() {
return Cookies.remove(MenuNode);
}

View File

@ -70,7 +70,12 @@
import { encrypt, decrypt } from "@/utils/jsencrypt"; import { encrypt, decrypt } from "@/utils/jsencrypt";
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import { OrganGetUserCompany } from "@/api/apis/organization.js"; import { OrganGetUserCompany } from "@/api/apis/organization.js";
import { setCompanyId } from "@/utils/auth.js"; import {
setCompanyId,
removeMenuNode,
getMenuNode,
setMenuNode,
} from "@/utils/auth.js";
import { import {
OtherGetBillList, OtherGetBillList,
OtherSaveData, OtherSaveData,
@ -260,11 +265,15 @@ export default {
.push({ .push({
path: this.redirect || "/", path: this.redirect || "/",
}) })
.then(() => {
setMenuNode("/index");
this.$store.commit("SET_CURRENT_MENU_NODE", "/index");
})
.catch(() => {}); .catch(() => {});
}) })
.catch(() => { .catch(() => {
this.loading = false; this.loading = false;
console.log(123,'123') console.log(123, "123");
}); });
} }
}); });

View File

@ -1,5 +1,5 @@
/** /**
desc 应用管理 desc 业务中心
*/ */
<template> <template>
<div class="workbench"> <div class="workbench">