From 0dec2fb9128fc910d7f86bd5677b425cbae2f940 Mon Sep 17 00:00:00 2001 From: Qiuxia Fan Date: Tue, 22 Mar 2022 17:52:07 +0800 Subject: [PATCH] add pagination --- src/views/dashboard/List.vue | 26 ++++++++++++++++--- src/views/dashboard/graphs/ServiceList.vue | 4 +-- .../related/topology/components/Graph.vue | 8 ++---- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/views/dashboard/List.vue b/src/views/dashboard/List.vue index a2fc85b7..dd84e4bd 100644 --- a/src/views/dashboard/List.vue +++ b/src/views/dashboard/List.vue @@ -117,6 +117,17 @@ limitations under the License. --> {{ t("import") }} + @@ -137,6 +148,7 @@ import { EntityType } from "./data"; const { t } = useI18n(); const appStore = useAppStoreWithOut(); const dashboardStore = useDashboardStore(); +const pageSize = 18; const dashboards = ref([]); const searchText = ref(""); const loading = ref(false); @@ -151,7 +163,7 @@ const handleSelectionChange = (val: DashboardItem[]) => { setList(); async function setList() { await dashboardStore.setDashboards(); - dashboards.value = dashboardStore.dashboards; + searchDashboards(); } async function importTemplates(event: any) { const arr: any = await readFile(event); @@ -361,16 +373,20 @@ async function handleDelete(row: DashboardItem) { sessionStorage.setItem("dashboards", JSON.stringify(dashboards.value)); sessionStorage.removeItem(`${row.layer}_${row.entity}_${row.name}`); } -function searchDashboards() { +function searchDashboards(pageIndex?: number) { const list = JSON.parse(sessionStorage.getItem("dashboards") || "[]"); - dashboards.value = list.filter((d: { name: string }) => + const arr = list.filter((d: { name: string }) => d.name.includes(searchText.value) ); + dashboards.value = arr.splice(pageIndex || 0, pageSize); } function reloadTemplates() { dashboardStore.resetTemplates(); } +function changePage(pageIndex: number) { + searchDashboards(pageIndex); +}