Skip to content

Commit 2bf074c

Browse files
committed
【issues/9593】树表的页面属性中子节点和父节点的属性串了
1 parent 6f00250 commit 2bf074c

1 file changed

Lines changed: 44 additions & 29 deletions

File tree

jeecgboot-vue3/src/views/super/online/cgform/components/CgformModal.vue

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -404,37 +404,50 @@
404404
const SYS_BUILT_IN_FIELDS = ['create_by', 'create_time', 'update_by', 'update_time', 'sys_org_code'];
405405
// update-end--author:liaozhiyang---date:20260414---for:【QQYUN-15128】新增字段时系统字段永远在最下面
406406
407+
// update-begin--author:liaozhiyang---date:20260506---for:【issues/9593】树表的页面属性中子节点和父节点的属性串了
408+
let onTableAddedQueue: Promise<unknown> = Promise.resolve();
409+
// update-end--author:liaozhiyang---date:20260506---for:【issues/9593】树表的页面属性中子节点和父节点的属性串了
410+
407411
/** 当新增了的时候应立即同步 */
408-
async function onTableAdded() {
409-
// update-begin--author:liaozhiyang---date:20260414---for:【QQYUN-15128】新增行时系统字段永远在最下面(系统字段被删除时退化为正常追加)
410-
const dbJVxeRef = tables.dbTable.value?.tableRef;
411-
if (dbJVxeRef) {
412-
const fullData = dbJVxeRef.getXTable().internalData.tableFullData;
413-
const sysIndex = fullData.findIndex((row) => SYS_BUILT_IN_FIELDS.includes(row.dbFieldName));
414-
const lastIndex = fullData.length - 1;
415-
// 末尾是新增行,且在系统字段后面,且本身不是系统字段
416-
if (sysIndex !== -1 && lastIndex > sysIndex && !SYS_BUILT_IN_FIELDS.includes(fullData[lastIndex]?.dbFieldName)) {
417-
const newRowData = { ...fullData[lastIndex] };
418-
// 在 dbTable 中把末尾新行移到第一个系统字段前面
419-
await dbJVxeRef.rowResort(lastIndex, sysIndex);
420-
// 对其他 tables 直接在系统字段前面插入,不走 syncAllTableNow 的追加逻辑
421-
const { pageTable, checkTable, fkTable, queryTable } = tables;
422-
for (const t of [pageTable, checkTable, fkTable, queryTable]) {
423-
const jvxeRef = t.value?.tableRef;
424-
if (!jvxeRef) continue;
425-
const tFullData = jvxeRef.getXTable().internalData.tableFullData;
426-
const tSysIndex = tFullData.findIndex((row) => SYS_BUILT_IN_FIELDS.includes(row.dbFieldName));
427-
if (tSysIndex !== -1) {
428-
jvxeRef.insertRows(newRowData, tSysIndex);
429-
} else {
430-
jvxeRef.addRows(newRowData);
412+
function onTableAdded() {
413+
// update-begin--author:liaozhiyang---date:20260506---for: 【issues/9593】树表的页面属性中子节点和父节点的属性串了
414+
onTableAddedQueue = onTableAddedQueue.then(async () => {
415+
// update-begin--author:liaozhiyang---date:20260414---for:【QQYUN-15128】新增行时系统字段永远在最下面(系统字段被删除时退化为正常追加)
416+
const dbJVxeRef = tables.dbTable.value?.tableRef;
417+
if (dbJVxeRef) {
418+
const fullData = dbJVxeRef.getXTable().internalData.tableFullData;
419+
const sysIndex = fullData.findIndex((row) => SYS_BUILT_IN_FIELDS.includes(row.dbFieldName));
420+
const lastIndex = fullData.length - 1;
421+
// 末尾是新增行,且在系统字段后面,且本身不是系统字段
422+
if (sysIndex !== -1 && lastIndex > sysIndex && !SYS_BUILT_IN_FIELDS.includes(fullData[lastIndex]?.dbFieldName)) {
423+
const newRowData = { ...fullData[lastIndex] };
424+
// 在 dbTable 中把末尾新行移到第一个系统字段前面
425+
await dbJVxeRef.rowResort(lastIndex, sysIndex);
426+
// 对其他 tables 直接在系统字段前面插入,不走 syncAllTableNow 的追加逻辑
427+
const { pageTable, checkTable, fkTable, queryTable } = tables;
428+
for (const t of [pageTable, checkTable, fkTable, queryTable]) {
429+
const jvxeRef = t.value?.tableRef;
430+
if (!jvxeRef) continue;
431+
const tFullData = jvxeRef.getXTable().internalData.tableFullData;
432+
const tSysIndex = tFullData.findIndex((row) => SYS_BUILT_IN_FIELDS.includes(row.dbFieldName));
433+
// 串行 await 附表 insertRows/addRows,确保下一次队列任务读到的是完全收尾后的状态
434+
if (tSysIndex !== -1) {
435+
await jvxeRef.insertRows(newRowData, tSysIndex);
436+
} else {
437+
await jvxeRef.addRows(newRowData);
438+
}
431439
}
440+
return;
432441
}
433-
return;
434442
}
435-
}
436-
// update-end--author:liaozhiyang---date:20260414---for:【QQYUN-15128】新增行时系统字段永远在最下面(系统字段被删除时退化为正常追加)
437-
syncAllTableNow();
443+
// update-end--author:liaozhiyang---date:20260414---for:【QQYUN-15128】新增行时系统字段永远在最下面(系统字段被删除时退化为正常追加)
444+
syncAllTableNow();
445+
});
446+
// 兜底:队列异常不阻塞后续调用
447+
onTableAddedQueue = onTableAddedQueue.catch((e) => {
448+
console.error('[onTableAdded] queue error:', e);
449+
});
450+
// update-end--author:liaozhiyang---date:20260506---for: 【issues/9593】树表的页面属性中子节点和父节点的属性串了
438451
}
439452
440453
/** 当删除的时候也应立即同步 */
@@ -504,8 +517,10 @@
504517
newData.id = uuidTemp;
505518
});
506519
dbTable.value!.tableRef!.addRows(treeFields, { setActive: false });
507-
pageTable.value!.tableRef!.addRows(treeFields, { setActive: false });
508-
checkTable.value!.tableRef!.addRows(treeFields, { setActive: false });
520+
// update-begin--author:liaozhiyang---date:20260506---for: 【issues/9593】树表的页面属性中子节点和父节点的属性串了
521+
// pageTable.value!.tableRef!.addRows(treeFields, { setActive: false });
522+
// checkTable.value!.tableRef!.addRows(treeFields, { setActive: false });
523+
// update-end--author:liaozhiyang---date:20260506---for: 【issues/9593】树表的页面属性中子节点和父节点的属性串了
509524
nextTick(() => syncAllTableNow());
510525
treeFieldAdded = true;
511526
}

0 commit comments

Comments
 (0)