From 2e2492530189432976fd0e9547642cb287307010 Mon Sep 17 00:00:00 2001 From: Qiuxia Fan Date: Wed, 23 Mar 2022 18:24:34 +0800 Subject: [PATCH] sort dashboards --- src/store/modules/dashboard.ts | 14 ++++++++++++-- src/views/dashboard/List.vue | 7 ++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/store/modules/dashboard.ts b/src/store/modules/dashboard.ts index 22872e75..2536a4cc 100644 --- a/src/store/modules/dashboard.ts +++ b/src/store/modules/dashboard.ts @@ -227,7 +227,6 @@ export const dashboardStore = defineStore({ this.showConfig = show; }, selectWidget(item: Nullable) { - console.log(item); this.selectedGrid = item; }, setLayer(id: string) { @@ -294,7 +293,7 @@ export const dashboardStore = defineStore({ return res.data; } const data = res.data.data.getAllTemplates; - const list = []; + let list = []; for (const t of data) { const c = JSON.parse(t.configuration); const key = [c.layer, c.entity, c.name].join("_"); @@ -311,6 +310,17 @@ export const dashboardStore = defineStore({ JSON.stringify({ id: t.id, configuration: c }) ); } + list = list.sort((a, b) => { + const nameA = a.name.toUpperCase(); + const nameB = b.name.toUpperCase(); + if (nameA < nameB) { + return -1; + } + if (nameA > nameB) { + return 1; + } + return 0; + }); sessionStorage.setItem("dashboards", JSON.stringify(list)); return res.data; }, diff --git a/src/views/dashboard/List.vue b/src/views/dashboard/List.vue index 91dd6247..8cd9fc3d 100644 --- a/src/views/dashboard/List.vue +++ b/src/views/dashboard/List.vue @@ -46,6 +46,7 @@ limitations under the License. --> ref="multipleTableRef" :default-sort="{ prop: 'name' }" @selection-change="handleSelectionChange" + height="637px" > @@ -214,9 +215,9 @@ function exportTemplates() { }); const name = `dashboards.json`; saveFile(templates, name); - // setTimeout(() => { - // multipleTableRef.value!.clearSelection(); - // }, 2000); + setTimeout(() => { + multipleTableRef.value!.clearSelection(); + }, 2000); } function handleEdit(row: DashboardItem) { dashboardStore.setMode(true);