mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 13:06:31 +00:00
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
This commit is contained in:
parent
7e0ac57057
commit
24f2429066
@ -5,7 +5,7 @@ import { cloneDeep } from 'lodash';
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useDesignable } from '../..';
|
import { useDesignable } from '../..';
|
||||||
import { useCollection, useCollectionFieldsOptions, useCollectionManager } from '../../../collection-manager';
|
import { useCollection, useCollectionManager } from '../../../collection-manager';
|
||||||
import { OpenModeSchemaItems } from '../../../schema-items';
|
import { OpenModeSchemaItems } from '../../../schema-items';
|
||||||
import { GeneralSchemaDesigner, SchemaSettings } from '../../../schema-settings';
|
import { GeneralSchemaDesigner, SchemaSettings } from '../../../schema-settings';
|
||||||
import { useCollectionState } from '../../../schema-settings/DataTemplates/hooks/useCollectionState';
|
import { useCollectionState } from '../../../schema-settings/DataTemplates/hooks/useCollectionState';
|
||||||
@ -15,7 +15,6 @@ import { requestSettingsSchema } from './utils';
|
|||||||
const Tree = connect(
|
const Tree = connect(
|
||||||
AntdTree,
|
AntdTree,
|
||||||
mapProps((props, field: any) => {
|
mapProps((props, field: any) => {
|
||||||
console.log(props, field);
|
|
||||||
return {
|
return {
|
||||||
...props,
|
...props,
|
||||||
onCheck: (checkedKeys) => {
|
onCheck: (checkedKeys) => {
|
||||||
@ -76,7 +75,7 @@ export const ActionDesigner = (props) => {
|
|||||||
const isDuplicateAction = fieldSchema['x-action'] === 'duplicate';
|
const isDuplicateAction = fieldSchema['x-action'] === 'duplicate';
|
||||||
const { collectionList, getEnableFieldTree, getOnLoadData, getOnCheck } = useCollectionState(name);
|
const { collectionList, getEnableFieldTree, getOnLoadData, getOnCheck } = useCollectionState(name);
|
||||||
const duplicateValues = cloneDeep(fieldSchema['x-component-props'].duplicateFields || []);
|
const duplicateValues = cloneDeep(fieldSchema['x-component-props'].duplicateFields || []);
|
||||||
const options = useCollectionFieldsOptions(name, 1, ['id']);
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const schemaUid = uid();
|
const schemaUid = uid();
|
||||||
const schema: ISchema = {
|
const schema: ISchema = {
|
||||||
@ -87,7 +86,6 @@ export const ActionDesigner = (props) => {
|
|||||||
};
|
};
|
||||||
setInitialSchema(schema);
|
setInitialSchema(schema);
|
||||||
}, [field.address]);
|
}, [field.address]);
|
||||||
|
|
||||||
const tips = {
|
const tips = {
|
||||||
'customize:update': t(
|
'customize:update': t(
|
||||||
'After clicking the custom button, the following fields of the current record will be saved according to the following form.',
|
'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) => {
|
|||||||
<SchemaSettings.ModalItem
|
<SchemaSettings.ModalItem
|
||||||
title={t('Save mode')}
|
title={t('Save mode')}
|
||||||
components={{ Tree }}
|
components={{ Tree }}
|
||||||
|
scope={{ getEnableFieldTree, name, getOnLoadData }}
|
||||||
schema={
|
schema={
|
||||||
{
|
{
|
||||||
type: 'object',
|
type: 'object',
|
||||||
@ -194,8 +193,11 @@ export const ActionDesigner = (props) => {
|
|||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
'x-component': 'Tree',
|
'x-component': 'Tree',
|
||||||
'x-component-props': {
|
'x-component-props': {
|
||||||
treeData: options,
|
treeData: [],
|
||||||
checkable: true,
|
checkable: true,
|
||||||
|
checkStrictly: true,
|
||||||
|
selectable: false,
|
||||||
|
loadData: '{{ getOnLoadData($self) }}',
|
||||||
defaultCheckedKeys: field.componentProps.filterKeys,
|
defaultCheckedKeys: field.componentProps.filterKeys,
|
||||||
rootStyle: {
|
rootStyle: {
|
||||||
padding: '8px 0',
|
padding: '8px 0',
|
||||||
@ -212,6 +214,9 @@ export const ActionDesigner = (props) => {
|
|||||||
fulfill: {
|
fulfill: {
|
||||||
state: {
|
state: {
|
||||||
hidden: '{{ $deps[0]==="create"}}',
|
hidden: '{{ $deps[0]==="create"}}',
|
||||||
|
componentProps: {
|
||||||
|
treeData: '{{ getEnableFieldTree(name, $self) }}',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -221,7 +226,6 @@ export const ActionDesigner = (props) => {
|
|||||||
} as ISchema
|
} as ISchema
|
||||||
}
|
}
|
||||||
onSubmit={({ saveMode, filterKeys }) => {
|
onSubmit={({ saveMode, filterKeys }) => {
|
||||||
console.log(saveMode, filterKeys);
|
|
||||||
field.componentProps.saveMode = saveMode;
|
field.componentProps.saveMode = saveMode;
|
||||||
field.componentProps.filterKeys = filterKeys;
|
field.componentProps.filterKeys = filterKeys;
|
||||||
fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
|
fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
|
||||||
|
Loading…
Reference in New Issue
Block a user