diff --git a/packages/core/client/src/modules/blocks/data-blocks/table/hooks/useTableBlockProps.tsx b/packages/core/client/src/modules/blocks/data-blocks/table/hooks/useTableBlockProps.tsx index e07bb03f87..d9ab3f9fc7 100644 --- a/packages/core/client/src/modules/blocks/data-blocks/table/hooks/useTableBlockProps.tsx +++ b/packages/core/client/src/modules/blocks/data-blocks/table/hooks/useTableBlockProps.tsx @@ -113,12 +113,8 @@ export const useTableBlockProps = () => { dataBlocks.forEach((block) => { const target = targets.find((target) => target.uid === block.uid); if (!target) return; - - const isForeignKey = block.foreignKeyFields?.some((field) => field.name === target.field); - const sourceKey = getSourceKey(currentBlock, target.field); - const recordKey = isForeignKey ? sourceKey : ctx.rowKey; - const value = [record[recordKey]]; - + const sourceKey = getSourceKey(currentBlock, target.field) || ctx.rowKey || 'id'; + const value = [record[sourceKey]]; const param = block.service.params?.[0] || {}; // 保留原有的 filter const storedFilter = block.service.params?.[1]?.filters || {}; @@ -168,5 +164,5 @@ export const useTableBlockProps = () => { function getSourceKey(currentBlock: DataBlock, field: string) { const associationField = currentBlock?.associatedFields?.find((item) => item.foreignKey === field); - return associationField?.sourceKey || 'id'; + return associationField?.sourceKey || field?.split?.('.')?.[1]; }