From b93830c835e103a4a4d5a9f911ec2200a57f0995 Mon Sep 17 00:00:00 2001 From: bot_dev2 Date: Thu, 6 Aug 2026 16:00:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20vxe-grid=20proxy.query=20=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E5=85=9C=E5=BA=95=EF=BC=88page=20=E7=BC=BA=E7=9C=81?= =?UTF-8?q?=E6=97=B6=E8=BF=94=E5=9B=9E=E5=85=A8=E9=87=8F=EF=BC=8CE2=20?= =?UTF-8?q?=E9=87=8D=E5=86=99=E8=A6=86=E7=9B=96=E4=BA=86=20QA=20cd7d4fd=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AF=BC=E8=87=B4=20models/version=200=20?= =?UTF-8?q?=E6=9D=A1=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/iaop/admin/models.vue | 20 ++++++++++++++----- .../src/views/iaop/studio/version.vue | 13 ++++++++---- 2 files changed, 24 insertions(+), 9 deletions(-) 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, + }; + }, }, };