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

View File

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

View File

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