From 80cdcaddea27f5b0c619c17fe309913e77afad7b Mon Sep 17 00:00:00 2001 From: Nixevol Date: Fri, 3 Jul 2026 05:09:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=88=86=E9=A1=B5=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aidocs/project_context.md | 2 +- apps/admin/src/components/TraceCodePanel.vue | 6 ++- apps/admin/src/composables/useTablePage.ts | 40 +++++++++++++++++--- apps/admin/src/styles.css | 22 ++++++++++- apps/admin/src/views/ArtworkTraceCodes.vue | 13 ++++++- apps/admin/src/views/Artworks.vue | 6 ++- apps/admin/src/views/Audit.vue | 6 ++- apps/admin/src/views/QueryLogs.vue | 6 ++- apps/admin/src/views/Templates.vue | 6 ++- apps/admin/src/views/Users.vue | 6 ++- 10 files changed, 90 insertions(+), 23 deletions(-) diff --git a/aidocs/project_context.md b/aidocs/project_context.md index 1b079c6..652618a 100644 --- a/aidocs/project_context.md +++ b/aidocs/project_context.md @@ -93,7 +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`,页面工具栏和表头固定,数据过多时只在表格内部滚动,不顶走上方组件。 +- 后台列表布局与分页统一(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`,页面布局固定为“工具栏 / 表格滚动区 / 底部分页栏”;`n-data-table` 禁用内置分页,外置 `n-pagination` 固定在底部,避免空数据/少数据时分页贴在表头下方,也避免多数据时分页被表格内容挤出视口。追溯码嵌套页需让 `n-card-content -> trace-table-wrap -> TraceCodePanel` 全链路传递 `min-height:0` 与 flex 高度,防止表体高度塌为 0。自定义分页条数只在选择“自定义条数”后展开输入框和应用按钮,应用后自动收起,并把输入值动态加入分页容量下拉显示为 `{n} / 页`。已用浏览器实测艺术品档案、查询日志、批次与追溯码管理行数据显示正常。 ## 当前代码基准与注意事项 diff --git a/apps/admin/src/components/TraceCodePanel.vue b/apps/admin/src/components/TraceCodePanel.vue index 81437e2..24ae4d9 100644 --- a/apps/admin/src/components/TraceCodePanel.vue +++ b/apps/admin/src/components/TraceCodePanel.vue @@ -71,14 +71,16 @@ :columns="columns" :data="rows" :loading="loading" - :pagination="pagination" + :pagination="false" class="table-fill" flex-height - paginate-single-page remote :row-key="(r) => r.id" v-model:checked-row-keys="checkedKeys" /> +
+ +
diff --git a/apps/admin/src/composables/useTablePage.ts b/apps/admin/src/composables/useTablePage.ts index bf533ad..65404b1 100644 --- a/apps/admin/src/composables/useTablePage.ts +++ b/apps/admin/src/composables/useTablePage.ts @@ -4,19 +4,30 @@ import type { PaginationProps } from 'naive-ui'; import { useI18n } from 'vue-i18n'; export const TABLE_PAGE_SIZE_ALL = Number.MAX_SAFE_INTEGER; +const TABLE_PAGE_SIZE_CUSTOM = Number.MAX_SAFE_INTEGER - 1; export function useTablePage(load: () => void | Promise, initialPageSize = 20) { const { t, locale } = useI18n(); + const showCustomPageSize = ref(false); const customPageSize = ref(null); + const appliedCustomPageSize = ref(null); function pageSizeOptions() { - return [ + const options = [ { 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 }, + { label: t('common.pagination.customPageSize'), value: TABLE_PAGE_SIZE_CUSTOM }, ]; + if (appliedCustomPageSize.value && !options.some((item) => item.value === appliedCustomPageSize.value)) { + options.splice(options.length - 1, 0, { + label: t('common.pagination.perPage', { n: appliedCustomPageSize.value }), + value: appliedCustomPageSize.value, + }); + } + return options; } const pagination = reactive({ @@ -27,8 +38,9 @@ export function useTablePage(load: () => void | Promise, initialPageSize = showQuickJumper: true, pageSizes: pageSizeOptions(), displayOrder: ['pages', 'size-picker', 'quick-jumper'], - suffix: () => - h('span', { class: 'table-pagination-extra' }, [ + suffix: () => { + if (!showCustomPageSize.value) return null; + return h('span', { class: 'table-pagination-extra' }, [ h(NInputNumber, { value: customPageSize.value, min: 1, @@ -53,12 +65,20 @@ export function useTablePage(load: () => void | Promise, initialPageSize = }, { default: () => t('common.pagination.apply') }, ), - ]), + ]); + }, onUpdatePage: (page: number) => { pagination.page = page; void load(); }, onUpdatePageSize: (pageSize: number) => { + if (pageSize === TABLE_PAGE_SIZE_CUSTOM) { + showCustomPageSize.value = true; + customPageSize.value = appliedCustomPageSize.value || 20; + pagination.pageSize = appliedCustomPageSize.value || initialPageSize; + return; + } + showCustomPageSize.value = false; pagination.page = 1; pagination.pageSize = pageSize; void load(); @@ -75,13 +95,21 @@ export function useTablePage(load: () => void | Promise, initialPageSize = 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; + const nextPageSize = result.pageSize === 0 ? TABLE_PAGE_SIZE_ALL : result.pageSize; + if (nextPageSize !== TABLE_PAGE_SIZE_ALL && ![20, 50, 100, 200].includes(nextPageSize)) { + appliedCustomPageSize.value = nextPageSize; + pagination.pageSizes = pageSizeOptions(); + } + pagination.pageSize = nextPageSize; } function applyCustomPageSize(value: number | null) { if (!value || value < 1) return; + appliedCustomPageSize.value = Math.floor(value); + pagination.pageSizes = pageSizeOptions(); + showCustomPageSize.value = false; pagination.page = 1; - pagination.pageSize = Math.floor(value); + pagination.pageSize = appliedCustomPageSize.value; customPageSize.value = null; void load(); } diff --git a/apps/admin/src/styles.css b/apps/admin/src/styles.css index bcdf56a..88360a7 100644 --- a/apps/admin/src/styles.css +++ b/apps/admin/src/styles.css @@ -21,7 +21,8 @@ body, min-height: 100%; } .page.table-page { - height: 100%; + height: calc(100vh - 56px); + max-height: calc(100vh - 56px); display: flex; flex-direction: column; overflow: hidden; @@ -37,12 +38,29 @@ body, flex: 1 1 auto; } .table-fill { - flex: 1 1 auto; + flex: 1 1 0; + height: 0; min-height: 0; } .table-fill .n-data-table-wrapper { + flex: 1 1 auto; min-height: 0; } +.table-fill .n-data-table-base-table { + min-height: 0; +} +.table-fill .n-data-table-base-table-body { + flex: 1 1 auto !important; + min-height: 0; +} +.table-pagination { + flex: 0 0 auto; + display: flex; + justify-content: flex-end; + align-items: center; + padding-top: 12px; + overflow-x: auto; +} .table-pagination-extra { display: inline-flex; align-items: center; diff --git a/apps/admin/src/views/ArtworkTraceCodes.vue b/apps/admin/src/views/ArtworkTraceCodes.vue index 7d46746..b31a0d0 100644 --- a/apps/admin/src/views/ArtworkTraceCodes.vue +++ b/apps/admin/src/views/ArtworkTraceCodes.vue @@ -26,7 +26,9 @@ - +
+ +
@@ -73,7 +75,7 @@ onMounted(loadArtwork); display: flex; flex-direction: column; } -.table-card :deep(.n-card__content) { +.table-card :deep(.n-card-content) { flex: 1 1 auto; min-height: 0; display: flex; @@ -85,4 +87,11 @@ onMounted(loadArtwork); gap: 10px; min-width: 0; } +.trace-table-wrap { + flex: 1 1 auto; + height: 100%; + min-height: 0; + display: flex; + flex-direction: column; +} diff --git a/apps/admin/src/views/Artworks.vue b/apps/admin/src/views/Artworks.vue index a593b70..41f6a57 100644 --- a/apps/admin/src/views/Artworks.vue +++ b/apps/admin/src/views/Artworks.vue @@ -31,13 +31,15 @@ :columns="columns" :data="rows" :loading="loading" - :pagination="pagination" + :pagination="false" class="table-fill" flex-height - paginate-single-page remote :row-key="(r) => r.id" /> +
+ +
diff --git a/apps/admin/src/views/Audit.vue b/apps/admin/src/views/Audit.vue index 8dcd6d0..5a02add 100644 --- a/apps/admin/src/views/Audit.vue +++ b/apps/admin/src/views/Audit.vue @@ -26,13 +26,15 @@ :columns="columns" :data="rows" :loading="loading" - :pagination="pagination" + :pagination="false" class="table-fill" flex-height - paginate-single-page remote :row-key="(r) => r.id" /> +
+ +
diff --git a/apps/admin/src/views/QueryLogs.vue b/apps/admin/src/views/QueryLogs.vue index 6243ca1..5532469 100644 --- a/apps/admin/src/views/QueryLogs.vue +++ b/apps/admin/src/views/QueryLogs.vue @@ -47,13 +47,15 @@ :columns="columns" :data="rows" :loading="loading" - :pagination="pagination" + :pagination="false" class="table-fill" flex-height - paginate-single-page remote :row-key="(r) => r.id" /> +
+ +
diff --git a/apps/admin/src/views/Templates.vue b/apps/admin/src/views/Templates.vue index f6bddc1..a24f598 100644 --- a/apps/admin/src/views/Templates.vue +++ b/apps/admin/src/views/Templates.vue @@ -23,13 +23,15 @@ :columns="columns" :data="rows" :loading="loading" - :pagination="pagination" + :pagination="false" class="table-fill" flex-height - paginate-single-page remote :row-key="(r) => r.id" /> +
+ +
+
+ +