fix: linkage conflict between same-named association fields in different sub-tables within the same form (#6577)

* fix: linkage conflict between same-named association fields in different sub-tables within same form

* fix: bug
This commit is contained in:
Katherine 2025-03-27 23:00:04 +08:00 committed by GitHub
parent 63caa541cb
commit eba3f79134
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -69,6 +69,11 @@ export const filterAnalyses = (filters): any[] => {
return results;
};
function getFieldPath(str) {
const lastIndex = str.lastIndexOf('.');
return lastIndex === -1 ? str : str.slice(0, lastIndex);
}
const InternalAssociationSelect = observer(
(props: AssociationSelectProps) => {
const { objectValue = true, addMode: propsAddMode, ...rest } = props;
@ -100,11 +105,14 @@ const InternalAssociationSelect = observer(
//支持深层次子表单
onFieldInputValueChange('*', (fieldPath: any) => {
const linkageFields = filterAnalyses(field.componentProps?.service?.params?.filter) || [];
const linageFieldEntire = getFieldPath(fieldPath.address.entire);
const targetFieldEntire = getFieldPath(field.address.entire);
if (
linkageFields.includes(fieldPath?.props?.name) &&
field.value &&
isEqual(fieldPath?.indexes, field?.indexes) &&
fieldPath?.props?.name !== field.props.name
fieldPath?.props?.name !== field.props.name &&
(!field?.indexes?.length || isEqual(linageFieldEntire, targetFieldEntire))
) {
field.setValue(null);
setInnerValue(null);