feat: 优化后台列表高度与分页容量
This commit is contained in:
@@ -93,6 +93,7 @@
|
||||
- 后台交互拆分(2026-07-03):艺术品档案列表操作列拆为两个图标入口:编辑详情(进入 `/artworks/:id`,只维护基础信息、图片、溯源节点、认证文件)和数据管理(进入 `/artworks/:id/trace-codes`,专门管理该档案下的批次与追溯码)。`ArtworkEdit.vue` 不再内嵌追溯码表,新增 `ArtworkTraceCodes.vue` 复用 `TraceCodePanel` 并展示档案编号、追溯码数、已激活数、查询总数摘要;侧边栏仍只高亮“艺术品档案”。
|
||||
- 出库单条录入修复(2026-07-03):`Outbound.vue` 的远程追溯码下拉原先只在用户输入时触发搜索,页面初次打开 options 为空,导致默认显示“无数据”;现改为 mounted 后主动加载最近 20 条追溯码,输入时继续远程检索,并用请求序号避免旧搜索覆盖新结果。选择追溯码会回填出库时间、备注、出库实况图、最近 ONCHAIN 存证哈希/时间/区块高度;清空选择会清空表单,清空出库时间/图片/备注后保存可真正写回 null。`TraceCodeService.list` 额外返回 `outImageUrl` 与 `latestProof`,供后台出库页回显使用。
|
||||
- 后台艺术品档案文案微调(2026-07-03):艺术品档案列表/表单中 `pages.artwork.images` 从“作品图片 / 视频”改为“作品”,`pages.artwork.title` 从“作品名称”改为“名称”;英文同步为 `Artwork` / `Name`。仅调整语言包,不改变字段名与接口。
|
||||
- 后台列表布局与分页统一(2026-07-03):后台主列表统一接入 `useTablePage`,默认每页 20,分页容量支持 20/50/100/200/不限制,并提供自定义条数输入;“不限制”前端用 `Number.MAX_SAFE_INTEGER` 保持分页器稳定,请求时转换为 `pageSize=0`。后端 `PaginationDto` 约定 `pageSize=0` 表示不分页,`take` 返回 `undefined`,`buildPage` 返回 page=1/pageSize=0。所有主数据表页面(艺术品档案、模板、内容审核、查询日志、用户、追溯码面板)使用 `table-page` + `table-fill` + `flex-height`,页面工具栏和表头固定,数据过多时只在表格内部滚动,不顶走上方组件。
|
||||
|
||||
## 当前代码基准与注意事项
|
||||
|
||||
@@ -100,5 +101,6 @@
|
||||
- 当前核心模型:一款/一个档案 `Artwork` 多个批次 `Batch`,每批次多个实物追溯码 `TraceCode`;`archiveNo` 是款级唯一档案编号,`TraceCode` 是每套实物的一物一码载体,查询统计按档案聚合。
|
||||
- 生码入口:主入口在艺术品档案列表的“数据管理”进入“批次与追溯码管理”;隐藏全局明细页也可生码但必须指定作品档案/款式。不存在“未绑定码池 → 绑定作品”的旧流程。
|
||||
- 出库导入:以短码定位具体一套码,导入列不再包含 SKU 或手填档案编号;档案编号由作品自动生成并在日志/导出/C 端展示。
|
||||
- 后台列表约定:新列表页优先复用 `apps/admin/src/composables/useTablePage.ts`,页面根容器使用 `class="page table-page"`,`n-data-table` 使用 `class="table-fill" flex-height paginate-single-page`;后端列表查询如继承 `PaginationDto`,需遵守 `pageSize=0` 不分页语义。
|
||||
- 客户端:当前 `Trace.vue` 依赖 `openMediaViewer.ts` + PhotoSwipe,不再使用旧 `MediaViewer.vue`;顶部语言菜单和追溯码复制是用户当前未提交改动的一部分,后续若继续修改客户端,需保护这些改动。
|
||||
- 文案残留:`apps/client/src/locales/*` 仍保留 `privacy.note`,但当前页面不显示底部隐私说明;若按合规要求恢复,需要在 `Trace.vue` 重新渲染对应文案。
|
||||
|
||||
@@ -72,10 +72,12 @@
|
||||
:data="rows"
|
||||
:loading="loading"
|
||||
:pagination="pagination"
|
||||
class="table-fill"
|
||||
flex-height
|
||||
paginate-single-page
|
||||
remote
|
||||
:row-key="(r) => r.id"
|
||||
v-model:checked-row-keys="checkedKeys"
|
||||
@update:page="onPage"
|
||||
/>
|
||||
|
||||
<n-modal v-model:show="genModal" preset="card" :title="t('pages.traceCode.generate')" style="width: 440px">
|
||||
@@ -153,6 +155,7 @@ import { useAuthStore } from '@/stores/auth';
|
||||
import { message, dialog } from '@/utils/feedback';
|
||||
import { fmt, statusType } from '@/utils/format';
|
||||
import { downloadFile } from '@/utils/download';
|
||||
import { useTablePage } from '@/composables/useTablePage';
|
||||
|
||||
const props = defineProps<{
|
||||
artworkId?: number;
|
||||
@@ -175,18 +178,14 @@ const query = reactive<{
|
||||
batchId: number | null;
|
||||
status: string | null;
|
||||
keyword: string;
|
||||
page: number;
|
||||
pageSize: number;
|
||||
}>({
|
||||
artworkId: fixedArtworkId.value,
|
||||
groupId: null,
|
||||
batchId: null,
|
||||
status: null,
|
||||
keyword: '',
|
||||
page: 1,
|
||||
pageSize: embedded.value ? 8 : 10,
|
||||
});
|
||||
const pagination = reactive({ page: 1, pageSize: query.pageSize, itemCount: 0 });
|
||||
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(load, embedded.value ? 20 : 20);
|
||||
const statusOptions = Object.values(TraceCodeStatus).map((v) => ({ label: t(`common.status.${v}`), value: v }));
|
||||
|
||||
const batchOptions = ref<{ label: string; value: number }[]>([]);
|
||||
@@ -290,24 +289,18 @@ async function load() {
|
||||
batchId: query.batchId || undefined,
|
||||
status: query.status || undefined,
|
||||
keyword: query.keyword || 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();
|
||||
}
|
||||
|
||||
@@ -452,7 +445,7 @@ watch(
|
||||
query.artworkId = aid;
|
||||
genForm.artworkId = aid;
|
||||
query.batchId = null;
|
||||
query.page = 1;
|
||||
resetPage();
|
||||
await loadBatches();
|
||||
await load();
|
||||
},
|
||||
@@ -474,6 +467,10 @@ onMounted(async () => {
|
||||
<style scoped>
|
||||
.trace-code-panel {
|
||||
min-width: 0;
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.panel-toolbar {
|
||||
display: flex;
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
import { computed, h, reactive, ref, watch } from 'vue';
|
||||
import { NButton, NInputNumber } from 'naive-ui';
|
||||
import type { PaginationProps } from 'naive-ui';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
export const TABLE_PAGE_SIZE_ALL = Number.MAX_SAFE_INTEGER;
|
||||
|
||||
export function useTablePage(load: () => void | Promise<void>, initialPageSize = 20) {
|
||||
const { t, locale } = useI18n();
|
||||
const customPageSize = ref<number | null>(null);
|
||||
|
||||
function pageSizeOptions() {
|
||||
return [
|
||||
{ label: t('common.pagination.perPage', { n: 20 }), value: 20 },
|
||||
{ label: t('common.pagination.perPage', { n: 50 }), value: 50 },
|
||||
{ label: t('common.pagination.perPage', { n: 100 }), value: 100 },
|
||||
{ label: t('common.pagination.perPage', { n: 200 }), value: 200 },
|
||||
{ label: t('common.pagination.unlimited'), value: TABLE_PAGE_SIZE_ALL },
|
||||
];
|
||||
}
|
||||
|
||||
const pagination = reactive<PaginationProps>({
|
||||
page: 1,
|
||||
pageSize: initialPageSize,
|
||||
itemCount: 0,
|
||||
showSizePicker: true,
|
||||
showQuickJumper: true,
|
||||
pageSizes: pageSizeOptions(),
|
||||
displayOrder: ['pages', 'size-picker', 'quick-jumper'],
|
||||
suffix: () =>
|
||||
h('span', { class: 'table-pagination-extra' }, [
|
||||
h(NInputNumber, {
|
||||
value: customPageSize.value,
|
||||
min: 1,
|
||||
precision: 0,
|
||||
size: 'small',
|
||||
placeholder: t('common.pagination.customPageSize'),
|
||||
style: 'width: 116px',
|
||||
showButton: false,
|
||||
onUpdateValue: (value: number | null) => {
|
||||
customPageSize.value = value;
|
||||
},
|
||||
onKeyup: (event: KeyboardEvent) => {
|
||||
if (event.key === 'Enter') applyCustomPageSize(customPageSize.value);
|
||||
},
|
||||
}),
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
size: 'small',
|
||||
disabled: !customPageSize.value || customPageSize.value < 1,
|
||||
onClick: () => applyCustomPageSize(customPageSize.value),
|
||||
},
|
||||
{ default: () => t('common.pagination.apply') },
|
||||
),
|
||||
]),
|
||||
onUpdatePage: (page: number) => {
|
||||
pagination.page = page;
|
||||
void load();
|
||||
},
|
||||
onUpdatePageSize: (pageSize: number) => {
|
||||
pagination.page = 1;
|
||||
pagination.pageSize = pageSize;
|
||||
void load();
|
||||
},
|
||||
});
|
||||
|
||||
const page = computed(() => pagination.page || 1);
|
||||
const pageSize = computed(() => ((pagination.pageSize ?? initialPageSize) === TABLE_PAGE_SIZE_ALL ? 0 : (pagination.pageSize ?? initialPageSize)));
|
||||
|
||||
function resetPage() {
|
||||
pagination.page = 1;
|
||||
}
|
||||
|
||||
function setPageResult(result: { total: number; page: number; pageSize: number }) {
|
||||
pagination.itemCount = result.total;
|
||||
pagination.page = result.page;
|
||||
pagination.pageSize = result.pageSize === 0 ? TABLE_PAGE_SIZE_ALL : result.pageSize;
|
||||
}
|
||||
|
||||
function applyCustomPageSize(value: number | null) {
|
||||
if (!value || value < 1) return;
|
||||
pagination.page = 1;
|
||||
pagination.pageSize = Math.floor(value);
|
||||
customPageSize.value = null;
|
||||
void load();
|
||||
}
|
||||
|
||||
watch(locale, () => {
|
||||
pagination.pageSizes = pageSizeOptions();
|
||||
});
|
||||
|
||||
return { pagination, page, pageSize, resetPage, setPageResult, applyCustomPageSize };
|
||||
}
|
||||
@@ -74,6 +74,12 @@
|
||||
"DISABLED": "Disabled",
|
||||
"ABNORMAL": "Abnormal"
|
||||
},
|
||||
"pagination": {
|
||||
"perPage": "{n} / page",
|
||||
"unlimited": "Unlimited",
|
||||
"customPageSize": "Custom size",
|
||||
"apply": "Apply"
|
||||
},
|
||||
"auditStatus": {
|
||||
"PENDING": "Pending",
|
||||
"APPROVED": "Approved",
|
||||
|
||||
@@ -74,6 +74,12 @@
|
||||
"DISABLED": "停用",
|
||||
"ABNORMAL": "异常"
|
||||
},
|
||||
"pagination": {
|
||||
"perPage": "{n} / 页",
|
||||
"unlimited": "不限制",
|
||||
"customPageSize": "自定义条数",
|
||||
"apply": "应用"
|
||||
},
|
||||
"auditStatus": {
|
||||
"PENDING": "待审核",
|
||||
"APPROVED": "已通过",
|
||||
|
||||
@@ -18,6 +18,13 @@ body,
|
||||
}
|
||||
.page {
|
||||
padding: 16px;
|
||||
min-height: 100%;
|
||||
}
|
||||
.page.table-page {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
.page-toolbar {
|
||||
display: flex;
|
||||
@@ -29,6 +36,19 @@ body,
|
||||
.page-toolbar .spacer {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
.table-fill {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
}
|
||||
.table-fill .n-data-table-wrapper {
|
||||
min-height: 0;
|
||||
}
|
||||
.table-pagination-extra {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.text-ellipsis {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="page table-page">
|
||||
<div class="page-toolbar">
|
||||
<n-button quaternary @click="router.back()">
|
||||
<template #icon><n-icon :component="ArrowBackOutline" /></template>
|
||||
@@ -25,7 +25,7 @@
|
||||
</n-descriptions>
|
||||
</n-card>
|
||||
|
||||
<n-card :title="t('pages.artwork.traceCodes')" :bordered="false">
|
||||
<n-card :title="t('pages.artwork.traceCodes')" :bordered="false" class="table-card">
|
||||
<trace-code-panel :artwork-id="artworkId" />
|
||||
</n-card>
|
||||
</div>
|
||||
@@ -65,6 +65,19 @@ onMounted(loadArtwork);
|
||||
}
|
||||
.summary-card {
|
||||
margin-bottom: 16px;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
.table-card {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.table-card :deep(.n-card__content) {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.summary-title {
|
||||
display: flex;
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="page table-page">
|
||||
<div class="page-toolbar">
|
||||
<n-input
|
||||
v-model:value="query.keyword"
|
||||
@@ -27,9 +27,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 v-model:show="rejectModal" preset="card" :title="t('pages.audit.reject')" style="width: 420px">
|
||||
@@ -58,6 +60,7 @@ import { AuditStatus } from '@artveris/shared';
|
||||
import { auditApi } from '@/api';
|
||||
import { message, dialog } from '@/utils/feedback';
|
||||
import { fmt } from '@/utils/format';
|
||||
import { useTablePage } from '@/composables/useTablePage';
|
||||
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
@@ -65,13 +68,11 @@ const router = useRouter();
|
||||
const rows = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
const acting = ref(false);
|
||||
const query = reactive<{ keyword: string; auditStatus: string | null; page: number; pageSize: number }>({
|
||||
const query = reactive<{ keyword: string; auditStatus: string | null }>({
|
||||
keyword: '',
|
||||
auditStatus: AuditStatus.PENDING,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
});
|
||||
const pagination = reactive({ page: 1, pageSize: 10, itemCount: 0 });
|
||||
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(load);
|
||||
const auditStatusOptions = Object.values(AuditStatus).map((v) => ({ label: t(`common.auditStatus.${v}`), value: v }));
|
||||
|
||||
function auditTagType(s: string) {
|
||||
@@ -121,22 +122,17 @@ async function load() {
|
||||
const res: any = await auditApi.list({
|
||||
keyword: query.keyword || undefined,
|
||||
auditStatus: query.auditStatus || 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 approve(r: any) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="page table-page">
|
||||
<div class="page-toolbar">
|
||||
<n-input
|
||||
v-model:value="query.keyword"
|
||||
@@ -48,9 +48,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>
|
||||
@@ -64,20 +66,19 @@ import dayjs from 'dayjs';
|
||||
import { QueryResult } from '@artveris/shared';
|
||||
import { queryLogApi } from '@/api';
|
||||
import { fmt, statusType } from '@/utils/format';
|
||||
import { useTablePage } from '@/composables/useTablePage';
|
||||
|
||||
const { t } = useI18n();
|
||||
const rows = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
const range = ref<[number, number] | null>(null);
|
||||
const query = reactive<{ keyword: string; archiveNo: string; batchNo: string; result: string | null; startTime?: string; endTime?: string; page: number; pageSize: number }>({
|
||||
const query = reactive<{ keyword: string; archiveNo: string; batchNo: string; result: string | null; startTime?: string; endTime?: string }>({
|
||||
keyword: '',
|
||||
archiveNo: '',
|
||||
batchNo: '',
|
||||
result: null,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
});
|
||||
const pagination = reactive({ page: 1, pageSize: 10, itemCount: 0 });
|
||||
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(load);
|
||||
const resultOptions = Object.values(QueryResult).map((v) => ({ label: t(`common.queryResult.${v}`), value: v }));
|
||||
|
||||
const columns: DataTableColumns<any> = [
|
||||
@@ -117,12 +118,11 @@ async function load() {
|
||||
result: query.result || undefined,
|
||||
startTime: query.startTime,
|
||||
endTime: query.endTime,
|
||||
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;
|
||||
}
|
||||
@@ -138,11 +138,7 @@ function onRange(val: [number, number] | null) {
|
||||
onSearch();
|
||||
}
|
||||
function onSearch() {
|
||||
query.page = 1;
|
||||
load();
|
||||
}
|
||||
function onPage(p: number) {
|
||||
query.page = p;
|
||||
resetPage();
|
||||
load();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<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: 200px" @keyup.enter="onSearch" />
|
||||
<n-button type="primary" @click="onSearch">
|
||||
@@ -13,7 +13,17 @@
|
||||
</n-button>
|
||||
</div>
|
||||
|
||||
<n-data-table :columns="columns" :data="rows" :loading="loading" :pagination="pagination" remote :row-key="(r) => r.id" @update:page="onPage" />
|
||||
<n-data-table
|
||||
:columns="columns"
|
||||
:data="rows"
|
||||
:loading="loading"
|
||||
:pagination="pagination"
|
||||
class="table-fill"
|
||||
flex-height
|
||||
paginate-single-page
|
||||
remote
|
||||
:row-key="(r) => r.id"
|
||||
/>
|
||||
|
||||
<n-modal v-model:show="showModal" preset="card" :title="editing ? t('pages.user.edit') : t('pages.user.create')" style="width: 460px">
|
||||
<n-form ref="formRef" :model="form" :rules="rules" label-placement="top">
|
||||
@@ -62,12 +72,13 @@ import { RoleType, UserStatus } from '@artveris/shared';
|
||||
import { userApi } from '@/api';
|
||||
import { message, dialog } from '@/utils/feedback';
|
||||
import { fmt, statusType } from '@/utils/format';
|
||||
import { useTablePage } from '@/composables/useTablePage';
|
||||
|
||||
const { t } = useI18n();
|
||||
const rows = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
const query = reactive({ keyword: '', page: 1, pageSize: 10 });
|
||||
const pagination = reactive({ page: 1, pageSize: 10, itemCount: 0 });
|
||||
const query = reactive({ keyword: '' });
|
||||
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(load);
|
||||
const roleOptions = Object.values(RoleType).map((v) => ({ label: t(`common.role.${v}`), value: v }));
|
||||
const statusOptions = Object.values(UserStatus).map((v) => ({ label: t(`common.status.${v}`), value: v }));
|
||||
|
||||
@@ -113,20 +124,15 @@ const columns: DataTableColumns<any> = [
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res: any = await userApi.list({ keyword: query.keyword, page: query.page, pageSize: query.pageSize });
|
||||
const res: any = await userApi.list({ keyword: query.keyword, 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();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsInt, IsOptional, Max, Min } from 'class-validator';
|
||||
import { IsInt, IsOptional, Min } from 'class-validator';
|
||||
|
||||
export class PaginationDto {
|
||||
@ApiPropertyOptional({ description: '页码,从 1 开始', default: 1 })
|
||||
@@ -14,15 +14,15 @@ export class PaginationDto {
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@Max(200)
|
||||
pageSize = 10;
|
||||
@Min(0)
|
||||
pageSize = 20;
|
||||
|
||||
get skip(): number {
|
||||
return (this.page - 1) * this.pageSize;
|
||||
}
|
||||
|
||||
get take(): number {
|
||||
get take(): number | undefined {
|
||||
if (this.pageSize === 0) return undefined;
|
||||
return this.pageSize;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PageResult } from '@artveris/shared';
|
||||
|
||||
export function buildPage<T>(list: T[], total: number, page: number, pageSize: number): PageResult<T> {
|
||||
return { list, total, page, pageSize };
|
||||
return { list, total, page: pageSize === 0 ? 1 : page, pageSize };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user