From 439a35c16572bfd1c77ffbc0f177acdf354c470b Mon Sep 17 00:00:00 2001 From: haohao <1036606149@qq.com> Date: Tue, 16 Dec 2025 09:58:16 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=E3=80=90antd=E3=80=91=E3=80=90iot?= =?UTF-8?q?=E3=80=91=E7=BB=9F=E4=B8=80=E5=88=97=E8=A1=A8=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=E5=92=8C=E5=8D=A1=E7=89=87=E8=A7=86=E5=9B=BE=E7=9A=84=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/iot/product/product/index.vue | 22 +++++++++++-------- .../iot/product/product/modules/card-view.vue | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/apps/web-antd/src/views/iot/product/product/index.vue b/apps/web-antd/src/views/iot/product/product/index.vue index da7930c82..302fc1f1c 100644 --- a/apps/web-antd/src/views/iot/product/product/index.vue +++ b/apps/web-antd/src/views/iot/product/product/index.vue @@ -51,11 +51,8 @@ async function loadCategories() { function handleSearch() { if (viewMode.value === 'list') { gridApi.formApi.setValues(queryParams.value); - gridApi.query(); - } else { - // TODO @haohao:要不 search 也改成 query 方法,更统一一点哈。 - cardViewRef.value?.search(queryParams.value); } + gridApi.query(); } /** 重置搜索 */ @@ -67,11 +64,7 @@ function handleReset() { /** 刷新表格 */ function handleRefresh() { - if (viewMode.value === 'list') { - gridApi.query(); - } else { - cardViewRef.value?.reload(); - } + gridApi.query(); } /** 导出表格 */ @@ -149,6 +142,17 @@ const [Grid, gridApi] = useVbenVxeGrid({ } as VxeTableGridOptions, }); +// 包装 gridApi.query() 方法,统一列表视图和卡片视图的查询接口 +const originalQuery = gridApi.query.bind(gridApi); +gridApi.query = async (params?: Record) => { + if (viewMode.value === 'list') { + return await originalQuery(params); + } else { + // 卡片视图:调用卡片组件的 query 方法 + cardViewRef.value?.query(); + } +}; + /** 初始化 */ onMounted(() => { loadCategories(); diff --git a/apps/web-antd/src/views/iot/product/product/modules/card-view.vue b/apps/web-antd/src/views/iot/product/product/modules/card-view.vue index ac297355f..49150ae99 100644 --- a/apps/web-antd/src/views/iot/product/product/modules/card-view.vue +++ b/apps/web-antd/src/views/iot/product/product/modules/card-view.vue @@ -85,7 +85,7 @@ function getDeviceTypeColor(deviceType: number) { defineExpose({ reload: getList, - search: () => { + query: () => { queryParams.value.pageNo = 1; getList(); },