diff --git a/deploy/fba/fba-ui-src/apps/web-antdv-next/src/views/iaop/admin/models.vue b/deploy/fba/fba-ui-src/apps/web-antdv-next/src/views/iaop/admin/models.vue index c90172e..9514a00 100644 --- a/deploy/fba/fba-ui-src/apps/web-antdv-next/src/views/iaop/admin/models.vue +++ b/deploy/fba/fba-ui-src/apps/web-antdv-next/src/views/iaop/admin/models.vue @@ -5,7 +5,7 @@ * - 降级:API 不可达时回退 localStorage(iaop.admin.models.v1,旧版 key),UI 标注「离线演示模式」; * - 迁移:检测 localStorage 有数据且服务端在线时提示导入。 */ -import { computed, onMounted, ref } from 'vue'; +import { computed, nextTick, onMounted, ref, watch } from 'vue'; import { Page, VbenButton } from '@vben/common-ui'; import { message } from 'antdv-next'; @@ -62,15 +62,23 @@ const gridOptions: VxeTableGridOptions = { { title: '操作', field: 'action', width: 170, slots: { default: 'action' } }, ], proxy: { - query: async ({ page }) => ({ - items: models.value.slice((page.currentPage - 1) * page.pageSize, page.currentPage * page.pageSize), - total: models.value.length, - }), + query: async ({ page } = {}) => { + // page 可能缺省(分页未就绪的首次查询),兜底返回全量 + const cur = page?.currentPage ?? 1; + const size = page?.pageSize ?? models.value.length || 10; + return { + items: models.value.slice((cur - 1) * size, cur * size), + total: models.value.length, + }; + }, }, }; const [Grid, gridApi] = useVbenVxeGrid({ gridOptions }); +// 数据变化自动刷新表格(双保险:init 的 refresh 与 watch 都触发 query) +watch(models, () => gridApi.query()); + async function refresh() { gridApi.query(); } @@ -85,6 +93,8 @@ async function init() { try { await loadFromServer(); online.value = true; + await nextTick(); + refresh(); // 迁移提示:本地有数据且服务端在线(且本地有服务端没有的模型) const local = loadLocal(); const serverNames = new Set(models.value.map((m) => `${m.name}@${m.version}`)); diff --git a/deploy/fba/fba-ui-src/apps/web-antdv-next/src/views/iaop/studio/version.vue b/deploy/fba/fba-ui-src/apps/web-antdv-next/src/views/iaop/studio/version.vue index 3ecc756..27805af 100644 --- a/deploy/fba/fba-ui-src/apps/web-antdv-next/src/views/iaop/studio/version.vue +++ b/deploy/fba/fba-ui-src/apps/web-antdv-next/src/views/iaop/studio/version.vue @@ -40,10 +40,15 @@ const gridOptions: VxeTableGridOptions = { { title: '说明', field: 'note', minWidth: 200 }, ], proxy: { - query: async ({ page }) => ({ - items: rows.value.slice((page.currentPage - 1) * page.pageSize, page.currentPage * page.pageSize), - total: rows.value.length, - }), + query: async ({ page } = {}) => { + // page 可能缺省(分页未就绪的首次查询),兜底返回全量 + const cur = page?.currentPage ?? 1; + const size = page?.pageSize ?? rows.value.length || 10; + return { + items: rows.value.slice((cur - 1) * size, cur * size), + total: rows.value.length, + }; + }, }, };