mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 05:29:26 +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 { 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 { Modal, ModalProps, ThemeConfig } from 'antd';
|
||||
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
|
||||
?.submit(async () => {
|
||||
await applyMiddleware(env.form, env.confirmMiddlewares);
|
||||
resolve(toJS(env.form?.values));
|
||||
untracked(() => {
|
||||
resolve({ ...env.form?.values });
|
||||
});
|
||||
formDialog.close();
|
||||
})
|
||||
.catch(() => {});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { css } from '@emotion/css';
|
||||
import { Form } from '@formily/core';
|
||||
import { observer, useFieldSchema } from '@formily/react';
|
||||
import React, { useMemo } from 'react';
|
||||
import { withDynamicSchemaProps } from '../../application/hoc/withDynamicSchemaProps';
|
||||
import { FormBlockContext } from '../../block-provider';
|
||||
import { useCollectionManager_deprecated } from '../../collection-manager';
|
||||
import { useCollectionParentRecordData } from '../../data-source/collection-record/CollectionRecordProvider';
|
||||
@ -9,26 +9,10 @@ import { RecordProvider } from '../../record-provider';
|
||||
import { SchemaComponent, useProps } from '../../schema-component';
|
||||
import { DynamicComponentProps } from '../../schema-component/antd/filter/DynamicComponent';
|
||||
import { FilterContext } from '../../schema-component/antd/filter/context';
|
||||
import { VariableOption, VariablesContextType } from '../../variables/types';
|
||||
import { VariableInput, getShouldChange } from '../VariableInput/VariableInput';
|
||||
import { LinkageRuleActionGroup } from './LinkageRuleActionGroup';
|
||||
import { EnableLinkage } from './components/EnableLinkage';
|
||||
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 {
|
||||
dynamicComponent: any;
|
||||
@ -124,10 +108,7 @@ export const FormLinkageRules = withDynamicSchemaProps(
|
||||
},
|
||||
action: {
|
||||
type: 'void',
|
||||
'x-component': LinkageRuleActionGroup,
|
||||
'x-component-props': {
|
||||
...props,
|
||||
},
|
||||
'x-component': (_props) => <LinkageRuleActionGroup {..._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(
|
||||
() => ({ field: options, fieldSchema, dynamicComponent, options: options || [] }),
|
||||
|
Loading…
x
Reference in New Issue
Block a user