fix: 筛选区块支持关联项直接添加 (#1255)
Reviewed-on: daoyoucloud/tachybase#1255 Co-authored-by: wjh <wwwjh0710@163.com> Co-committed-by: wjh <wwwjh0710@163.com>
This commit is contained in:
parent
163d45e1b8
commit
62ee8730b0
@ -487,24 +487,32 @@ const getItem = (
|
|||||||
if (processedCollections.includes(field.target)) return null;
|
if (processedCollections.includes(field.target)) return null;
|
||||||
|
|
||||||
const subFields = getCollectionFields(field.target);
|
const subFields = getCollectionFields(field.target);
|
||||||
|
const options = [];
|
||||||
|
subFields.forEach((subField) => {
|
||||||
|
if (['m2o', 'obo'].includes(subField.interface)) {
|
||||||
|
options.push(getResultSchema(`${schemaName}.${subField.name}`, subField, collectionName));
|
||||||
|
}
|
||||||
|
options.push(
|
||||||
|
getItem(subField, `${schemaName}.${subField.name}`, collectionName, getCollectionFields, [
|
||||||
|
...processedCollections,
|
||||||
|
field.target,
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
});
|
||||||
return {
|
return {
|
||||||
type: 'subMenu',
|
type: 'subMenu',
|
||||||
name: field.uiSchema?.title,
|
name: field.uiSchema?.title,
|
||||||
title: field.uiSchema?.title,
|
title: field.uiSchema?.title,
|
||||||
children: subFields
|
children: options.filter(Boolean),
|
||||||
.map((subField) =>
|
|
||||||
getItem(subField, `${schemaName}.${subField.name}`, collectionName, getCollectionFields, [
|
|
||||||
...processedCollections,
|
|
||||||
field.target,
|
|
||||||
]),
|
|
||||||
)
|
|
||||||
.filter(Boolean),
|
|
||||||
} as SchemaInitializerItemType;
|
} as SchemaInitializerItemType;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAssocField(field)) return null;
|
if (isAssocField(field)) return null;
|
||||||
|
|
||||||
|
return getResultSchema(schemaName, field, collectionName);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getResultSchema = (schemaName, field, collectionName) => {
|
||||||
const schema = {
|
const schema = {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
name: schemaName,
|
name: schemaName,
|
||||||
@ -520,8 +528,7 @@ const getItem = (
|
|||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
'x-collection-field': `${collectionName}.${schemaName}`,
|
'x-collection-field': `${collectionName}.${schemaName}`,
|
||||||
};
|
};
|
||||||
|
const result = {
|
||||||
return {
|
|
||||||
name: field.uiSchema?.title || field.name,
|
name: field.uiSchema?.title || field.name,
|
||||||
type: 'item',
|
type: 'item',
|
||||||
title: field.uiSchema?.title || field.name,
|
title: field.uiSchema?.title || field.name,
|
||||||
@ -529,6 +536,7 @@ const getItem = (
|
|||||||
remove: removeGridFormItem,
|
remove: removeGridFormItem,
|
||||||
schema,
|
schema,
|
||||||
} as SchemaInitializerItemType;
|
} as SchemaInitializerItemType;
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 筛选表单相关
|
// 筛选表单相关
|
||||||
|
Loading…
Reference in New Issue
Block a user