diff --git a/src/layouts/components/tabs.vue b/src/layouts/components/tabs.vue index c72a4d0..bba76d2 100644 --- a/src/layouts/components/tabs.vue +++ b/src/layouts/components/tabs.vue @@ -28,16 +28,16 @@ const activeTab = computed(() => store.state.layout.activeTab); const tabList = computed(() => store.state.layout.tabList); // 标签列表变化时如果激活标签不存在则跳转到第一个标签 - watch( - () => unref(tabList), - (value) => { - if (!unref(activeTab) || value.findIndex((item) => item.name === unref(activeTab)) === -1) { - console.info('[router] tabs push ' + value[0].fullPath); - router.push(value[0].fullPath); - } - }, - { immediate: true, deep: true } - ); + // watch( + // () => unref(tabList), + // (value) => { + // if (!unref(activeTab) || value.findIndex((item) => item.name === unref(activeTab)) === -1) { + // console.info('[router] tabs push ' + value[0].fullPath); + // router.push(value[0].fullPath); + // } + // }, + // { immediate: true, deep: true } + // ); const handleCloseTab = (index) => { store.commit('layout/closeTab', { index, diff --git a/src/store/modules/core/layout.js b/src/store/modules/core/layout.js index ed987fd..8b119cd 100644 --- a/src/store/modules/core/layout.js +++ b/src/store/modules/core/layout.js @@ -44,17 +44,24 @@ const mutations = { state.tabList.push(tab); } }, - closeTab: (state, { index, reverse }) => { - if (typeof index === 'undefined') { - state.tabList.splice(1); + closeTab: (state, { index, reverse, current }) => { + if (current) { + state.tabList.splice( + state.tabList.findIndex((item) => item.name === state.activeTab), + 1 + ); } else { - if (reverse) { - let tab = state.tabList[index]; - router.push(tab.fullPath); - state.tabList = [tab]; - } else if (state.tabList.length > 1) { - state.tabList.splice(index, 1); - router.push(state.tabList[Math.min(index, state.tabList.length - 1)].fullPath); + if (typeof index === 'undefined') { + state.tabList.splice(1); + } else { + if (reverse) { + let tab = state.tabList[index]; + router.push(tab.fullPath); + state.tabList = [tab]; + } else if (state.tabList.length > 1) { + state.tabList.splice(index, 1); + router.push(state.tabList[Math.min(index, state.tabList.length - 1)].fullPath); + } } } }, diff --git a/src/views/sales/product/form/step2.vue b/src/views/sales/product/form/step2.vue index 46e8689..2b3bfed 100644 --- a/src/views/sales/product/form/step2.vue +++ b/src/views/sales/product/form/step2.vue @@ -289,6 +289,7 @@ await store.dispatch('product/enable', { id: route.params.id, isEnable: true }); } await store.dispatch('productSkus/save', { id: route.params.id, data }); + store.commit('layout/closeTab', { current: true }); router.push({ name: 'ProductManagement' }); } state.loading = false;