|
404 | 404 | const SYS_BUILT_IN_FIELDS = ['create_by', 'create_time', 'update_by', 'update_time', 'sys_org_code']; |
405 | 405 | // update-end--author:liaozhiyang---date:20260414---for:【QQYUN-15128】新增字段时系统字段永远在最下面 |
406 | 406 |
|
| 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 | +
|
407 | 411 | /** 当新增了的时候应立即同步 */ |
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 | + } |
431 | 439 | } |
| 440 | + return; |
432 | 441 | } |
433 | | - return; |
434 | 442 | } |
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】树表的页面属性中子节点和父节点的属性串了 |
438 | 451 | } |
439 | 452 |
|
440 | 453 | /** 当删除的时候也应立即同步 */ |
|
504 | 517 | newData.id = uuidTemp; |
505 | 518 | }); |
506 | 519 | 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】树表的页面属性中子节点和父节点的属性串了 |
509 | 524 | nextTick(() => syncAllTableNow()); |
510 | 525 | treeFieldAdded = true; |
511 | 526 | } |
|
0 commit comments