fix templates

This commit is contained in:
Qiuxia Fan 2022-03-16 18:24:34 +08:00
parent 3ffdc0cf08
commit 91f7e4483f
3 changed files with 8 additions and 9 deletions

View File

@ -368,7 +368,6 @@ export const dashboardStore = defineStore({
return; return;
} }
const c = { const c = {
isRoot: false,
children: this.layout, children: this.layout,
...this.currentDashboard, ...this.currentDashboard,
}; };
@ -384,6 +383,7 @@ export const dashboardStore = defineStore({
}); });
json = res.data.changeTemplate; json = res.data.changeTemplate;
} else { } else {
c.isRoot = false;
const index = this.dashboards.findIndex( const index = this.dashboards.findIndex(
(d: DashboardItem) => (d: DashboardItem) =>
d.name === this.currentDashboard.name && d.name === this.currentDashboard.name &&
@ -411,15 +411,12 @@ export const dashboardStore = defineStore({
ElMessage.success("Saved successfully"); ElMessage.success("Saved successfully");
this.dashboards.push({ this.dashboards.push({
...this.currentDashboard,
id: json.id, id: json.id,
name: this.currentDashboard.name,
layer: this.currentDashboard.layer,
entity: this.currentDashboard.entity,
isRoot: true,
}); });
const key = [ const key = [
this.layer, this.currentDashboard.layer,
this.entity, this.currentDashboard.entity,
this.currentDashboard.name.split(" ").join("-"), this.currentDashboard.name.split(" ").join("-"),
].join("_"); ].join("_");
const l = { id: json.id, configuration: c }; const l = { id: json.id, configuration: c };

View File

@ -19,7 +19,7 @@ export type DashboardItem = {
id?: string; id?: string;
entity: string; entity: string;
layer: string; layer: string;
isRoot: string; isRoot: boolean;
name: string; name: string;
}; };
export interface LayoutConfig { export interface LayoutConfig {

View File

@ -112,6 +112,7 @@ import { useDashboardStore } from "@/store/modules/dashboard";
import router from "@/router"; import router from "@/router";
import { DashboardItem } from "@/types/dashboard"; import { DashboardItem } from "@/types/dashboard";
import { saveFile, readFile } from "@/utils/file"; import { saveFile, readFile } from "@/utils/file";
import { is } from "@/utils/is";
const appStore = useAppStoreWithOut(); const appStore = useAppStoreWithOut();
const dashboardStore = useDashboardStore(); const dashboardStore = useDashboardStore();
@ -154,10 +155,11 @@ async function importTemplates(event: any) {
name: name, name: name,
layer: layer, layer: layer,
entity: entity, entity: entity,
isRoot: isRoot, isRoot: false,
}; };
if (index > -1) { if (index > -1) {
p.id = item.id; p.id = item.id;
p.isRoot = isRoot;
} }
dashboardStore.setCurrentDashboard(p); dashboardStore.setCurrentDashboard(p);
dashboardStore.setLayout(children); dashboardStore.setLayout(children);