From 62ee8730b0a1f914c1e4bb48dfe4b066a91263e8 Mon Sep 17 00:00:00 2001 From: wjh Date: Tue, 2 Jul 2024 12:11:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=AD=9B=E9=80=89=E5=8C=BA=E5=9D=97?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=85=B3=E8=81=94=E9=A1=B9=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20(#1255)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachybase/pulls/1255 Co-authored-by: wjh Co-committed-by: wjh --- .../client/src/schema-initializer/utils.ts | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/packages/core/client/src/schema-initializer/utils.ts b/packages/core/client/src/schema-initializer/utils.ts index 13b40d428..d7263bb62 100644 --- a/packages/core/client/src/schema-initializer/utils.ts +++ b/packages/core/client/src/schema-initializer/utils.ts @@ -487,24 +487,32 @@ const getItem = ( if (processedCollections.includes(field.target)) return null; 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 { type: 'subMenu', name: field.uiSchema?.title, title: field.uiSchema?.title, - children: subFields - .map((subField) => - getItem(subField, `${schemaName}.${subField.name}`, collectionName, getCollectionFields, [ - ...processedCollections, - field.target, - ]), - ) - .filter(Boolean), + children: options.filter(Boolean), } as SchemaInitializerItemType; } if (isAssocField(field)) return null; + return getResultSchema(schemaName, field, collectionName); +}; + +const getResultSchema = (schemaName, field, collectionName) => { const schema = { type: 'string', name: schemaName, @@ -520,8 +528,7 @@ const getItem = ( 'x-decorator': 'FormItem', 'x-collection-field': `${collectionName}.${schemaName}`, }; - - return { + const result = { name: field.uiSchema?.title || field.name, type: 'item', title: field.uiSchema?.title || field.name, @@ -529,6 +536,7 @@ const getItem = ( remove: removeGridFormItem, schema, } as SchemaInitializerItemType; + return result; }; // 筛选表单相关