fix save config

This commit is contained in:
Qiuxia Fan 2022-03-18 13:51:07 +08:00
parent d01631ef04
commit 5c73b067f4
4 changed files with 24 additions and 16 deletions

View File

@ -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),
},
});
json = res.data.changeTemplate;
} else {
@ -387,18 +385,26 @@ export const dashboardStore = defineStore({
ElMessage.error(json.message);
return;
}
if (!this.currentDashboard.id) {
ElMessage.success("Saved successfully");
this.dashboards.push({
...this.currentDashboard,
id: json.id,
});
}
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));
},

View File

@ -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,
});
}
}

View File

@ -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",

View File

@ -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");