diff --git a/packages/core/client/src/schema-component/antd/association-select/AssociationSelect.tsx b/packages/core/client/src/schema-component/antd/association-select/AssociationSelect.tsx index ba6614ea7..4e0fd63fb 100644 --- a/packages/core/client/src/schema-component/antd/association-select/AssociationSelect.tsx +++ b/packages/core/client/src/schema-component/antd/association-select/AssociationSelect.tsx @@ -15,6 +15,7 @@ import { } from '../../../collection-manager'; import { isTitleField } from '../../../collection-manager/Configuration/CollectionFields'; import { GeneralSchemaDesigner, SchemaSettings, isPatternDisabled, isShowDefaultValue } from '../../../schema-settings'; +import { useIsShowMultipleSwitch } from '../../../schema-settings/hooks/useIsShowMultipleSwitch'; import { useCompile, useDesignable, useFieldComponentOptions, useFieldTitle } from '../../hooks'; import { removeNullCondition } from '../filter'; import { RemoteSelect, RemoteSelectProps } from '../remote-select'; @@ -102,6 +103,8 @@ AssociationSelect.Designer = function Designer() { const tk = useFilterByTk(); const { dn, refresh, insertAdjacent } = useDesignable(); const compile = useCompile(); + const IsShowMultipleSwitch = useIsShowMultipleSwitch(); + const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']); const fieldComponentOptions = useFieldComponentOptions(); const isSubFormAssociationField = field.address.segments.includes('__form_grid'); @@ -495,36 +498,31 @@ AssociationSelect.Designer = function Designer() { }} /> )} - {form && - !form?.readPretty && - ['o2m', 'm2m'].includes(collectionField.interface) && - fieldSchema['x-component'] !== 'TableField' && ( - { - const schema = { - ['x-uid']: fieldSchema['x-uid'], - }; - fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {}; - field.componentProps = field.componentProps || {}; + {IsShowMultipleSwitch() ? ( + { + const schema = { + ['x-uid']: fieldSchema['x-uid'], + }; + fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {}; + field.componentProps = field.componentProps || {}; - fieldSchema['x-component-props'].multiple = value; - field.componentProps.multiple = value; + fieldSchema['x-component-props'].multiple = value; + field.componentProps.multiple = value; - schema['x-component-props'] = fieldSchema['x-component-props']; - dn.emit('patch', { - schema, - }); - refresh(); - }} - /> - )} + schema['x-component-props'] = fieldSchema['x-component-props']; + dn.emit('patch', { + schema, + }); + refresh(); + }} + /> + ) : null} { FormItem.Designer = function Designer() { const { getCollectionFields, getInterface, getCollectionJoinField, getCollection } = useCollectionManager(); const { getField } = useCollection(); - const tk = useFilterByTk(); const { form } = useFormBlockContext(); const field = useField(); const fieldSchema = useFieldSchema(); const { t } = useTranslation(); - const { dn, refresh, insertAdjacent } = useDesignable(); + const { dn, refresh } = useDesignable(); const compile = useCompile(); const variablesCtx = useVariablesCtx(); + const IsShowMultipleSwitch = useIsShowMultipleSwitch(); + const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']); const targetCollection = getCollection(collectionField?.target); const interfaceConfig = getInterface(collectionField?.interface); @@ -705,36 +707,31 @@ FormItem.Designer = function Designer() { }} /> )} - {form && - !form?.readPretty && - ['o2m', 'm2m'].includes(collectionField?.interface) && - fieldSchema['x-component'] !== 'TableField' && ( - { - const schema = { - ['x-uid']: fieldSchema['x-uid'], - }; - fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {}; - field.componentProps = field.componentProps || {}; + {IsShowMultipleSwitch() ? ( + { + const schema = { + ['x-uid']: fieldSchema['x-uid'], + }; + fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {}; + field.componentProps = field.componentProps || {}; - fieldSchema['x-component-props'].multiple = value; - field.componentProps.multiple = value; + fieldSchema['x-component-props'].multiple = value; + field.componentProps.multiple = value; - schema['x-component-props'] = fieldSchema['x-component-props']; - dn.emit('patch', { - schema, - }); - refresh(); - }} - /> - )} + schema['x-component-props'] = fieldSchema['x-component-props']; + dn.emit('patch', { + schema, + }); + refresh(); + }} + /> + ) : null} {field.readPretty && options.length > 0 && fieldSchema['x-component'] === 'CollectionField' && !isFileField && (