From e65f57f3873cda4b8f1528011da94010061b7233 Mon Sep 17 00:00:00 2001 From: 170-carry Date: Mon, 27 Apr 2026 23:19:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=A1=B5100?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/src/views/operate/gold-running-water.vue | 75 ++++++++++++++----- 1 file changed, 58 insertions(+), 17 deletions(-) diff --git a/apps/src/views/operate/gold-running-water.vue b/apps/src/views/operate/gold-running-water.vue index ff035eb..d146ba1 100644 --- a/apps/src/views/operate/gold-running-water.vue +++ b/apps/src/views/operate/gold-running-water.vue @@ -12,6 +12,7 @@ import { DatePicker, Input, message, + Pagination, Select, Space, Table, @@ -52,6 +53,7 @@ const sysOriginOptions = computed(() => { return options.length > 0 ? options : getAllowedSysOrigins([]); }); +const DEFAULT_PAGE_SIZE = 100; const loading = ref(false); const loadMoreLoading = ref(false); const list = ref>>([]); @@ -59,12 +61,13 @@ const notMore = ref(false); const originKeyword = ref(''); const sysOrigins = ref([]); const rangeDate = ref<[string, string] | null>(null); +const currentPage = ref(1); const query = reactive>({ context: '', endTime: '', id: '', - limit: 20, + limit: DEFAULT_PAGE_SIZE, origin: '', startTime: '', sysOrigin: '', @@ -98,6 +101,20 @@ const originOptions = computed(() => { })); }); +const currentPageList = computed(() => { + const pageSize = Number(query.limit || DEFAULT_PAGE_SIZE); + const startIndex = (currentPage.value - 1) * pageSize; + return list.value.slice(startIndex, startIndex + pageSize); +}); + +const paginationTotal = computed(() => { + const pageSize = Number(query.limit || DEFAULT_PAGE_SIZE); + if (notMore.value) { + return list.value.length; + } + return Math.max(list.value.length + pageSize, (currentPage.value + 1) * pageSize); +}); + watch( rangeDate, (value) => { @@ -185,6 +202,7 @@ async function loadData(reset = false) { list.value = []; notMore.value = false; query.context = ''; + currentPage.value = 1; } normalizeOriginValue(); @@ -204,15 +222,39 @@ async function loadData(reset = false) { const waters = result?.waters || []; list.value = reset ? waters : [...list.value, ...waters]; query.context = result?.context || ''; - notMore.value = Boolean(result?.listOver); + notMore.value = Boolean(result?.listOver) || !query.context; } finally { loading.value = false; loadMoreLoading.value = false; } } -function handleSearch() { - void loadData(true); +async function ensurePageLoaded(page: number) { + const pageSize = Number(query.limit || DEFAULT_PAGE_SIZE); + let guard = 0; + while (!notMore.value && list.value.length < page * pageSize && guard < page) { + const beforeLength = list.value.length; + const beforeContext = query.context; + await loadData(false); + guard += 1; + if (list.value.length === beforeLength && query.context === beforeContext) { + break; + } + } +} + +async function handlePageChange(page: number) { + await ensurePageLoaded(page); + if (notMore.value) { + const maxPage = Math.max(1, Math.ceil(list.value.length / Number(query.limit || DEFAULT_PAGE_SIZE))); + currentPage.value = Math.min(page, maxPage); + return; + } + currentPage.value = page; +} + +async function handleSearch() { + await loadData(true); } function openUserDetails(record: Record) { @@ -294,7 +336,7 @@ void loadData(true);
-
- - 已加载全部 + @@ -384,9 +425,9 @@ void loadData(true); color: #262626; } -.load-more { +.pagination { display: flex; - justify-content: center; + justify-content: flex-end; margin-top: 16px; }