diff --git a/src/components/form/index.vue b/src/components/form/index.vue index cce7ecd..2e0c322 100644 --- a/src/components/form/index.vue +++ b/src/components/form/index.vue @@ -441,6 +441,9 @@ // 返回 handleReset() { this.$refs.ruleForm.resetFields(); + // 步骤1:从 keep-alive 缓存列表中移除当前页面 + this.$store.dispatch('tagsView/delCachedView', this.$route); + // 清除所有表单校验提示 this.$emit("fnClick", {fnCode: 'cancel'}); }, // change事件 diff --git a/src/layout/components/AppMain.vue b/src/layout/components/AppMain.vue index 9209165..12fffbd 100644 --- a/src/layout/components/AppMain.vue +++ b/src/layout/components/AppMain.vue @@ -2,7 +2,7 @@
- + diff --git a/src/router/index.js b/src/router/index.js index 77b8d6e..907f266 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -193,7 +193,7 @@ export const dynamicRoutes = [ { path: 'index/:id?', component: () => import('@/views/earnManage/busValueCount/details'), - name: 'busValueCountEdit', + name: 'busValueCount_Details', meta: { title: '新增任务', activeMenu: '/earnManage/busValueCount' } } ] @@ -310,7 +310,7 @@ export const dynamicRoutes = [ path: ':id?', component: () => import('@/views/earnManage/businessScript/details'), name: 'BusinessScriptDetails', - meta: { title: '脚本信息', noCache: true ,activeMenu: '/earnManage/businessScript' } + meta: { title: '脚本信息', activeMenu: '/earnManage/businessScript' } } ] }, @@ -325,7 +325,7 @@ export const dynamicRoutes = [ path: ':id?', component: () => import('@/views/earnManage/businessIssued/details'), name: 'BusinessIssuedDetails', - meta: { title: '业务下发信息', noCache: true ,activeMenu: '/earnManage/businessIssued' } + meta: { title: '业务下发信息', activeMenu: '/earnManage/businessIssued' } } ] }, @@ -369,7 +369,7 @@ export const dynamicRoutes = [ { path: ':id?', component: () => import('@/views/resource/serverRegister/handle'), - name: 'serverRegisterEdit', + name: 'serverRegister_Edit', meta: { title: '服务器管理信息', activeMenu: '/resource/serverRegister' } } ] @@ -470,7 +470,7 @@ export const dynamicRoutes = [ { path: ':id?', component: () => import('@/views/resource/frpServerManage/details'), - name: 'FrpServerManageEdit', + name: 'frpServerDetails', meta: { title: '修改FRP服务端配置', activeMenu: '/resource/frpServerManage' } } ] @@ -514,7 +514,7 @@ export const dynamicRoutes = [ { path: 'index/:id?', component: () => import('@/views/resource/topology/details'), - name: 'TopologyEdit', + name: 'TopologyDetails', meta: { title: '拓扑信息', activeMenu: '/resource/topology' } } ] @@ -571,7 +571,7 @@ export const dynamicRoutes = [ { path: ':id?', component: () => import('@/views/resource/messagePush/details'), - name: 'MessagePushDetails', + name: 'messagePushDetails', meta: { title: '消息推送信息', activeMenu: '/resource/messagePush' } } ] @@ -616,7 +616,7 @@ export const dynamicRoutes = [ { path: 'index/:id?', component: () => import('@/views/resource/serverScriptStrat/details'), - name: 'serverScriptStatEdit', + name: 'severScriptStratDetails', meta: { title: '服务器脚本策略信息', activeMenu: '/resource/serverScriptStrat' } } ] @@ -778,7 +778,7 @@ export const dynamicRoutes = [ { path: ':id?', component: () => import('@/views/resource/alarmLog/alarmLogDetails'), - name: 'alarmLogAdd', + name: 'AlarmLogDetails', meta: { title: '告警阈值配置', activeMenu: '/resource/alarmLog' } } ] @@ -866,7 +866,7 @@ export const dynamicRoutes = [ { path: ':id?', component: () => import('@/views/resource/mtrProbe/mtrProbeView'), - name: 'mtrAgentLossRateProbe', + name: 'mtrProbe_view', meta: { title: '新建MTR探测策略', activeMenu: '/resource/mtrAgent' } } ] @@ -881,7 +881,7 @@ export const dynamicRoutes = [ { path: ':id?', component: () => import('@/views/resource/mtrProbe/mtrProbeView'), - name: 'mtrProbeView', + name: 'mtrProbe_view', meta: { title: 'MTR探测策略信息', activeMenu: '/resource/mtrProbe' } } ] @@ -896,7 +896,7 @@ export const dynamicRoutes = [ { path: ':id?', component: () => import('@/views/resource/agentUpdate/agentUpdateView'), - name: 'agentUpdateView', + name: 'AgentUpdateView', meta: { title: 'AGENT更新信息', activeMenu: '/resource/agentUpdate' } } ] diff --git a/src/store/modules/tagsView.js b/src/store/modules/tagsView.js index 9a88c2b..5fc011c 100644 --- a/src/store/modules/tagsView.js +++ b/src/store/modules/tagsView.js @@ -1,228 +1,228 @@ -const state = { - visitedViews: [], - cachedViews: [], - iframeViews: [] -} - -const mutations = { - ADD_IFRAME_VIEW: (state, view) => { - if (state.iframeViews.some(v => v.path === view.path)) return - state.iframeViews.push( - Object.assign({}, view, { - title: view.meta.title || 'no-name' - }) - ) - }, - ADD_VISITED_VIEW: (state, view) => { - if (state.visitedViews.some(v => v.path === view.path)) return - state.visitedViews.push( - Object.assign({}, view, { - title: view.meta.title || 'no-name' - }) - ) - }, - ADD_CACHED_VIEW: (state, view) => { - if (state.cachedViews.includes(view.name)) return - if (view.meta && !view.meta.noCache) { - state.cachedViews.push(view.name) - } - }, - DEL_VISITED_VIEW: (state, view) => { - for (const [i, v] of state.visitedViews.entries()) { - if (v.path === view.path) { - state.visitedViews.splice(i, 1) - break - } - } - state.iframeViews = state.iframeViews.filter(item => item.path !== view.path) - }, - DEL_IFRAME_VIEW: (state, view) => { - state.iframeViews = state.iframeViews.filter(item => item.path !== view.path) - }, - DEL_CACHED_VIEW: (state, view) => { - const index = state.cachedViews.indexOf(view.name) - index > -1 && state.cachedViews.splice(index, 1) - }, - - 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 - }) - }, - 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 = { - addView({ dispatch }, view) { - dispatch('addVisitedView', view) - dispatch('addCachedView', view) - }, - addIframeView({ commit }, view) { - commit('ADD_IFRAME_VIEW', view) - }, - addVisitedView({ commit }, view) { - commit('ADD_VISITED_VIEW', view) - }, - addCachedView({ commit }, view) { - commit('ADD_CACHED_VIEW', view) - }, - delView({ dispatch, state }, view) { - return new Promise(resolve => { - dispatch('delVisitedView', view) - dispatch('delCachedView', view) - resolve({ - visitedViews: [...state.visitedViews], - cachedViews: [...state.cachedViews] - }) - }) - }, - delVisitedView({ commit, state }, view) { - 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) - resolve([...state.iframeViews]) - }) - }, - delCachedView({ commit, state }, view) { - return new Promise(resolve => { - commit('DEL_CACHED_VIEW', view) - resolve([...state.cachedViews]) - }) - }, - delOthersViews({ dispatch, state }, view) { - return new Promise(resolve => { - dispatch('delOthersVisitedViews', view) - dispatch('delOthersCachedViews', view) - resolve({ - visitedViews: [...state.visitedViews], - cachedViews: [...state.cachedViews] - }) - }) - }, - delOthersVisitedViews({ commit, state }, view) { - 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) - resolve([...state.cachedViews]) - }) - }, - delAllViews({ dispatch, state }, view) { - return new Promise(resolve => { - dispatch('delAllVisitedViews', view) - dispatch('delAllCachedViews', view) - resolve({ - visitedViews: [...state.visitedViews], - cachedViews: [...state.cachedViews] - }) - }) - }, - delAllVisitedViews({ commit, state }) { - return new Promise(resolve => { - commit('DEL_ALL_VISITED_VIEWS') - resolve([...state.visitedViews]) - }) - }, - delAllCachedViews({ commit, state }) { - return new Promise(resolve => { - commit('DEL_ALL_CACHED_VIEWS') - resolve([...state.cachedViews]) - }) - }, - updateVisitedView({ commit }, view) { - commit('UPDATE_VISITED_VIEW', view) - }, - delRightTags({ commit }, view) { - return new Promise(resolve => { - commit('DEL_RIGHT_VIEWS', view) - resolve([...state.visitedViews]) - }) - }, - delLeftTags({ commit }, view) { - return new Promise(resolve => { - commit('DEL_LEFT_VIEWS', view) - resolve([...state.visitedViews]) - }) - }, -} - -export default { - namespaced: true, - state, - mutations, - actions -} +const state = { + visitedViews: [], + cachedViews: [], + iframeViews: [] +} + +const mutations = { + ADD_IFRAME_VIEW: (state, view) => { + if (state.iframeViews.some(v => v.path === view.path)) return + state.iframeViews.push( + Object.assign({}, view, { + title: view.meta.title || 'no-name' + }) + ) + }, + ADD_VISITED_VIEW: (state, view) => { + if (state.visitedViews.some(v => v.path === view.path)) return + state.visitedViews.push( + Object.assign({}, view, { + title: view.meta.title || 'no-name' + }) + ) + }, + ADD_CACHED_VIEW: (state, view) => { + if (state.cachedViews.includes(view.name)) return + if (view.meta && !view.meta.noCache) { + state.cachedViews.push(view.name) + } + }, + DEL_VISITED_VIEW: (state, view) => { + for (const [i, v] of state.visitedViews.entries()) { + if (v.path === view.path) { + state.visitedViews.splice(i, 1) + break + } + } + state.iframeViews = state.iframeViews.filter(item => item.path !== view.path) + }, + DEL_IFRAME_VIEW: (state, view) => { + state.iframeViews = state.iframeViews.filter(item => item.path !== view.path) + }, + DEL_CACHED_VIEW: (state, view) => { + const index = state.cachedViews.indexOf(view.name) + index > -1 && state.cachedViews.splice(index, 1) + }, + + 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 + }) + }, + 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 = { + addView({ dispatch }, view) { + dispatch('addVisitedView', view) + dispatch('addCachedView', view) + }, + addIframeView({ commit }, view) { + commit('ADD_IFRAME_VIEW', view) + }, + addVisitedView({ commit }, view) { + commit('ADD_VISITED_VIEW', view) + }, + addCachedView({ commit }, view) { + commit('ADD_CACHED_VIEW', view) + }, + delView({ dispatch, state }, view) { + return new Promise(resolve => { + dispatch('delVisitedView', view) + dispatch('delCachedView', view) + resolve({ + visitedViews: [...state.visitedViews], + cachedViews: [...state.cachedViews] + }) + }) + }, + delVisitedView({ commit, state }, view) { + 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) + resolve([...state.iframeViews]) + }) + }, + delCachedView({ commit, state }, view) { + return new Promise(resolve => { + commit('DEL_CACHED_VIEW', view) + resolve([...state.cachedViews]) + }) + }, + delOthersViews({ dispatch, state }, view) { + return new Promise(resolve => { + dispatch('delOthersVisitedViews', view) + dispatch('delOthersCachedViews', view) + resolve({ + visitedViews: [...state.visitedViews], + cachedViews: [...state.cachedViews] + }) + }) + }, + delOthersVisitedViews({ commit, state }, view) { + 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) + resolve([...state.cachedViews]) + }) + }, + delAllViews({ dispatch, state }, view) { + return new Promise(resolve => { + dispatch('delAllVisitedViews', view) + dispatch('delAllCachedViews', view) + resolve({ + visitedViews: [...state.visitedViews], + cachedViews: [...state.cachedViews] + }) + }) + }, + delAllVisitedViews({ commit, state }) { + return new Promise(resolve => { + commit('DEL_ALL_VISITED_VIEWS') + resolve([...state.visitedViews]) + }) + }, + delAllCachedViews({ commit, state }) { + return new Promise(resolve => { + commit('DEL_ALL_CACHED_VIEWS') + resolve([...state.cachedViews]) + }) + }, + updateVisitedView({ commit }, view) { + commit('UPDATE_VISITED_VIEW', view) + }, + delRightTags({ commit }, view) { + return new Promise(resolve => { + commit('DEL_RIGHT_VIEWS', view) + resolve([...state.visitedViews]) + }) + }, + delLeftTags({ commit }, view) { + return new Promise(resolve => { + commit('DEL_LEFT_VIEWS', view) + resolve([...state.visitedViews]) + }) + }, +} + +export default { + namespaced: true, + state, + mutations, + actions +} diff --git a/src/views/earnManage/busValueCount/busValueCount.vue b/src/views/earnManage/busValueCount/busValueCount.vue index 919fca9..04d5c0a 100644 --- a/src/views/earnManage/busValueCount/busValueCount.vue +++ b/src/views/earnManage/busValueCount/busValueCount.vue @@ -54,6 +54,7 @@ watch: { activeName: { handler(val) { + this.keepAliveFirst = true; this.getList(); }, deep: true, @@ -99,6 +100,7 @@ pageSize: 8, total: 0, }, + keepAliveFirst: false } }, // created() { @@ -106,11 +108,13 @@ // this.getList(1); // }); // }, - // activated() { - // this.$nextTick(() => { - // this.getList(); - // }); - // }, + activated() { + this.$nextTick(() => { + if (!this.keepAliveFirst) { + this.getList(); + } + }); + }, methods: { /** 查询角色列表 */ getList(num) { @@ -122,6 +126,9 @@ this.tableList = response.rows; this.queryParams.total = response.total; this.loading = false; + this.keepAliveFirst = false; + }).catch(() => { + this.keepAliveFirst = false; }) }, diff --git a/src/views/earnManage/busValueCount/index.vue b/src/views/earnManage/busValueCount/index.vue index b02329e..9d4df51 100644 --- a/src/views/earnManage/busValueCount/index.vue +++ b/src/views/earnManage/busValueCount/index.vue @@ -14,7 +14,7 @@