fix: incorrect parameters passed in table block filtering (#5773)

This commit is contained in:
Katherine 2024-12-03 19:32:07 +08:00 committed by GitHub
parent 38e79d41af
commit fa315a1261
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -110,12 +110,8 @@ export const useTableBlockProps = () => {
dataBlocks.forEach((block) => { dataBlocks.forEach((block) => {
const target = targets.find((target) => target.uid === block.uid); const target = targets.find((target) => target.uid === block.uid);
if (!target) return; if (!target) return;
const sourceKey = getSourceKey(currentBlock, target.field) || ctx.rowKey || 'id';
const isForeignKey = block.foreignKeyFields?.some((field) => field.name === target.field); const value = [record[sourceKey]];
const sourceKey = getSourceKey(currentBlock, target.field);
const recordKey = isForeignKey ? sourceKey : ctx.rowKey;
const value = [record[recordKey]];
const param = block.service.params?.[0] || {}; const param = block.service.params?.[0] || {};
// 保留原有的 filter // 保留原有的 filter
const storedFilter = block.service.params?.[1]?.filters || {}; const storedFilter = block.service.params?.[1]?.filters || {};
@ -165,5 +161,5 @@ export const useTableBlockProps = () => {
function getSourceKey(currentBlock: DataBlock, field: string) { function getSourceKey(currentBlock: DataBlock, field: string) {
const associationField = currentBlock?.associatedFields?.find((item) => item.foreignKey === field); const associationField = currentBlock?.associatedFields?.find((item) => item.foreignKey === field);
return associationField?.sourceKey || 'id'; return associationField?.sourceKey || field?.split?.('.')?.[1];
} }