feat: 优化后台列表高度与分页容量

This commit is contained in:
Nixevol
2026-07-03 04:45:01 +08:00
parent 0e817c453e
commit 5c564e9f24
14 changed files with 227 additions and 94 deletions
+11 -15
View File
@@ -1,5 +1,5 @@
<template>
<div class="page">
<div class="page table-page">
<div class="page-toolbar">
<n-input
v-model:value="query.keyword"
@@ -32,9 +32,11 @@
:data="rows"
:loading="loading"
:pagination="pagination"
class="table-fill"
flex-height
paginate-single-page
remote
:row-key="(r) => r.id"
@update:page="onPage"
/>
</div>
</template>
@@ -49,6 +51,7 @@ import { ArtworkStatus } from '@artveris/shared';
import { artworkApi } from '@/api';
import { useAuthStore } from '@/stores/auth';
import { fmt, statusType } from '@/utils/format';
import { useTablePage } from '@/composables/useTablePage';
const { t } = useI18n();
const router = useRouter();
@@ -56,13 +59,11 @@ const auth = useAuthStore();
const rows = ref<any[]>([]);
const loading = ref(false);
const query = reactive<{ keyword: string; status: string | null; page: number; pageSize: number }>({
const query = reactive<{ keyword: string; status: string | null }>({
keyword: '',
status: null,
page: 1,
pageSize: 10,
});
const pagination = reactive({ page: 1, pageSize: 10, itemCount: 0 });
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(load);
const statusOptions = Object.values(ArtworkStatus).map((v) => ({ label: t(`common.status.${v}`), value: v }));
const columns: DataTableColumns<any> = [
@@ -137,22 +138,17 @@ async function load() {
const res: any = await artworkApi.list({
keyword: query.keyword,
status: query.status || undefined,
page: query.page,
pageSize: query.pageSize,
page: page.value,
pageSize: pageSize.value,
});
rows.value = res.list;
pagination.itemCount = res.total;
pagination.page = res.page;
setPageResult(res);
} finally {
loading.value = false;
}
}
function onSearch() {
query.page = 1;
load();
}
function onPage(p: number) {
query.page = p;
resetPage();
load();
}
function goCreate() {