online添加,默认字段丢失

This commit is contained in:
JEECG
2026-01-30 15:35:36 +08:00
parent 80b8573232
commit 05caace985

View File

@ -1,43 +1,29 @@
import { nextTick, watch } from 'vue'; import { nextTick, watch } from 'vue';
import { JVxeDataProps, JVxeRefs, JVxeTableMethods } from '../types'; 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) { export function useDataSource(props, data: JVxeDataProps, methods: JVxeTableMethods, refs: JVxeRefs) {
// update-begin--author:liaozhiyang---date:20260130---for:【QQYUN-14177】online配置界面字段配置卡顿 watch(
// 使用浅拷贝优化大数据量处理 () => props.dataSource,
const processDataSource = debounce(async (newDataSource) => { async () => {
if (!Array.isArray(newDataSource)) { data.disabledRowIds = [];
data.vxeDataSource.value = []; data.vxeDataSource.value = cloneDeep(props.dataSource);
return;
}
data.vxeDataSource.value = cloneDeep(newDataSource);
// 批量处理禁用行,减少循环次数
const disabledRowIds: string[] = [];
data.vxeDataSource.value.forEach((row, rowIndex) => { data.vxeDataSource.value.forEach((row, rowIndex) => {
// 判断是否是禁用行 // 判断是否是禁用行
if (methods.isDisabledRow(row, rowIndex)) { if (methods.isDisabledRow(row, rowIndex)) {
disabledRowIds.push(row.id); data.disabledRowIds.push(row.id);
} }
// 处理联动回显数据 // 处理联动回显数据
methods.handleLinkageBackData(row); methods.handleLinkageBackData(row);
}); });
data.disabledRowIds = disabledRowIds; await waitRef(refs.gridRef);
methods.recalcSortNumber();
const grid = await waitRef(refs.gridRef);
if (grid?.value) methods.recalcSortNumber();
}, 50); // 50ms 防抖,避免频繁更新
watch(
() => props.dataSource,
(newDataSource) => {
processDataSource(newDataSource);
}, },
{ immediate: true } { immediate: true }
); );
// update-end--author:liaozhiyang---date:20260130---for:【QQYUN-14177】online配置界面字段配置卡顿
} }
// update-begin--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<any>((resolve) => { return new Promise<any>((resolve) => {
let tries = 0; let tries = 0;
(function next() { (function next() {