fix: asociationSelect support multiple

This commit is contained in:
katherinehhh 2023-05-09 15:29:19 +08:00
parent d7be145fd5
commit 6dafc85242
3 changed files with 7 additions and 5 deletions

View File

@ -1,9 +1,9 @@
import { LoadingOutlined } from '@ant-design/icons';
import { connect, mapProps, RecursionField, useFieldSchema, useField, observer } from '@formily/react';
import { connect, mapProps, RecursionField, useFieldSchema, useField } from '@formily/react';
import { Button, Input } from 'antd';
import _ from 'lodash';
import { ActionContext } from '../action';
import React, { memo, useCallback, useMemo, useState } from 'react';
import React, { memo, useCallback, useMemo, useState, useEffect } from 'react';
import { useFieldTitle } from '../../hooks';
import { RemoteSelect, RemoteSelectProps } from '../remote-select';
import { useInsertSchema } from './hooks';
@ -50,7 +50,9 @@ const InternalAssociationSelect = memo((props: AssociationSelectProps) => {
return normalizeValues(props.value);
}
}, [props.value, normalizeValues]);
field.value = value;
useEffect(() => {
field.value = value;
}, []);
return (
<div key={fieldSchema.name}>
<Input.Group compact style={{ display: 'flex' }}>

View File

@ -82,7 +82,7 @@ export const InternalPicker = observer((props: any) => {
const pickerProps = {
size: 'small',
fieldNames,
multiple: ['o2m', 'm2m'].includes(collectionField?.interface),
multiple: multiple !== false && ['o2m', 'm2m'].includes(collectionField?.interface),
association: {
target: collectionField?.target,
},

View File

@ -75,7 +75,7 @@ export const InternalSubTable: any = observer((props: any) => {
const [tableData, setTableData] = useState(field.value);
const pickerProps = {
size: 'small',
multiple: ['o2m', 'm2m'].includes(collectionField?.interface),
multiple: props.multiple !== false && ['o2m', 'm2m'].includes(collectionField?.interface),
association: {
target: collectionField?.target,
},