diff --git a/packages/core/client/src/block-provider/BlockProvider.tsx b/packages/core/client/src/block-provider/BlockProvider.tsx index f1ed19a2e..95a8b2193 100644 --- a/packages/core/client/src/block-provider/BlockProvider.tsx +++ b/packages/core/client/src/block-provider/BlockProvider.tsx @@ -301,14 +301,18 @@ export const BlockProvider = (props: { }) => { const { collection, association, name } = props; const resource = useResource(props); - const params = useMemo(() => ({ ...props.params }), [props.params]); const { appends, updateAssociationValues } = useAssociationNames(); + const params = useMemo(() => { + if (!props.params) { + return props.params; + } + if (!props.params['appends']) { + return { ...props.params, appends }; + } + return { ...props.params }; + }, [appends, props.params]); const blockValue = useMemo(() => ({ name }), [name]); - if (!Object.keys(params).includes('appends')) { - params['appends'] = appends; - } - return ( diff --git a/packages/core/client/src/block-provider/hooks/index.ts b/packages/core/client/src/block-provider/hooks/index.ts index 3ef2ec37c..eda790bf0 100644 --- a/packages/core/client/src/block-provider/hooks/index.ts +++ b/packages/core/client/src/block-provider/hooks/index.ts @@ -1278,10 +1278,10 @@ export const useAssociationNames = () => { const getAssociationAppends = (schema, str) => { schema.reduceProperties((pre, s) => { const prefix = pre || str; - const collectionfield = s['x-collection-field'] && getCollectionJoinField(s['x-collection-field']); + const collectionField = s['x-collection-field'] && getCollectionJoinField(s['x-collection-field']); const isAssociationSubfield = s.name.includes('.'); const isAssociationField = - collectionfield && ['hasOne', 'hasMany', 'belongsTo', 'belongsToMany'].includes(collectionfield.type); + collectionField && ['hasOne', 'hasMany', 'belongsTo', 'belongsToMany'].includes(collectionField.type); // 根据联动规则中条件的字段获取一些 appends if (s['x-linkage-rules']) { @@ -1301,8 +1301,8 @@ export const useAssociationNames = () => { }); } - const isTreeCollection = isAssociationField && getCollection(collectionfield.target)?.template === 'tree'; - if (collectionfield && (isAssociationField || isAssociationSubfield) && s['x-component'] !== 'TableField') { + const isTreeCollection = isAssociationField && getCollection(collectionField.target)?.template === 'tree'; + if (collectionField && (isAssociationField || isAssociationSubfield) && s['x-component'] !== 'TableField') { const fieldPath = !isAssociationField && isAssociationSubfield ? getAssociationPath(s.name) : s.name; const path = prefix === '' || !prefix ? fieldPath : prefix + '.' + fieldPath; if (isTreeCollection) { diff --git a/packages/core/client/src/variables/VariablesProvider.tsx b/packages/core/client/src/variables/VariablesProvider.tsx index 3b7d51d25..0dda9362a 100644 --- a/packages/core/client/src/variables/VariablesProvider.tsx +++ b/packages/core/client/src/variables/VariablesProvider.tsx @@ -287,5 +287,11 @@ export default VariablesProvider; * @returns */ function shouldToRequest(value) { + // fix https://nocobase.height.app/T-2502 + // 兼容对多子表单子表格字段的情况 + if (JSON.stringify(value) === '[{}]') { + return true; + } + return value === undefined; }