fix: linkage rules compatibility with legacy data (#6686)

* fix: linkage rules compatibility with legacy data

* fix: bug
This commit is contained in:
Katherine 2025-04-17 10:32:41 +08:00 committed by GitHub
parent 78fefe197b
commit 38f8cf9d56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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': {