From 03dbd044525fac8031b25309f35bc1487bdca993 Mon Sep 17 00:00:00 2001 From: bot_dev2 Date: Thu, 6 Aug 2026 16:06:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20models=20=E9=A1=B5=E6=94=B9=20:data=20?= =?UTF-8?q?=E5=93=8D=E5=BA=94=E5=BC=8F=E7=BB=91=E5=AE=9A=EF=BC=88=E5=BC=82?= =?UTF-8?q?=E6=AD=A5=20fetch=20=E6=95=B0=E6=8D=AE=20+=20proxy=20=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E6=97=B6=E5=BA=8F=E5=AF=BC=E8=87=B4=200=20=E6=9D=A1?= =?UTF-8?q?=EF=BC=8Cvxe-grid=20data=20=E7=9B=B4=E7=BB=91=E6=9C=80=E7=A8=B3?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/iaop/admin/models.vue | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 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 a8599db..f2fe36c 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, nextTick, onMounted, ref, watch } from 'vue'; +import { onMounted, ref } from 'vue'; import { Page, VbenButton } from '@vben/common-ui'; import { message } from 'antdv-next'; @@ -61,26 +61,15 @@ const gridOptions: VxeTableGridOptions = { { title: '说明', field: 'description', minWidth: 220 }, { title: '操作', field: 'action', width: 170, slots: { default: 'action' } }, ], - proxy: { - 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, - }; - }, - }, + // 数据直接绑定 :data(响应式自动渲染,规避 proxy 分页就绪时序) + data: models, }; const [Grid, gridApi] = useVbenVxeGrid({ gridOptions }); -// 数据变化自动刷新表格(双保险:init 的 refresh 与 watch 都触发 query) -watch(models, () => gridApi.query()); async function refresh() { - gridApi.query(); + // :data 响应式绑定,数据变化自动渲染 } async function loadFromServer() { @@ -93,7 +82,6 @@ async function init() { try { await loadFromServer(); online.value = true; - await nextTick(); refresh(); // 迁移提示:本地有数据且服务端在线(且本地有服务端没有的模型) const local = loadLocal(); @@ -185,7 +173,7 @@ onMounted(init); {{ online ? '● 服务端在线' : '● 离线演示模式' }} - +