diff --git a/packages/core/client/src/schema-component/antd/association-field/FileManager.tsx b/packages/core/client/src/schema-component/antd/association-field/FileManager.tsx index d7a935b55..04d49e232 100644 --- a/packages/core/client/src/schema-component/antd/association-field/FileManager.tsx +++ b/packages/core/client/src/schema-component/antd/association-field/FileManager.tsx @@ -15,12 +15,12 @@ import { import { CollectionProvider, useCollection, useCollectionManager } from '../../../collection-manager'; import { useCompile } from '../../hooks'; import { ActionContextProvider } from '../action'; +import { EllipsisWithTooltip } from '../input'; import { FileSelector, Preview } from '../preview'; import { ReadPrettyInternalViewer } from './InternalViewer'; import { useFieldNames, useInsertSchema } from './hooks'; import schema from './schema'; import { flatData, getLabelFormatValue, isShowFilePicker, useLabelUiSchema } from './util'; -import { EllipsisWithTooltip } from '../input'; const useTableSelectorProps = () => { const field: any = useField(); @@ -88,7 +88,7 @@ const InternalFileManager = (props) => { useEffect(() => { if (value && Object.keys(value).length > 0) { - const opts = (Array.isArray(value) ? value : value ? [value] : []).map((option) => { + const opts = (Array.isArray(value) ? value : value ? [value] : []).filter(Boolean).map((option) => { const label = option[fieldNames.label]; return { ...option, diff --git a/packages/core/client/src/schema-component/antd/form-item/hooks/useLazyLoadAssociationFieldOfForm.ts b/packages/core/client/src/schema-component/antd/form-item/hooks/useLazyLoadAssociationFieldOfForm.ts index a607889ed..64239d9c4 100644 --- a/packages/core/client/src/schema-component/antd/form-item/hooks/useLazyLoadAssociationFieldOfForm.ts +++ b/packages/core/client/src/schema-component/antd/form-item/hooks/useLazyLoadAssociationFieldOfForm.ts @@ -21,13 +21,21 @@ const useLazyLoadAssociationFieldOfForm = () => { const fieldSchema = useFieldSchema(); const variables = useVariables(); const field = useField(); - const { isInAssignFieldValues } = useFlag() || {}; + const { isInAssignFieldValues, isInSubForm, isInSubTable } = useFlag() || {}; const { type: formBlockType } = useFormBlockType(); const schemaName = fieldSchema.name.toString(); useEffect(() => { - if (isInAssignFieldValues || formBlockType === 'create') { + const cloneRecord = { ...record }; + delete cloneRecord['__parent']; + delete cloneRecord['__collectionName']; + + if ( + isInAssignFieldValues || + _.isEmpty(cloneRecord) || + (formBlockType === 'create' && !isInSubForm && !isInSubTable) + ) { return; } @@ -37,11 +45,7 @@ const useLazyLoadAssociationFieldOfForm = () => { return; } - const cloneRecord = { ...record }; - delete cloneRecord['__parent']; - delete cloneRecord['__collectionName']; - - if (_.isEmpty(cloneRecord) || !variables || record[schemaName] != null) { + if (!variables || record[schemaName] != null) { return; } @@ -70,7 +74,7 @@ const useLazyLoadAssociationFieldOfForm = () => { .catch((err) => { console.error(err); }); - }, []); + }, [record]); }; export default useLazyLoadAssociationFieldOfForm; diff --git a/packages/core/client/src/variables/VariablesProvider.tsx b/packages/core/client/src/variables/VariablesProvider.tsx index 0dda9362a..3b443b667 100644 --- a/packages/core/client/src/variables/VariablesProvider.tsx +++ b/packages/core/client/src/variables/VariablesProvider.tsx @@ -288,8 +288,8 @@ export default VariablesProvider; */ function shouldToRequest(value) { // fix https://nocobase.height.app/T-2502 - // 兼容对多子表单子表格字段的情况 - if (JSON.stringify(value) === '[{}]') { + // 兼容 `对多` 和 `对一` 子表单子表格字段的情况 + if (JSON.stringify(value) === '[{}]' || JSON.stringify(value) === '{}') { return true; }