This commit is contained in:
Qiuxia Fan 2022-03-19 11:47:11 +08:00
parent eea641d8ce
commit 81041891fa
2 changed files with 31 additions and 28 deletions

View File

@ -73,6 +73,8 @@ function setLayer(n: string) {
layer.value = "GENERAL"; layer.value = "GENERAL";
break; break;
} }
dashboardStore.setLayer(layer.value);
dashboardStore.setEntity(EntityType[1].value);
// appStore.setPageTitle(layer.value); // appStore.setPageTitle(layer.value);
} }
watch( watch(

View File

@ -122,6 +122,7 @@ 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 { EntityType } from "./data"; import { EntityType } from "./data";
import { findLastKey } from "lodash";
/*global Nullable*/ /*global Nullable*/
const { t } = useI18n(); const { t } = useI18n();
@ -241,34 +242,34 @@ async function setRoot(row: DashboardItem) {
}) })
); );
} }
} } else {
if ( if (
d.layer === row.layer && d.layer === row.layer &&
d.entity === row.entity && d.entity === row.entity &&
d.id !== row.id && row.isRoot === false &&
!row.isRoot && d.isRoot === true
d.isRoot ) {
) { d.isRoot = false;
d.isRoot = false; const key = [d.layer, d.entity, d.name.split(" ").join("-")].join("_");
const key = [d.layer, d.entity, d.name.split(" ").join("-")].join("_"); const layout = sessionStorage.getItem(key) || "{}";
const layout = sessionStorage.getItem(key) || "{}"; const c = {
const c = { ...JSON.parse(layout).configuration,
...JSON.parse(layout).configuration, ...d,
...d, };
}; const setting = {
const setting = { id: d.id,
id: d.id, configuration: JSON.stringify(c),
configuration: JSON.stringify(c), };
}; const res = await dashboardStore.updateDashboard(setting);
const res = await dashboardStore.updateDashboard(setting); if (res.data.changeTemplate.id) {
if (res.data.changeTemplate.id) { sessionStorage.setItem(
sessionStorage.setItem( key,
key, JSON.stringify({
JSON.stringify({ id: d.id,
id: d.id, configuration: c,
configuration: c, })
}) );
); }
} }
} }
items.push(d); items.push(d);