From 713c1d145994a5fe5f5d33f52494688ef42a12b1 Mon Sep 17 00:00:00 2001 From: Qiuxia Fan Date: Sun, 27 Mar 2022 22:42:09 +0800 Subject: [PATCH] fix widget index --- src/store/modules/dashboard.ts | 6 ++++-- src/views/dashboard/controls/Widget.vue | 3 --- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/store/modules/dashboard.ts b/src/store/modules/dashboard.ts index 410df5d0..a0f0147c 100644 --- a/src/store/modules/dashboard.ts +++ b/src/store/modules/dashboard.ts @@ -76,9 +76,10 @@ export const dashboardStore = defineStore({ this.currentDashboard = item; }, addControl(type: string) { + const arr = this.layout.map((d: any) => Number(d.i)); const newItem: LayoutConfig = { ...NewControl, - i: String(this.layout.length), + i: String(Math.max(...arr) + 1), type, metricTypes: [""], metrics: [""], @@ -146,9 +147,10 @@ export const dashboardStore = defineStore({ } const tabIndex = this.layout[idx].activedTabIndex || 0; const { children } = this.layout[idx].children[tabIndex]; + const arr = children.map((d: any) => Number(d.i)); const newItem: LayoutConfig = { ...NewControl, - i: String(children.length), + i: String(Math.max(...arr) + 1), type, metricTypes: [""], metrics: [""], diff --git a/src/views/dashboard/controls/Widget.vue b/src/views/dashboard/controls/Widget.vue index 57e8f3b5..511f59c9 100644 --- a/src/views/dashboard/controls/Widget.vue +++ b/src/views/dashboard/controls/Widget.vue @@ -19,9 +19,6 @@ limitations under the License. --> {{ data.widget?.title || "" }} - - ({{ data.standard?.unit }}) -