From 38f8cf9d565385be8a9f87b661e8563f211aa3e2 Mon Sep 17 00:00:00 2001 From: Katherine Date: Thu, 17 Apr 2025 10:32:41 +0800 Subject: [PATCH] fix: linkage rules compatibility with legacy data (#6686) * fix: linkage rules compatibility with legacy data * fix: bug --- .../core/client/src/schema-settings/LinkageRules/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/core/client/src/schema-settings/LinkageRules/index.tsx b/packages/core/client/src/schema-settings/LinkageRules/index.tsx index 03acb9eca3..5fbc3b7bf4 100644 --- a/packages/core/client/src/schema-settings/LinkageRules/index.tsx +++ b/packages/core/client/src/schema-settings/LinkageRules/index.tsx @@ -20,6 +20,7 @@ import { SubFormProvider } from '../../schema-component/antd/association-field/h import { DynamicComponentProps } from '../../schema-component/antd/filter/DynamicComponent'; import { FilterContext } from '../../schema-component/antd/filter/context'; import { VariableInput, getShouldChange } from '../VariableInput/VariableInput'; +import { useCurrentFormContext } from '../VariableInput/hooks/useFormVariable'; import { LinkageRuleActionGroup } from './LinkageRuleActionGroup'; import { EnableLinkage } from './components/EnableLinkage'; import { ArrayCollapse } from './components/LinkageHeader'; @@ -95,6 +96,7 @@ export const FormLinkageRules = withDynamicSchemaProps( const { name } = useCollection_deprecated(); const { getAllCollectionsInheritChain } = useCollectionManager_deprecated(); const parentRecordData = useCollectionParentRecordData(); + const { shouldDisplayCurrentForm } = useCurrentFormContext(); const variableKey = getActiveContextName(localVariables); const components = useMemo(() => ({ ArrayCollapse }), []); const schema = useMemo( @@ -103,7 +105,7 @@ export const FormLinkageRules = withDynamicSchemaProps( properties: { rules: { type: 'array', - default: transformDefaultValue(defaultValues, variableKey), + default: transformDefaultValue(defaultValues, shouldDisplayCurrentForm ? variableKey : '$nRecord'), 'x-component': 'ArrayCollapse', 'x-decorator': 'FormItem', 'x-component-props': {