fix: 修复后台列表分页交互
This commit is contained in:
@@ -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} / 页`。已用浏览器实测艺术品档案、查询日志、批次与追溯码管理行数据显示正常。
|
||||
|
||||
## 当前代码基准与注意事项
|
||||
|
||||
|
||||
@@ -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"
|
||||
/>
|
||||
<div class="table-pagination">
|
||||
<n-pagination v-bind="pagination" :disabled="loading" />
|
||||
</div>
|
||||
|
||||
<n-modal v-model:show="genModal" preset="card" :title="t('pages.traceCode.generate')" style="width: 440px">
|
||||
<n-form :model="genForm" label-placement="top">
|
||||
|
||||
@@ -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<void>, initialPageSize = 20) {
|
||||
const { t, locale } = useI18n();
|
||||
const showCustomPageSize = ref(false);
|
||||
const customPageSize = ref<number | null>(null);
|
||||
const appliedCustomPageSize = ref<number | null>(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<PaginationProps>({
|
||||
@@ -27,8 +38,9 @@ export function useTablePage(load: () => void | Promise<void>, 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<void>, 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<void>, 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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -26,7 +26,9 @@
|
||||
</n-card>
|
||||
|
||||
<n-card :title="t('pages.artwork.traceCodes')" :bordered="false" class="table-card">
|
||||
<trace-code-panel :artwork-id="artworkId" />
|
||||
<div class="trace-table-wrap">
|
||||
<trace-code-panel :artwork-id="artworkId" />
|
||||
</div>
|
||||
</n-card>
|
||||
</div>
|
||||
</template>
|
||||
@@ -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;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -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"
|
||||
/>
|
||||
<div class="table-pagination">
|
||||
<n-pagination v-bind="pagination" :disabled="loading" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -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"
|
||||
/>
|
||||
<div class="table-pagination">
|
||||
<n-pagination v-bind="pagination" :disabled="loading" />
|
||||
</div>
|
||||
|
||||
<n-modal v-model:show="rejectModal" preset="card" :title="t('pages.audit.reject')" style="width: 420px">
|
||||
<n-form label-placement="top">
|
||||
|
||||
@@ -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"
|
||||
/>
|
||||
<div class="table-pagination">
|
||||
<n-pagination v-bind="pagination" :disabled="loading" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -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"
|
||||
/>
|
||||
<div class="table-pagination">
|
||||
<n-pagination v-bind="pagination" :disabled="loading" />
|
||||
</div>
|
||||
|
||||
<n-modal
|
||||
v-model:show="showModal"
|
||||
|
||||
@@ -17,13 +17,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"
|
||||
/>
|
||||
<div class="table-pagination">
|
||||
<n-pagination v-bind="pagination" :disabled="loading" />
|
||||
</div>
|
||||
|
||||
<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">
|
||||
|
||||
Reference in New Issue
Block a user