From cce5a8826c85ad59c3953c27f7527f3cc4a6892c Mon Sep 17 00:00:00 2001 From: Qiuxia Fan Date: Mon, 10 Jan 2022 14:43:07 +0800 Subject: [PATCH] feat: active widget on the tab --- src/store/modules/dashboard.ts | 6 ++- src/views/dashboard/controls/Tab.vue | 76 ++++++++++++++++++---------- src/views/dashboard/panel/Layout.vue | 1 + 3 files changed, 56 insertions(+), 27 deletions(-) diff --git a/src/store/modules/dashboard.ts b/src/store/modules/dashboard.ts index f3e0adfb..5bda837e 100644 --- a/src/store/modules/dashboard.ts +++ b/src/store/modules/dashboard.ts @@ -105,9 +105,13 @@ export const dashboardStore = defineStore({ this.layout[idx].children?.push(i); }, addTabWidget(tabIndex: number) { + const activedGridItem = this.activedGridItem.split("-")[0]; const idx = this.layout.findIndex( - (d: LayoutConfig) => d.i === this.activedGridItem + (d: LayoutConfig) => d.i === activedGridItem ); + if (idx < 0) { + return; + } const { children } = this.layout[idx].children[tabIndex]; const newWidget = { x: 0, diff --git a/src/views/dashboard/controls/Tab.vue b/src/views/dashboard/controls/Tab.vue index b8347f52..42c06b06 100644 --- a/src/views/dashboard/controls/Tab.vue +++ b/src/views/dashboard/controls/Tab.vue @@ -49,29 +49,30 @@ limitations under the License. --> - - + - - - + + + + +