From 7302dadaba783c1346b47b40f533280d6c3e4fa2 Mon Sep 17 00:00:00 2001 From: liupengpeng <276665548@qq.com> Date: 星期五, 10 二月 2023 15:34:31 +0800 Subject: [PATCH] 页面刷新还在本页面 --- src/views/PackageTwo/WareInspection.vue | 52 +++++++++++- src/views/datamanage/dataController.vue | 26 ++++++ src/components/login.vue | 1 src/views/Thematic/index.vue | 1 src/views/maintenance/mochaitmo.vue | 29 +++++++ src/components/navMenu.vue | 48 +++++++++++- src/App.vue | 18 ++++ src/router/index.js | 11 ++ 8 files changed, 176 insertions(+), 10 deletions(-) diff --git a/src/App.vue b/src/App.vue index 1f9c81a..cb0be87 100644 --- a/src/App.vue +++ b/src/App.vue @@ -18,6 +18,24 @@ }, created() { }, + mounted () { + window.addEventListener('beforeunload', e => { + sessionStorage.setItem('beforeunload', 1); + }); + // 鐩戝惉椤甸潰鍒锋柊 + if (sessionStorage.getItem('beforeunload') == 1) { + let name = sessionStorage.getItem("routerName"); + if (name) { + this.$nextTick(function () { + this.$router.push({ path: name }); //濡傛灉sessionStorage瀛樺湪璺敱锛屽幓缂撳瓨鐨勮矾鐢� + }) + } else { + this.$nextTick(function () { + this.$router.push({ path: '/' }); //涓嶅瓨鍦ㄥ瓨鍌紝鍘讳富椤� + }) + } + } + }, beforeDestroy() { }, }; </script> diff --git a/src/components/login.vue b/src/components/login.vue index daf1d2f..2129630 100644 --- a/src/components/login.vue +++ b/src/components/login.vue @@ -257,6 +257,7 @@ this.$store.commit('getPermsEntity', res.result); if (res.result.length != 0) { + sessionStorage.setItem('routerName', '/Synthesis') this.$router.push('/'); } this.loading = false diff --git a/src/components/navMenu.vue b/src/components/navMenu.vue index 031434b..657aef7 100644 --- a/src/components/navMenu.vue +++ b/src/components/navMenu.vue @@ -117,7 +117,32 @@ listMenu: [], showFlag: null, language: true, - + nowPage: [ + { + name: '/Archive', + index: 3 + }, + { + name: '/dataApplication', + index: 3 + }, + { + name: '/ExportMap', + index: 3 + }, + { + name: '/Synthesis', + index: 3 + }, + { + name: '/dataController', + index: 4 + }, + { + name: '/mochaitmo', + index: 5 + } + ] }; }, created() { }, @@ -187,7 +212,7 @@ this.showFlag = null; } } - + sessionStorage.setItem('changeSelectStyle', index) this.changeSelectStyle = index; }, closeAllChildren() { @@ -211,9 +236,11 @@ }, setLiClick(res, index) { setTimeout(() => { + // debu this.changeliSelect = res.cnName; if (res.url.indexOf('http') != -1) { - this.$store.reporturl = res.url; + this.$store.reporturl = res.url; + sessionStorage.setItem('iframehttpurl', this.$store.reporturl) this.$router.push('/QualityInspection'); // if (location.href.indexOf('/WareInspection') == -1) { // this.$store.reporturl = res.url; @@ -223,6 +250,7 @@ // } } else { this.$store.reporturl = null; + sessionStorage.setItem('iframehttpurl', null) this.$router.push(res.url); this.$store.commit('currentPerms', res.perms); } @@ -268,7 +296,19 @@ } this.listMenu.push(res[i]); - this.changeSelectStyle = this.listMenu.length - 1; + // this.changeSelectStyle = this.listMenu.length - 1; + // this.changeSelectStyle = 0 + // const nowPage = this.nowPage + // if (sessionStorage.getItem('routerName')) { + // for (let index = 0; index < nowPage.length; index++) { + // if (this.$route.path === nowPage[index].name) { + // this.$set(this, 'changeSelectStyle', nowPage[index].index) + // } + // } + // } else { + // this.changeSelectStyle = this.listMenu.length - 1; + // } + this.changeSelectStyle = sessionStorage.getItem('changeSelectStyle') // var strartMneu = res[i].children[0]; // this.$store.commit('currentPerms', strartMneu.perms); // this.changeliSelect = strartMneu.cnName; diff --git a/src/router/index.js b/src/router/index.js index 66b4e9a..fb520a9 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -53,7 +53,15 @@ const originalPush = VueRouter.prototype.push; VueRouter.prototype.push = function push(location) { - return originalPush.call(this, location).catch((err) => err); + const nowPage = sessionStorage.getItem('routerName') + const page = { + path: nowPage + } + if (page === location || location === '/') { + return originalPush.call(this, page).catch((err) => err); + } else { + return originalPush.call(this, location).catch((err) => err); + } }; // 缇ょ粍绠$悊 @@ -462,6 +470,7 @@ }); //璺敱瀹堝崼 router.beforeEach((to, from, next) => { + sessionStorage.setItem('routerName', to.path) next(); if (to.matched.some((auth) => auth.meta.requireAuth)) { // 鑾峰彇token diff --git a/src/views/PackageTwo/WareInspection.vue b/src/views/PackageTwo/WareInspection.vue index 3cad44b..69c06cc 100644 --- a/src/views/PackageTwo/WareInspection.vue +++ b/src/views/PackageTwo/WareInspection.vue @@ -49,6 +49,8 @@ }, showChangeIfream(res) { + // debugger + console.log(res) if (this.$store.state.themeflag == true) { if (res.indexOf('theme=white') != -1) { res = res.replace('theme=white', 'theme=dark'); @@ -80,15 +82,55 @@ this.$store.state.reporturl = res; this.reportUrl = res; this.url = res + // sessionStorage.setItem('routerName', this.reportUrl) console.log("2", this.reportUrl) - } + }, + + setLiClick(res, index) { + var timer = setTimeout(function () { + if (res.indexOf('http') != -1) { + this.$store.reporturl = res; + // sessionStorage.setItem('iframehttpurl', this.$store.reporturl) + this.$router.push('/QualityInspection'); + // if (location.href.indexOf('/WareInspection') == -1) { + // this.$store.reporturl = res.url; + // this.$router.push('/WareInspection'); + // } else { + // this.$bus.$emit('changeNaveUrl', res.url); + // } + } + this.setShowFalseDiv(false) + }, 100) + clearTimeout(timer) + }, + setShowFalseDiv(bolean) { + var index = this.showFlag; + if (index != null) { + let newItem = this.listMenu[index]; + + newItem.show = bolean; + Vue.set(this.listMenu, index, newItem); + } + }, }, mounted() { - this.showChangeIfream(this.$store.reporturl) + // console.log(sessionStorage.getItem('iframehttpurl')) + // debugger + if (sessionStorage.getItem('routerName') === '/WareInspection') { + + this.showChangeIfream(sessionStorage.getItem('iframehttpurl')) + this.setLiClick(sessionStorage.getItem('iframehttpurl')) - this.$bus.$on('changeNaveUrl', (res) => { - this.showChangeIfream(res) - }); + this.$bus.$on('changeNaveUrl', (res) => { + this.showChangeIfream(res) + }); + } else { + this.showChangeIfream(this.$store.reporturl) + + this.$bus.$on('changeNaveUrl', (res) => { + this.showChangeIfream(res) + }); + } } } diff --git a/src/views/Thematic/index.vue b/src/views/Thematic/index.vue index 9501c3e..ceecc2c 100644 --- a/src/views/Thematic/index.vue +++ b/src/views/Thematic/index.vue @@ -379,6 +379,7 @@ methods: { setTopReturn() { this.$router.push('/Synthesis'); + sessionStorage.setItem('changeSelectStyle', 3) }, changeRightList(res) { this.changeSelectli = res.id; diff --git a/src/views/datamanage/dataController.vue b/src/views/datamanage/dataController.vue index 1ddb659..7e07958 100644 --- a/src/views/datamanage/dataController.vue +++ b/src/views/datamanage/dataController.vue @@ -160,6 +160,14 @@ this.menuList = this.treeData(menuList); this.setViewController(this.menuList[0]); + + const hanleselectindex = sessionStorage.getItem('hanleselectindex') + if (hanleselectindex) { + this.$nextTick(function (){ + this.handleselecttwo(JSON.parse(hanleselectindex).url, JSON.parse(hanleselectindex)) + this.setViewController(JSON.parse(hanleselectindex)) + }) + } } else { this.$message.error('鏆傛棤鑿滃崟鏍忔暟鎹�'); @@ -198,6 +206,8 @@ }, handleselect(index, indexPath, e) { + const a = JSON.stringify(e.$attrs.perms) + sessionStorage.setItem('hanleselectindex', a) var data = e.$attrs.perms; this.$store.state.currentPerms = data.perms; var index = data.url; @@ -210,6 +220,22 @@ } this.setMenuFlag = index; }, + + handleselecttwo(index, e) { + const a = JSON.stringify(e) + sessionStorage.setItem('hanleselectindex', a) + var data = e; + this.$store.state.currentPerms = data.perms; + var index = data.url; + + if (index != null) { + if (index.indexOf('http') != -1) { + this.$store.commit('getIframe', data.url); + index = 'dataIfream'; + } + } + this.setMenuFlag = index; + }, }, }; </script> diff --git a/src/views/maintenance/mochaitmo.vue b/src/views/maintenance/mochaitmo.vue index d312f21..8d26554 100644 --- a/src/views/maintenance/mochaitmo.vue +++ b/src/views/maintenance/mochaitmo.vue @@ -203,6 +203,13 @@ }); this.menuList = this.treeData(menuList); this.getCookies(); + const hanleselectmochaitmo = sessionStorage.getItem('hanleselectmochaitmo') + if (hanleselectmochaitmo) { + this.$nextTick(function (){ + this.handleselecttwo(JSON.parse(hanleselectmochaitmo).url, JSON.parse(hanleselectmochaitmo)) + this.setViewController(JSON.parse(hanleselectmochaitmo)) + }) + } // } else { alert('鏆傛棤鑿滃崟鏍忔暟鎹�'); @@ -244,6 +251,10 @@ handleselect(index, indexPath, e) { this.getTimeCookies(); + + const a = JSON.stringify(e.$attrs.perms) + sessionStorage.setItem('hanleselectmochaitmo', a) + var data = e.$attrs.perms; this.$store.state.currentPerms = data.perms; var index = data.url; @@ -256,6 +267,24 @@ this.setMenuFlag = index; }, + handleselecttwo(index, e) { + this.getTimeCookies(); + + const a = JSON.stringify(e) + sessionStorage.setItem('hanleselectmochaitmo', a) + + var data = e; + this.$store.state.currentPerms = data.perms; + var index = data.url; + if (index != null) { + if (index.indexOf('http') != -1) { + this.$store.commit('getIframe', data.url); + index = 'dataIfream'; + } + } + this.setMenuFlag = index; + + }, }, }; </script> -- Gitblit v1.9.3