From 05caace9856877e947469420d5861dc19d64f1a2 Mon Sep 17 00:00:00 2001 From: JEECG <445654970@qq.com> Date: Fri, 30 Jan 2026 15:35:36 +0800 Subject: [PATCH] =?UTF-8?q?online=E6=B7=BB=E5=8A=A0=EF=BC=8C=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=AD=97=E6=AE=B5=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JVxeTable/src/hooks/useDataSource.ts | 44 +++++++------------ 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/jeecgboot-vue3/src/components/jeecg/JVxeTable/src/hooks/useDataSource.ts b/jeecgboot-vue3/src/components/jeecg/JVxeTable/src/hooks/useDataSource.ts index 74b7b8cd0..7bc9963fe 100644 --- a/jeecgboot-vue3/src/components/jeecg/JVxeTable/src/hooks/useDataSource.ts +++ b/jeecgboot-vue3/src/components/jeecg/JVxeTable/src/hooks/useDataSource.ts @@ -1,43 +1,29 @@ import { nextTick, watch } from 'vue'; import { JVxeDataProps, JVxeRefs, JVxeTableMethods } from '../types'; -import { cloneDeep, debounce } from 'lodash-es'; +import { cloneDeep } from 'lodash-es'; export function useDataSource(props, data: JVxeDataProps, methods: JVxeTableMethods, refs: JVxeRefs) { - // update-begin--author:liaozhiyang---date:20260130---for:【QQYUN-14177】online配置界面,字段配置卡顿 - // 使用浅拷贝优化大数据量处理 - const processDataSource = debounce(async (newDataSource) => { - if (!Array.isArray(newDataSource)) { - data.vxeDataSource.value = []; - return; - } - data.vxeDataSource.value = cloneDeep(newDataSource); - // 批量处理禁用行,减少循环次数 - const disabledRowIds: string[] = []; - data.vxeDataSource.value.forEach((row, rowIndex) => { - // 判断是否是禁用行 - if (methods.isDisabledRow(row, rowIndex)) { - disabledRowIds.push(row.id); - } - // 处理联动回显数据 - methods.handleLinkageBackData(row); - }); - data.disabledRowIds = disabledRowIds; - - const grid = await waitRef(refs.gridRef); - if (grid?.value) methods.recalcSortNumber(); - }, 50); // 50ms 防抖,避免频繁更新 - watch( () => props.dataSource, - (newDataSource) => { - processDataSource(newDataSource); + async () => { + data.disabledRowIds = []; + data.vxeDataSource.value = cloneDeep(props.dataSource); + data.vxeDataSource.value.forEach((row, rowIndex) => { + // 判断是否是禁用行 + if (methods.isDisabledRow(row, rowIndex)) { + data.disabledRowIds.push(row.id); + } + // 处理联动回显数据 + methods.handleLinkageBackData(row); + }); + await waitRef(refs.gridRef); + methods.recalcSortNumber(); }, { immediate: true } ); - // update-end--author:liaozhiyang---date:20260130---for:【QQYUN-14177】online配置界面,字段配置卡顿 } // update-begin--author:liaozhiyang---date:20260130---for:【QQYUN-14177】online配置界面,字段配置卡顿 -function waitRef($ref, maxTries = 10) { +function waitRef($ref, maxTries = 100) { return new Promise((resolve) => { let tries = 0; (function next() {