sort dashboards

This commit is contained in:
Qiuxia Fan 2022-03-23 18:24:34 +08:00
parent 107a3d85dd
commit 2e24925301
2 changed files with 16 additions and 5 deletions

View File

@ -227,7 +227,6 @@ export const dashboardStore = defineStore({
this.showConfig = show;
},
selectWidget(item: Nullable<LayoutConfig>) {
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;
},

View File

@ -46,6 +46,7 @@ limitations under the License. -->
ref="multipleTableRef"
:default-sort="{ prop: 'name' }"
@selection-change="handleSelectionChange"
height="637px"
>
<el-table-column type="selection" width="55" />
<el-table-column prop="name" label="Name">
@ -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);