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() {