From 8e1e74067dfb8aee657791e5d815bf50d29f6d82 Mon Sep 17 00:00:00 2001 From: cwchen <1048842385@qq.com> Date: Thu, 27 Nov 2025 14:54:08 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E6=9E=90=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../analysis/components/AnalysisBidView.vue | 13 ++++++- .../components/child/AnalysisResultPanel.vue | 39 ++++++++++++++++--- 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/src/views/analysis/components/AnalysisBidView.vue b/src/views/analysis/components/AnalysisBidView.vue index c62043d..c65d520 100644 --- a/src/views/analysis/components/AnalysisBidView.vue +++ b/src/views/analysis/components/AnalysisBidView.vue @@ -214,7 +214,7 @@ export default { proId: decryptWithSM4(this.$route.query.proId), bidId: decryptWithSM4(this.$route.query.bidId), activeMainTab: 'project', - defaultSubTab: 'response', + defaultSubTab: '', // 初始为空,由 AnalysisResultPanel 组件自动获取第一个子标签 analysisData: {}, tenderDocumentUrl: '', tenderDocumentTitle: '', @@ -348,7 +348,16 @@ export default { }, handleMainTabClick(tab) { this.activeMainTab = tab.name - this.handleMainTabChange(tab.name, '') + // 获取当前主标签的第一个子标签 + const currentMainTab = this.mainTabs.find(t => t.name === tab.name) + const firstSubTab = currentMainTab && currentMainTab.subTabs && currentMainTab.subTabs.length > 0 + ? currentMainTab.subTabs[0].name + : '' + // 强制更新 defaultSubTab,确保子标签切换 + this.$nextTick(() => { + this.defaultSubTab = firstSubTab + }) + this.handleMainTabChange(tab.name, firstSubTab) }, handleMainTabChange(mainTab, subTab) { console.log('主标签切换:', mainTab, subTab) diff --git a/src/views/analysis/components/child/AnalysisResultPanel.vue b/src/views/analysis/components/child/AnalysisResultPanel.vue index ccf5ec6..1439750 100644 --- a/src/views/analysis/components/child/AnalysisResultPanel.vue +++ b/src/views/analysis/components/child/AnalysisResultPanel.vue @@ -151,23 +151,52 @@ export default { } }, data() { + // 初始化时,如果 defaultSubTab 为空,获取第一个子标签 + const initialSubTab = this.defaultSubTab || this.getDefaultSubTab(this.defaultMainTab) return { activeMainTab: this.defaultMainTab, - activeSubTab: this.defaultSubTab || this.getDefaultSubTab(this.defaultMainTab), + activeSubTab: initialSubTab, } }, watch: { - defaultMainTab(newVal) { - this.activeMainTab = newVal - this.activeSubTab = this.getDefaultSubTab(newVal) + defaultMainTab(newVal, oldVal) { + if (newVal !== oldVal) { + this.activeMainTab = newVal + // 切换主标签时,总是获取第一个子标签 + const firstSubTab = this.getDefaultSubTab(newVal) + if (firstSubTab) { + this.activeSubTab = firstSubTab + } else { + this.activeSubTab = '' + } + } + }, + defaultSubTab(newVal, oldVal) { + // 当 defaultSubTab 变化时,更新 activeSubTab + if (newVal && newVal !== oldVal) { + this.activeSubTab = newVal + } else if (!newVal) { + // 如果为空,获取当前主标签的第一个子标签 + this.activeSubTab = this.getDefaultSubTab(this.activeMainTab) + } }, hideMainTabs(newVal) { if (newVal) { // 当隐藏主标签时,确保子标签正确初始化 - this.activeSubTab = this.getDefaultSubTab(this.defaultMainTab) + if (!this.defaultSubTab) { + this.activeSubTab = this.getDefaultSubTab(this.defaultMainTab) + } else { + this.activeSubTab = this.defaultSubTab + } } } }, + created() { + // 初始化时,如果 activeSubTab 为空,确保获取第一个子标签 + if (!this.activeSubTab) { + this.activeSubTab = this.getDefaultSubTab(this.activeMainTab) + } + }, methods: { handleMainTabClick(tab) { // 切换主标签时,重置子标签为第一个