fix: associationSelect

This commit is contained in:
katherinehhh 2023-05-11 16:01:11 +08:00
parent 9864292029
commit dba550803a
2 changed files with 7 additions and 5 deletions

View File

@ -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);

View File

@ -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);