mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
perf(LinkageRules): solve lagging problems (#4090)
This commit is contained in:
parent
8f17456d93
commit
ca29515bcd
@ -1,6 +1,6 @@
|
|||||||
import { createForm, Form, IFormProps } from '@formily/core';
|
import { createForm, Form, IFormProps } from '@formily/core';
|
||||||
import { FormProvider, Observer, observer, ReactFC } from '@formily/react';
|
import { FormProvider, Observer, observer, ReactFC } from '@formily/react';
|
||||||
import { toJS } from '@formily/reactive';
|
import { untracked } from '@formily/reactive';
|
||||||
import { applyMiddleware, IMiddleware, isBool, isFn, isNum, isStr } from '@formily/shared';
|
import { applyMiddleware, IMiddleware, isBool, isFn, isNum, isStr } from '@formily/shared';
|
||||||
import { Modal, ModalProps, ThemeConfig } from 'antd';
|
import { Modal, ModalProps, ThemeConfig } from 'antd';
|
||||||
import React, { Fragment, useLayoutEffect, useRef, useState } from 'react';
|
import React, { Fragment, useLayoutEffect, useRef, useState } from 'react';
|
||||||
@ -161,7 +161,9 @@ export function FormDialog(title: any, id: any, renderer?: any, theme?: any): IF
|
|||||||
env.form
|
env.form
|
||||||
?.submit(async () => {
|
?.submit(async () => {
|
||||||
await applyMiddleware(env.form, env.confirmMiddlewares);
|
await applyMiddleware(env.form, env.confirmMiddlewares);
|
||||||
resolve(toJS(env.form?.values));
|
untracked(() => {
|
||||||
|
resolve({ ...env.form?.values });
|
||||||
|
});
|
||||||
formDialog.close();
|
formDialog.close();
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { css } from '@emotion/css';
|
import { css } from '@emotion/css';
|
||||||
import { Form } from '@formily/core';
|
|
||||||
import { observer, useFieldSchema } from '@formily/react';
|
import { observer, useFieldSchema } from '@formily/react';
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
|
import { withDynamicSchemaProps } from '../../application/hoc/withDynamicSchemaProps';
|
||||||
import { FormBlockContext } from '../../block-provider';
|
import { FormBlockContext } from '../../block-provider';
|
||||||
import { useCollectionManager_deprecated } from '../../collection-manager';
|
import { useCollectionManager_deprecated } from '../../collection-manager';
|
||||||
import { useCollectionParentRecordData } from '../../data-source/collection-record/CollectionRecordProvider';
|
import { useCollectionParentRecordData } from '../../data-source/collection-record/CollectionRecordProvider';
|
||||||
@ -9,26 +9,10 @@ import { RecordProvider } from '../../record-provider';
|
|||||||
import { SchemaComponent, useProps } from '../../schema-component';
|
import { SchemaComponent, useProps } from '../../schema-component';
|
||||||
import { DynamicComponentProps } from '../../schema-component/antd/filter/DynamicComponent';
|
import { DynamicComponentProps } from '../../schema-component/antd/filter/DynamicComponent';
|
||||||
import { FilterContext } from '../../schema-component/antd/filter/context';
|
import { FilterContext } from '../../schema-component/antd/filter/context';
|
||||||
import { VariableOption, VariablesContextType } from '../../variables/types';
|
|
||||||
import { VariableInput, getShouldChange } from '../VariableInput/VariableInput';
|
import { VariableInput, getShouldChange } from '../VariableInput/VariableInput';
|
||||||
import { LinkageRuleActionGroup } from './LinkageRuleActionGroup';
|
import { LinkageRuleActionGroup } from './LinkageRuleActionGroup';
|
||||||
import { EnableLinkage } from './components/EnableLinkage';
|
import { EnableLinkage } from './components/EnableLinkage';
|
||||||
import { ArrayCollapse } from './components/LinkageHeader';
|
import { ArrayCollapse } from './components/LinkageHeader';
|
||||||
import { withDynamicSchemaProps } from '../../application/hoc/withDynamicSchemaProps';
|
|
||||||
|
|
||||||
interface usePropsReturn {
|
|
||||||
options: any;
|
|
||||||
defaultValues: any[];
|
|
||||||
collectionName: string;
|
|
||||||
form: Form;
|
|
||||||
variables: VariablesContextType;
|
|
||||||
localVariables: VariableOption | VariableOption[];
|
|
||||||
record: Record<string, any>;
|
|
||||||
/**
|
|
||||||
* create 表示创建表单,update 表示更新表单
|
|
||||||
*/
|
|
||||||
formBlockType: 'create' | 'update';
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
dynamicComponent: any;
|
dynamicComponent: any;
|
||||||
@ -124,10 +108,7 @@ export const FormLinkageRules = withDynamicSchemaProps(
|
|||||||
},
|
},
|
||||||
action: {
|
action: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
'x-component': LinkageRuleActionGroup,
|
'x-component': (_props) => <LinkageRuleActionGroup {..._props} {...props} />,
|
||||||
'x-component-props': {
|
|
||||||
...props,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -167,7 +148,17 @@ export const FormLinkageRules = withDynamicSchemaProps(
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
[collectionName, defaultValues, form, localVariables, options, props, record, variables],
|
[
|
||||||
|
collectionName,
|
||||||
|
defaultValues,
|
||||||
|
form,
|
||||||
|
getAllCollectionsInheritChain,
|
||||||
|
localVariables,
|
||||||
|
options,
|
||||||
|
props,
|
||||||
|
record,
|
||||||
|
variables,
|
||||||
|
],
|
||||||
);
|
);
|
||||||
const value = useMemo(
|
const value = useMemo(
|
||||||
() => ({ field: options, fieldSchema, dynamicComponent, options: options || [] }),
|
() => ({ field: options, fieldSchema, dynamicComponent, options: options || [] }),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user