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
+13 -12
View File
@@ -1,14 +1,14 @@
<template>
<div class="page">
<div class="page table-page">
<div class="page-toolbar">
<n-input
v-model:value="query.keyword"
:placeholder="t('common.label.keyword')"
clearable
style="width: 220px"
@keyup.enter="load"
@keyup.enter="onSearch"
/>
<n-button type="primary" @click="load">
<n-button type="primary" @click="onSearch">
<template #icon><n-icon :component="SearchOutline" /></template>
{{ t('common.action.search') }}
</n-button>
@@ -24,9 +24,11 @@
:data="rows"
:loading="loading"
:pagination="pagination"
class="table-fill"
flex-height
paginate-single-page
remote
:row-key="(r) => r.id"
@update:page="onPage"
/>
<n-modal
@@ -104,14 +106,15 @@ import { templateApi } from '@/api';
import { useAuthStore } from '@/stores/auth';
import { message, dialog } from '@/utils/feedback';
import { fmt, statusType } from '@/utils/format';
import { useTablePage } from '@/composables/useTablePage';
const { t } = useI18n();
const auth = useAuthStore();
const rows = ref<any[]>([]);
const loading = ref(false);
const query = reactive({ keyword: '', page: 1, pageSize: 10 });
const pagination = reactive({ page: 1, pageCount: 1, pageSize: 10, itemCount: 0 });
const query = reactive({ keyword: '' });
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(load);
const fieldTypeOptions = Object.values(FieldType).map((v) => ({ label: t(`common.fieldType.${v}`), value: v }));
@@ -182,17 +185,15 @@ async function toggleStatus(r: any) {
async function load() {
loading.value = true;
try {
const res: any = await templateApi.list({ keyword: query.keyword, page: query.page, pageSize: query.pageSize });
const res: any = await templateApi.list({ keyword: query.keyword, page: page.value, pageSize: pageSize.value });
rows.value = res.list;
pagination.itemCount = res.total;
pagination.page = res.page;
pagination.pageSize = res.pageSize;
setPageResult(res);
} finally {
loading.value = false;
}
}
function onPage(p: number) {
query.page = p;
function onSearch() {
resetPage();
load();
}