fix: useSyncFromForm support multi-level relationships (#2413)

This commit is contained in:
katherinehhh 2023-08-08 15:37:10 +08:00 committed by GitHub
parent 3c161eab86
commit 823d4bd94d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -260,13 +260,13 @@ function loadChildren({ node, traverseAssociations, traverseFields, systemKeys,
const activeNode = findNode(fields.dataSource || fields.componentProps.treeData, node);
let children = [];
// 多对多和多对一只展示关系字段
if (['belongsTo', 'belongsToMany'].includes(node.field.type)) {
if (['belongsTo', 'belongsToMany'].includes(node.field.type) && node?.type === 'reference') {
children = traverseAssociations(node.field.target, {
exclude: systemKeys,
prefix: node.key,
maxDepth: 1,
});
} else if (['hasOne', 'hasMany'].includes(node.field.type)) {
} else if (['hasOne', 'hasMany'].includes(node.field.type) || node?.type === 'duplicate') {
children = traverseFields(node.field.target, {
exclude: ['id', ...systemKeys],
prefix: node.key,

View File

@ -53,7 +53,7 @@ export const useSyncFromForm = (fieldSchema, collection?, callBack?) => {
field,
disabled,
};
const tatgetFormField = formData.find((v) => v.name === field.name);
const tatgetFormField = formData.find((v) => v.name === option.key);
if (
['belongsTo', 'belongsToMany'].includes(field.type) &&
(!tatgetFormField || ['Select', 'Picker'].includes(tatgetFormField?.fieldMode))