diff --git a/packages/core/client/src/schema-component/antd/association-field/InternalPicker.tsx b/packages/core/client/src/schema-component/antd/association-field/InternalPicker.tsx index d02c99a070..7afc0e0444 100644 --- a/packages/core/client/src/schema-component/antd/association-field/InternalPicker.tsx +++ b/packages/core/client/src/schema-component/antd/association-field/InternalPicker.tsx @@ -14,7 +14,7 @@ import { TableSelectorParamsProvider, useTableSelectorProps as useTsp, } from '../../../block-provider/TableSelectorProvider'; -import { CollectionProvider, useCollection } from '../../../collection-manager'; +import { CollectionProvider, useCollection, useCollectionManager } from '../../../collection-manager'; import { useCompile } from '../../hooks'; import { ActionContext } from '../action'; import { useFieldNames, useInsertSchema } from './hooks'; @@ -71,7 +71,8 @@ export const InternalPicker = observer((props: any) => { const insertSelector = useInsertSchema('Selector'); const { getField } = useCollection(); const { t } = useTranslation(); - const collectionField = getField(field.props.name); + const { getCollectionJoinField } = useCollectionManager(); + const collectionField = getField(field.props.name) || getCollectionJoinField(fieldSchema?.['x-collection-field']); const addbuttonClick = () => { insertAddNewer(schema.AddNewer); setVisibleAddNewer(true); diff --git a/packages/core/client/src/schema-component/antd/association-field/hooks.ts b/packages/core/client/src/schema-component/antd/association-field/hooks.ts index 8227052909..42bf840ddb 100644 --- a/packages/core/client/src/schema-component/antd/association-field/hooks.ts +++ b/packages/core/client/src/schema-component/antd/association-field/hooks.ts @@ -37,8 +37,8 @@ export default function useServiceOptions(props) { const { action = 'list', service, fieldNames } = props; const params = service?.params || {}; const fieldSchema = useFieldSchema(); - const { getField, fields } = useCollection(); - const { getCollectionFields } = useCollectionManager(); + const { getField } = useCollection(); + const { getCollectionFields, getCollectionJoinField } = useCollectionManager(); const record = useRecord(); const normalizeValues = useCallback( @@ -63,8 +63,9 @@ export default function useServiceOptions(props) { }, [props.value, normalizeValues]); const collectionField = useMemo(() => { - return getField(fieldSchema.name); + return getField(fieldSchema.name) || getCollectionJoinField(fieldSchema?.['x-collection-field']); }, [fieldSchema.name]); + const sourceValue = record?.[collectionField?.sourceKey]; const filter = useMemo(() => { const isOToAny = ['oho', 'o2m'].includes(collectionField?.interface);