From 5c73b067f495a9e88f8a8458d360037d21635522 Mon Sep 17 00:00:00 2001 From: Qiuxia Fan Date: Fri, 18 Mar 2022 13:51:07 +0800 Subject: [PATCH] fix save config --- src/store/modules/dashboard.ts | 26 ++++++++++++++++---------- src/views/dashboard/Edit.vue | 6 ++++-- src/views/dashboard/graphs/Line.vue | 4 ++-- src/views/dashboard/panel/Tool.vue | 4 ++-- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/store/modules/dashboard.ts b/src/store/modules/dashboard.ts index 2ed00892..c3f9b6d0 100644 --- a/src/store/modules/dashboard.ts +++ b/src/store/modules/dashboard.ts @@ -355,10 +355,8 @@ export const dashboardStore = defineStore({ if (this.currentDashboard.id) { res = await this.updateDashboard({ - setting: { - id: this.currentDashboard.id, - configuration: JSON.stringify(c), - }, + id: this.currentDashboard.id, + configuration: JSON.stringify(c), }); json = res.data.changeTemplate; } else { @@ -387,18 +385,26 @@ export const dashboardStore = defineStore({ ElMessage.error(json.message); return; } - ElMessage.success("Saved successfully"); - - this.dashboards.push({ - ...this.currentDashboard, - id: json.id, - }); + if (!this.currentDashboard.id) { + ElMessage.success("Saved successfully"); + } const key = [ this.currentDashboard.layer, this.currentDashboard.entity, this.currentDashboard.name.split(" ").join("-"), ].join("_"); + if (this.currentDashboard.id) { + sessionStorage.removeItem(key); + this.dashboards = this.dashboards.filter( + (d: DashboardItem) => d.id !== this.currentDashboard.id + ); + } + this.dashboards.push({ + ...this.currentDashboard, + id: json.id, + }); const l = { id: json.id, configuration: c }; + sessionStorage.setItem(key, JSON.stringify(l)); sessionStorage.setItem("dashboards", JSON.stringify(this.dashboards)); }, diff --git a/src/views/dashboard/Edit.vue b/src/views/dashboard/Edit.vue index f780a3f9..5469d188 100644 --- a/src/views/dashboard/Edit.vue +++ b/src/views/dashboard/Edit.vue @@ -62,14 +62,16 @@ async function setTemplate() { sessionStorage.getItem(layoutKey) || "{}" ); const layout: any = c.configuration || {}; - dashboardStore.setLayout(layout.children || []); appStore.setPageTitle(layout.name); + if (!dashboardStore.currentDashboard) { dashboardStore.setCurrentDashboard({ layer: p.layerId, - entity: p.layerId, + entity: p.entity, name: p.name, + id: c.id, + isRoot: layout.isRoot, }); } } diff --git a/src/views/dashboard/graphs/Line.vue b/src/views/dashboard/graphs/Line.vue index a2742d14..2df370f3 100644 --- a/src/views/dashboard/graphs/Line.vue +++ b/src/views/dashboard/graphs/Line.vue @@ -79,10 +79,10 @@ function getOption() { name: i, type: "line", symbol: "circle", - barMaxWidth: 10, + symbolSize: 8, + showSymbol: props.config.showSymbol, step: props.config.step, smooth: props.config.smooth, - showSymbol: props.config.showSymbol, lineStyle: { width: 1.5, type: "solid", diff --git a/src/views/dashboard/panel/Tool.vue b/src/views/dashboard/panel/Tool.vue index ca630adf..f7fc1183 100644 --- a/src/views/dashboard/panel/Tool.vue +++ b/src/views/dashboard/panel/Tool.vue @@ -319,7 +319,7 @@ function setTabControls(id: string) { dashboardStore.addTabControls("Topology"); break; case "apply": - dashboardStore.saveDashboard(params.name); + dashboardStore.saveDashboard(); break; default: ElMessage.info("Don't support this control"); @@ -348,7 +348,7 @@ function setControls(id: string) { dashboardStore.addControl("Topology"); break; case "apply": - dashboardStore.saveDashboard(params.name); + dashboardStore.saveDashboard(); break; default: dashboardStore.addControl("Widget");