diff --git a/src/utils/tools.js b/src/utils/tools.js index 5d5de854..94f01787 100644 --- a/src/utils/tools.js +++ b/src/utils/tools.js @@ -5,6 +5,7 @@ import { storageKey, iso36112, topDomain, echartsFontSize, dbGeoDataTableName, n import { getIso36112JsonData, getDictList } from '@/utils/api' import { format } from 'echarts' import router from '@/router' +import store from '@/store' import indexedDBUtils from '@/indexedDB' export const tableSort = { @@ -1317,3 +1318,34 @@ export function switchStatus (status) { return 'Enabled' } } + +/** + * 在路由跳转前,即下钻前将路由数据保存起来,确保回退和前进保留当时状态 + */ +export function beforeRouterPush () { + const currentRouter = _.cloneDeep(router.currentRoute.value.query) + const historyList = _.cloneDeep(store.getters.getRouterHistoryList) + + const tempObj = { + t: currentRouter.t, + query: currentRouter, + path: _.cloneDeep(router.currentRoute.value.path), + params: _.cloneDeep(router.currentRoute.value.params) + } + if (historyList.length > 0) { + let flag = true + historyList.forEach((item, index) => { + if (item.t === currentRouter.t) { + historyList[index] = tempObj + flag = false + } + if (!flag) { + return true + } + }) + if (flag) historyList.push(tempObj) + } else { + historyList.push(tempObj) + } + store.commit('setRouterHistoryList', historyList) +} diff --git a/src/views/charts2/charts/linkMonitor/LinkBlock.vue b/src/views/charts2/charts/linkMonitor/LinkBlock.vue index 6d03968f..c5508e65 100644 --- a/src/views/charts2/charts/linkMonitor/LinkBlock.vue +++ b/src/views/charts2/charts/linkMonitor/LinkBlock.vue @@ -116,7 +116,7 @@ import chartMixin from '@/views/charts2/chart-mixin' import { useRoute } from 'vue-router' import { ref } from 'vue' import { api } from '@/utils/api' -import { colorGradientCalculation } from '@/utils/tools' +import { colorGradientCalculation, beforeRouterPush } from '@/utils/tools' import unitConvert from '@/utils/unit-convert' import { drillDownPanelTypeMapping, storageKey, unitTypes } from '@/utils/constants' import { getSecond } from '@/utils/date-util' @@ -372,6 +372,7 @@ export default { }, drillLinkId (item) { const queryCondition = `common_out_link_id = ${item.outLinkId} or common_in_link_id = ${item.inLinkId}` + beforeRouterPush() this.$router.push({ query: { ...this.$route.query, diff --git a/src/views/charts2/charts/networkOverview/NetworkOverviewPerformanceEvent.vue b/src/views/charts2/charts/networkOverview/NetworkOverviewPerformanceEvent.vue index d34e4d93..b2f1d14a 100644 --- a/src/views/charts2/charts/networkOverview/NetworkOverviewPerformanceEvent.vue +++ b/src/views/charts2/charts/networkOverview/NetworkOverviewPerformanceEvent.vue @@ -32,7 +32,7 @@ import { getSecond } from '@/utils/date-util' import ChartNoData from '@/views/charts/charts/ChartNoData' import chartMixin from '@/views/charts2/chart-mixin' import ChartError from '@/components/common/Error' -import { getIndexByEventSeverity } from '@/utils/tools' +import { getIndexByEventSeverity, beforeRouterPush } from '@/utils/tools' export default { name: 'NetworkOverviewPerformanceEvent', setup () { @@ -65,7 +65,7 @@ export default { startTime: getSecond(this.timeFilter.startTime), endTime: getSecond(this.timeFilter.endTime) } - /*const dom = document.getElementById('chart1') + /* const dom = document.getElementById('chart1') const dom2 = document.getElementById('chart2') if (dom) { if (!this.myChart) { @@ -145,7 +145,7 @@ export default { }).finally(() => { this.loading2 = false }) - }*/ + } */ this.loading1 = false this.loading2 = false this.isNoData = true @@ -153,6 +153,7 @@ export default { this.toggleLoading(false) }, routerJump () { + beforeRouterPush() const params = { startTime: this.timeFilter.startTime, endTime: this.timeFilter.endTime, diff --git a/src/views/charts2/charts/networkOverview/NetworkOverviewTabs.vue b/src/views/charts2/charts/networkOverview/NetworkOverviewTabs.vue index 4327d338..aa56add8 100644 --- a/src/views/charts2/charts/networkOverview/NetworkOverviewTabs.vue +++ b/src/views/charts2/charts/networkOverview/NetworkOverviewTabs.vue @@ -293,7 +293,7 @@ import { } from '@/utils/constants' import axios from 'axios' import unitConvert, { valueToRangeValue } from '@/utils/unit-convert' -import { getChainRatio, computeScore, urlParamsHandler, overwriteUrl, readDrilldownTableConfigByUser, combineDrilldownTableWithUserConfig, getDnsMapData, handleSpecialValue, getConfigVersion } from '@/utils/tools' +import { getChainRatio, computeScore, urlParamsHandler, overwriteUrl, readDrilldownTableConfigByUser, combineDrilldownTableWithUserConfig, getDnsMapData, handleSpecialValue, getConfigVersion, beforeRouterPush } from '@/utils/tools' import { getSecond } from '@/utils/date-util' import chartMixin from '@/views/charts2/chart-mixin' import _ from 'lodash' @@ -1449,7 +1449,7 @@ export default { overwriteUrl(newUrl) } // 下钻前保存当前路由状态 - this.beforeRouterPush() + beforeRouterPush() const clickTab = this.getTabByName(columnName)// 下钻后,显示的下钻tab对应的drilldownTabs const tabLable = clickTab.label const tabName = clickTab.name @@ -1539,36 +1539,6 @@ export default { } }) }, - /** - * 在路由跳转前,即下钻前将路由数据保存起来,确保回退和前进保留当时状态 - */ - beforeRouterPush () { - const currentRouter = this.$_.cloneDeep(this.$route.query) - const historyList = this.$_.cloneDeep(this.$store.getters.getRouterHistoryList) - - const tempObj = { - t: currentRouter.t, - query: currentRouter, - path: this.$_.cloneDeep(this.$route.path), - params: this.$_.cloneDeep(this.$route.params) - } - if (historyList.length > 0) { - let flag = true - historyList.forEach((item, index) => { - if (item.t === currentRouter.t) { - historyList[index] = tempObj - flag = false - } - if (!flag) { - return true - } - }) - if (flag) historyList.push(tempObj) - } else { - historyList.push(tempObj) - } - this.$store.commit('setRouterHistoryList', historyList) - }, handleSearchParams (columnValue) { columnValue = handleSpecialValue(columnValue)// columnValue.replaceAll("'", "\\\\'") const queryCondition = [] diff --git a/src/views/charts2/charts/npm/NpmRecentEvents.vue b/src/views/charts2/charts/npm/NpmRecentEvents.vue index a941eb2c..d8186652 100644 --- a/src/views/charts2/charts/npm/NpmRecentEvents.vue +++ b/src/views/charts2/charts/npm/NpmRecentEvents.vue @@ -56,6 +56,7 @@ import { ref } from 'vue' import ChartError from '@/components/common/Error' import axios from 'axios' import { dataForNpmRecentEvents } from '@/utils/static-data' +import { beforeRouterPush } from '@/utils/tools' export default { name: 'NpmRecentEvents', @@ -108,7 +109,7 @@ export default { url = api.npm.events.recentEvents } - /*this.toggleLoading(true) + /* this.toggleLoading(true) axios.get(url, { params: params }).then(response => { const res = response.data if (response.status === 200) { @@ -129,7 +130,7 @@ export default { this.httpError(e) }).finally(() => { this.toggleLoading(false) - })*/ + }) */ this.isNoData = true this.toggleLoading(false) }, @@ -144,7 +145,7 @@ export default { return name }, jumpPage (item) { - this.beforeRouterPush() + beforeRouterPush() this.$router.push({ path: '/detection/performanceEvent', query: { @@ -153,36 +154,6 @@ export default { } }) }, - /** - * 在路由跳转前,即下钻前将路由数据保存起来,确保回退和前进保留当时状态 - */ - beforeRouterPush () { - const currentRouter = this.$_.cloneDeep(this.$route.query) - const historyList = this.$_.cloneDeep(this.$store.getters.getRouterHistoryList) - - const tempObj = { - t: currentRouter.t, - query: currentRouter, - path: this.$_.cloneDeep(this.$route.path), - params: this.$_.cloneDeep(this.$route.params) - } - if (historyList.length > 0) { - let flag = true - historyList.forEach((item, index) => { - if (item.t === currentRouter.t) { - historyList[index] = tempObj - flag = false - } - if (!flag) { - return true - } - }) - if (flag) historyList.push(tempObj) - } else { - historyList.push(tempObj) - } - this.$store.commit('setRouterHistoryList', historyList) - }, httpError (res) { this.isNoData = false this.showError = true