diff --git a/src/store/modules/dashboard.ts b/src/store/modules/dashboard.ts index 19019a2d..8d278ea5 100644 --- a/src/store/modules/dashboard.ts +++ b/src/store/modules/dashboard.ts @@ -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 }; diff --git a/src/types/dashboard.ts b/src/types/dashboard.ts index 1ade1404..ebbeb0ef 100644 --- a/src/types/dashboard.ts +++ b/src/types/dashboard.ts @@ -19,7 +19,7 @@ export type DashboardItem = { id?: string; entity: string; layer: string; - isRoot: string; + isRoot: boolean; name: string; }; export interface LayoutConfig { diff --git a/src/views/dashboard/List.vue b/src/views/dashboard/List.vue index 0f047482..75114d73 100644 --- a/src/views/dashboard/List.vue +++ b/src/views/dashboard/List.vue @@ -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);