diff --git a/packages/core/client/src/schema-component/antd/association-field/Nester.tsx b/packages/core/client/src/schema-component/antd/association-field/Nester.tsx index 1b782371b..f2b81a8f5 100644 --- a/packages/core/client/src/schema-component/antd/association-field/Nester.tsx +++ b/packages/core/client/src/schema-component/antd/association-field/Nester.tsx @@ -4,7 +4,7 @@ import { ArrayField } from '@formily/core'; import { spliceArrayState } from '@formily/core/esm/shared/internals'; import { RecursionField, observer, useFieldSchema } from '@formily/react'; import { action } from '@formily/reactive'; -import { Card, Divider, Tooltip } from 'antd'; +import { Button, Card, Divider, Tooltip } from 'antd'; import React, { useContext } from 'react'; import { useTranslation } from 'react-i18next'; import { AssociationFieldContext } from './context'; @@ -29,7 +29,7 @@ const ToManyNester = observer((props) => { const fieldSchema = useFieldSchema(); const { options, field, allowMultiple, allowDissociate } = useAssociationFieldContext(); const { t } = useTranslation(); - return ( + return (field.value || []).length > 0 ? ( { } return ( <> - {!field.readPretty && allowed && ( -
- {[ - field.editable && allowMultiple && ( - - { - action(() => { - if (!Array.isArray(field.value)) { - field.value = []; - } - spliceArrayState(field as any, { - startIndex: index + 1, - insertCount: 1, - }); - field.value.splice(index + 1, 0, null); - return field.onInput(field.value); - }); - }} - /> - - ), - - { - action(() => { - spliceArrayState(field as any, { - startIndex: index, - deleteCount: 1, - }); - field.value.splice(index, 1); - return field.onInput(field.value); +
+ {field.editable && allowMultiple && ( + + { + action(() => { + if (!Array.isArray(field.value)) { + field.value = []; + } + spliceArrayState(field as any, { + startIndex: index + 1, + insertCount: 1, }); - }} - /> - , - ]} -
- )} + field.value.splice(index + 1, 0, null); + return field.onInput(field.value); + }); + }} + /> +
+ )} + {!field.readPretty && allowed && ( + + { + action(() => { + spliceArrayState(field as any, { + startIndex: index, + deleteCount: 1, + }); + field.value.splice(index, 1); + return field.onInput(field.value); + }); + }} + /> + + )} +
); })} - {/* {field.editable && allowMultiple && ( - - )} */}
+ ) : ( + <> + {field.editable && allowMultiple && ( + + + + )} + ); });