From 232f8d297334358a886ca42e6c5eb1e7ae9be7be Mon Sep 17 00:00:00 2001 From: Fine Date: Thu, 18 Aug 2022 15:33:43 +0800 Subject: [PATCH] fix key --- src/views/dashboard/List.vue | 4 +++ .../configuration/widget/AssociateOptions.vue | 27 ++++++++----------- src/views/dashboard/controls/Tab.vue | 3 ++- src/views/dashboard/panel/Tool.vue | 4 ++- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/views/dashboard/List.vue b/src/views/dashboard/List.vue index 5dbe374f..e4072d0b 100644 --- a/src/views/dashboard/List.vue +++ b/src/views/dashboard/List.vue @@ -238,6 +238,8 @@ function optimizeTemplate( children: (LayoutConfig & { moved?: boolean; standard?: unknown; + label?: string; + value?: string; })[] ) { for (const child of children || []) { @@ -245,6 +247,8 @@ function optimizeTemplate( delete child.activedTabIndex; delete child.standard; delete child.id; + delete child.label; + delete child.value; if (isEmptyObject(child.graph)) { delete child.graph; } diff --git a/src/views/dashboard/configuration/widget/AssociateOptions.vue b/src/views/dashboard/configuration/widget/AssociateOptions.vue index feae7703..967bc337 100644 --- a/src/views/dashboard/configuration/widget/AssociateOptions.vue +++ b/src/views/dashboard/configuration/widget/AssociateOptions.vue @@ -31,7 +31,6 @@ import { ref, computed } from "vue"; import { useI18n } from "vue-i18n"; import { useDashboardStore } from "@/store/modules/dashboard"; import getDashboard from "@/hooks/useDashboardsSession"; -import { LayoutConfig } from "@/types/dashboard"; import { Option } from "@/types/app"; const { t } = useI18n(); @@ -40,24 +39,20 @@ const associate = dashboardStore.selectedGrid.associate || []; const widgetIds = ref( associate.map((d: { widgetId: string }) => d.widgetId) ); -const widgets = computed(() => { +const widgets: any = computed(() => { const all = getDashboard(dashboardStore.currentDashboard).widgets; - const items = all.filter( - (d: { value: string; label: string } & LayoutConfig) => { - const isLinear = ["Bar", "Line", "Area"].includes( - (d.graph && d.graph.type) || "" - ); - if (isLinear && d.id && dashboardStore.selectedGrid.id !== d.id) { - d.value = d.id; - d.label = (d.widget && d.widget.name) || d.id; - return d; - } + const items = all.filter((d: any) => { + const isLinear = ["Bar", "Line", "Area"].includes( + (d.graph && d.graph.type) || "" + ); + if (isLinear && d.id && dashboardStore.selectedGrid.id !== d.id) { + return { value: d.id, label: (d.widget && d.widget.name) || d.id }; } - ); + }); return items; }); function updateWidgetConfig(options: Option[]) { - const { widgets } = getDashboard(dashboardStore.currentDashboard); + const arr: any = getDashboard(dashboardStore.currentDashboard).widgets; const opt = options.map((d: Option) => { return { widgetId: d.value }; }); @@ -72,7 +67,7 @@ function updateWidgetConfig(options: Option[]) { // remove unuse association widget option for (const id of widgetIds.value) { if (!newVal.includes(id)) { - const w = widgets.find((d: { id: string }) => d.id === id); + const w = arr.find((d: { id: string }) => d.id === id); const config = { ...w, associate: [], @@ -84,7 +79,7 @@ function updateWidgetConfig(options: Option[]) { for (let i = 0; i < opt.length; i++) { const item = JSON.parse(JSON.stringify(opt)); item[i] = { widgetId: dashboardStore.selectedGrid.id }; - const w = widgets.find((d: { id: string }) => d.id === opt[i].widgetId); + const w = arr.find((d: { id: string }) => d.id === opt[i].widgetId); const config = { ...w, associate: item, diff --git a/src/views/dashboard/controls/Tab.vue b/src/views/dashboard/controls/Tab.vue index 2188862e..098fd24c 100644 --- a/src/views/dashboard/controls/Tab.vue +++ b/src/views/dashboard/controls/Tab.vue @@ -87,7 +87,7 @@ limitations under the License. --> :w="item.w" :h="item.h" :i="item.i" - :key="item.i" + :key="item.id" @click="clickTabGrid($event, item)" :class="{ active: activeTabWidget === item.i }" :drag-ignore-from="dragIgnoreFrom" @@ -216,6 +216,7 @@ export default defineComponent({ dashboardStore.setCurrentTabItems( dashboardStore.layout[l].children[activeTabIndex.value].children ); + console.log(dashboardStore.currentTabItems); } function copyLink() { let path = ""; diff --git a/src/views/dashboard/panel/Tool.vue b/src/views/dashboard/panel/Tool.vue index 87b483d3..46ee3a36 100644 --- a/src/views/dashboard/panel/Tool.vue +++ b/src/views/dashboard/panel/Tool.vue @@ -308,7 +308,9 @@ async function setSourceSelector() { } selectorStore.setCurrentPod(currentPod); states.currentPod = currentPod.label; - const process = params.processId || selectorStore.processes[0].id; + const process = + params.processId || + (selectorStore.processes.length && selectorStore.processes[0].id); let currentProcess; if (states.currentProcess) { currentProcess = selectorStore.processes.find(