From 2a9fde6805bf8f75fabf4f47244d51fabd789a04 Mon Sep 17 00:00:00 2001 From: Fine Date: Tue, 12 Dec 2023 15:49:16 +0800 Subject: [PATCH] feat: update tabs --- src/types/dashboard.d.ts | 2 +- src/views/dashboard/controls/Tab.vue | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/types/dashboard.d.ts b/src/types/dashboard.d.ts index cacadfba..400ccd0b 100644 --- a/src/types/dashboard.d.ts +++ b/src/types/dashboard.d.ts @@ -36,7 +36,7 @@ export interface LayoutConfig { expressions?: string[]; metricTypes?: string[]; typesOfMQE?: string[]; - children?: { name: string; children: LayoutConfig[]; expression?: string; enable: boolean }[]; + children?: { name: string; children: LayoutConfig[]; expression?: string; enable?: boolean }[]; activedTabIndex?: number; metricConfig?: MetricConfigOpt[]; id?: string; diff --git a/src/views/dashboard/controls/Tab.vue b/src/views/dashboard/controls/Tab.vue index 790986ea..194c6b46 100644 --- a/src/views/dashboard/controls/Tab.vue +++ b/src/views/dashboard/controls/Tab.vue @@ -20,6 +20,7 @@ limitations under the License. --> :key="idx" :class="{ active: activeTabIndex === idx }" @click="clickTabs($event, idx)" + v-show="child.enable !== false" > for (const child of tabsProps.children || []) { if (params.source[child.expression || ""]) { - child.enable = !!Number(params.source[child.expression || ""]) || true; + child.enable = !!Number(params.source[child.expression || ""]); } else { child.enable = true; } } - console.log(tabsProps); + dashboardStore.setConfigs(tabsProps); } watch( - () => (props.data.children || []).map((d: { name: string }) => d.name), - () => { + () => (props.data.children || []).map((d: any) => d.expression), + (old: string[], data: string[]) => { + if (JSON.stringify(data) === JSON.stringify(old)) { + return; + } queryExpressions(); }, );