From 24f2429066e11fdf1c2d67a3478c7b499bc9203c Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Fri, 30 Jun 2023 17:47:32 +0800 Subject: [PATCH] refactor: optimization of tree table stuck performance (#2154) * fix: the first selection of the form template shows incomplete data * fix: the first selection of the form template shows incomplete data * fix: the first selection of the form template shows incomplete data * fix: the first selection of the form template shows incomplete data * refactor: optimization of Tree Table performance * refactor: code improve --- .../antd/action/Action.Designer.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx b/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx index 39dbd0d13a..7a6f5d0bf7 100644 --- a/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx +++ b/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx @@ -5,7 +5,7 @@ import { cloneDeep } from 'lodash'; import React, { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useDesignable } from '../..'; -import { useCollection, useCollectionFieldsOptions, useCollectionManager } from '../../../collection-manager'; +import { useCollection, useCollectionManager } from '../../../collection-manager'; import { OpenModeSchemaItems } from '../../../schema-items'; import { GeneralSchemaDesigner, SchemaSettings } from '../../../schema-settings'; import { useCollectionState } from '../../../schema-settings/DataTemplates/hooks/useCollectionState'; @@ -15,7 +15,6 @@ import { requestSettingsSchema } from './utils'; const Tree = connect( AntdTree, mapProps((props, field: any) => { - console.log(props, field); return { ...props, onCheck: (checkedKeys) => { @@ -76,7 +75,7 @@ export const ActionDesigner = (props) => { const isDuplicateAction = fieldSchema['x-action'] === 'duplicate'; const { collectionList, getEnableFieldTree, getOnLoadData, getOnCheck } = useCollectionState(name); const duplicateValues = cloneDeep(fieldSchema['x-component-props'].duplicateFields || []); - const options = useCollectionFieldsOptions(name, 1, ['id']); + useEffect(() => { const schemaUid = uid(); const schema: ISchema = { @@ -87,7 +86,6 @@ export const ActionDesigner = (props) => { }; setInitialSchema(schema); }, [field.address]); - const tips = { 'customize:update': t( 'After clicking the custom button, the following fields of the current record will be saved according to the following form.', @@ -170,6 +168,7 @@ export const ActionDesigner = (props) => { { 'x-decorator': 'FormItem', 'x-component': 'Tree', 'x-component-props': { - treeData: options, + treeData: [], checkable: true, + checkStrictly: true, + selectable: false, + loadData: '{{ getOnLoadData($self) }}', defaultCheckedKeys: field.componentProps.filterKeys, rootStyle: { padding: '8px 0', @@ -212,6 +214,9 @@ export const ActionDesigner = (props) => { fulfill: { state: { hidden: '{{ $deps[0]==="create"}}', + componentProps: { + treeData: '{{ getEnableFieldTree(name, $self) }}', + }, }, }, }, @@ -221,7 +226,6 @@ export const ActionDesigner = (props) => { } as ISchema } onSubmit={({ saveMode, filterKeys }) => { - console.log(saveMode, filterKeys); field.componentProps.saveMode = saveMode; field.componentProps.filterKeys = filterKeys; fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};