mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2026-05-28 11:23:52 +00:00
【issues/9593】树表的页面属性中子节点和父节点的属性串了
This commit is contained in:
parent
6f00250239
commit
2bf074cdd1
@ -404,37 +404,50 @@
|
|||||||
const SYS_BUILT_IN_FIELDS = ['create_by', 'create_time', 'update_by', 'update_time', 'sys_org_code'];
|
const SYS_BUILT_IN_FIELDS = ['create_by', 'create_time', 'update_by', 'update_time', 'sys_org_code'];
|
||||||
// update-end--author:liaozhiyang---date:20260414---for:【QQYUN-15128】新增字段时系统字段永远在最下面
|
// update-end--author:liaozhiyang---date:20260414---for:【QQYUN-15128】新增字段时系统字段永远在最下面
|
||||||
|
|
||||||
|
// update-begin--author:liaozhiyang---date:20260506---for:【issues/9593】树表的页面属性中子节点和父节点的属性串了
|
||||||
|
let onTableAddedQueue: Promise<unknown> = Promise.resolve();
|
||||||
|
// update-end--author:liaozhiyang---date:20260506---for:【issues/9593】树表的页面属性中子节点和父节点的属性串了
|
||||||
|
|
||||||
/** 当新增了的时候应立即同步 */
|
/** 当新增了的时候应立即同步 */
|
||||||
async function onTableAdded() {
|
function onTableAdded() {
|
||||||
// update-begin--author:liaozhiyang---date:20260414---for:【QQYUN-15128】新增行时系统字段永远在最下面(系统字段被删除时退化为正常追加)
|
// update-begin--author:liaozhiyang---date:20260506---for: 【issues/9593】树表的页面属性中子节点和父节点的属性串了
|
||||||
const dbJVxeRef = tables.dbTable.value?.tableRef;
|
onTableAddedQueue = onTableAddedQueue.then(async () => {
|
||||||
if (dbJVxeRef) {
|
// update-begin--author:liaozhiyang---date:20260414---for:【QQYUN-15128】新增行时系统字段永远在最下面(系统字段被删除时退化为正常追加)
|
||||||
const fullData = dbJVxeRef.getXTable().internalData.tableFullData;
|
const dbJVxeRef = tables.dbTable.value?.tableRef;
|
||||||
const sysIndex = fullData.findIndex((row) => SYS_BUILT_IN_FIELDS.includes(row.dbFieldName));
|
if (dbJVxeRef) {
|
||||||
const lastIndex = fullData.length - 1;
|
const fullData = dbJVxeRef.getXTable().internalData.tableFullData;
|
||||||
// 末尾是新增行,且在系统字段后面,且本身不是系统字段
|
const sysIndex = fullData.findIndex((row) => SYS_BUILT_IN_FIELDS.includes(row.dbFieldName));
|
||||||
if (sysIndex !== -1 && lastIndex > sysIndex && !SYS_BUILT_IN_FIELDS.includes(fullData[lastIndex]?.dbFieldName)) {
|
const lastIndex = fullData.length - 1;
|
||||||
const newRowData = { ...fullData[lastIndex] };
|
// 末尾是新增行,且在系统字段后面,且本身不是系统字段
|
||||||
// 在 dbTable 中把末尾新行移到第一个系统字段前面
|
if (sysIndex !== -1 && lastIndex > sysIndex && !SYS_BUILT_IN_FIELDS.includes(fullData[lastIndex]?.dbFieldName)) {
|
||||||
await dbJVxeRef.rowResort(lastIndex, sysIndex);
|
const newRowData = { ...fullData[lastIndex] };
|
||||||
// 对其他 tables 直接在系统字段前面插入,不走 syncAllTableNow 的追加逻辑
|
// 在 dbTable 中把末尾新行移到第一个系统字段前面
|
||||||
const { pageTable, checkTable, fkTable, queryTable } = tables;
|
await dbJVxeRef.rowResort(lastIndex, sysIndex);
|
||||||
for (const t of [pageTable, checkTable, fkTable, queryTable]) {
|
// 对其他 tables 直接在系统字段前面插入,不走 syncAllTableNow 的追加逻辑
|
||||||
const jvxeRef = t.value?.tableRef;
|
const { pageTable, checkTable, fkTable, queryTable } = tables;
|
||||||
if (!jvxeRef) continue;
|
for (const t of [pageTable, checkTable, fkTable, queryTable]) {
|
||||||
const tFullData = jvxeRef.getXTable().internalData.tableFullData;
|
const jvxeRef = t.value?.tableRef;
|
||||||
const tSysIndex = tFullData.findIndex((row) => SYS_BUILT_IN_FIELDS.includes(row.dbFieldName));
|
if (!jvxeRef) continue;
|
||||||
if (tSysIndex !== -1) {
|
const tFullData = jvxeRef.getXTable().internalData.tableFullData;
|
||||||
jvxeRef.insertRows(newRowData, tSysIndex);
|
const tSysIndex = tFullData.findIndex((row) => SYS_BUILT_IN_FIELDS.includes(row.dbFieldName));
|
||||||
} else {
|
// 串行 await 附表 insertRows/addRows,确保下一次队列任务读到的是完全收尾后的状态
|
||||||
jvxeRef.addRows(newRowData);
|
if (tSysIndex !== -1) {
|
||||||
|
await jvxeRef.insertRows(newRowData, tSysIndex);
|
||||||
|
} else {
|
||||||
|
await jvxeRef.addRows(newRowData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
// update-end--author:liaozhiyang---date:20260414---for:【QQYUN-15128】新增行时系统字段永远在最下面(系统字段被删除时退化为正常追加)
|
||||||
// update-end--author:liaozhiyang---date:20260414---for:【QQYUN-15128】新增行时系统字段永远在最下面(系统字段被删除时退化为正常追加)
|
syncAllTableNow();
|
||||||
syncAllTableNow();
|
});
|
||||||
|
// 兜底:队列异常不阻塞后续调用
|
||||||
|
onTableAddedQueue = onTableAddedQueue.catch((e) => {
|
||||||
|
console.error('[onTableAdded] queue error:', e);
|
||||||
|
});
|
||||||
|
// update-end--author:liaozhiyang---date:20260506---for: 【issues/9593】树表的页面属性中子节点和父节点的属性串了
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 当删除的时候也应立即同步 */
|
/** 当删除的时候也应立即同步 */
|
||||||
@ -504,8 +517,10 @@
|
|||||||
newData.id = uuidTemp;
|
newData.id = uuidTemp;
|
||||||
});
|
});
|
||||||
dbTable.value!.tableRef!.addRows(treeFields, { setActive: false });
|
dbTable.value!.tableRef!.addRows(treeFields, { setActive: false });
|
||||||
pageTable.value!.tableRef!.addRows(treeFields, { setActive: false });
|
// update-begin--author:liaozhiyang---date:20260506---for: 【issues/9593】树表的页面属性中子节点和父节点的属性串了
|
||||||
checkTable.value!.tableRef!.addRows(treeFields, { setActive: false });
|
// pageTable.value!.tableRef!.addRows(treeFields, { setActive: false });
|
||||||
|
// checkTable.value!.tableRef!.addRows(treeFields, { setActive: false });
|
||||||
|
// update-end--author:liaozhiyang---date:20260506---for: 【issues/9593】树表的页面属性中子节点和父节点的属性串了
|
||||||
nextTick(() => syncAllTableNow());
|
nextTick(() => syncAllTableNow());
|
||||||
treeFieldAdded = true;
|
treeFieldAdded = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user