Merge branch 'main' into next

This commit is contained in:
nocobase[bot] 2025-04-14 10:39:18 +00:00
commit d93ed210b8
2 changed files with 13 additions and 7 deletions

View File

@ -10,11 +10,11 @@
import { useFieldSchema } from '@formily/react'; import { useFieldSchema } from '@formily/react';
import React from 'react'; import React from 'react';
import { withDynamicSchemaProps } from '../hoc/withDynamicSchemaProps'; import { withDynamicSchemaProps } from '../hoc/withDynamicSchemaProps';
import { DatePickerProvider, ActionBarProvider, SchemaComponentOptions } from '../schema-component'; import { FilterCollectionField } from '../modules/blocks/filter-blocks/FilterCollectionField';
import { ActionBarProvider, DatePickerProvider, SchemaComponentOptions } from '../schema-component';
import { DefaultValueProvider } from '../schema-settings'; import { DefaultValueProvider } from '../schema-settings';
import { CollectOperators } from './CollectOperators'; import { CollectOperators } from './CollectOperators';
import { FormBlockProvider } from './FormBlockProvider'; import { FormBlockProvider } from './FormBlockProvider';
import { FilterCollectionField } from '../modules/blocks/filter-blocks/FilterCollectionField';
export const FilterFormBlockProvider = withDynamicSchemaProps((props) => { export const FilterFormBlockProvider = withDynamicSchemaProps((props) => {
const filedSchema = useFieldSchema(); const filedSchema = useFieldSchema();
@ -35,7 +35,7 @@ export const FilterFormBlockProvider = withDynamicSchemaProps((props) => {
}} }}
> >
<DefaultValueProvider isAllowToSetDefaultValue={() => false}> <DefaultValueProvider isAllowToSetDefaultValue={() => false}>
<FormBlockProvider name="filter-form" {...props}></FormBlockProvider> <FormBlockProvider name="filter-form" {...props} confirmBeforeClose={false}></FormBlockProvider>
</DefaultValueProvider> </DefaultValueProvider>
</ActionBarProvider> </ActionBarProvider>
</DatePickerProvider> </DatePickerProvider>

View File

@ -20,6 +20,7 @@ import { useAttach, useComponent } from '../..';
import { useApp } from '../../../application'; import { useApp } from '../../../application';
import { getCardItemSchema } from '../../../block-provider'; import { getCardItemSchema } from '../../../block-provider';
import { useTemplateBlockContext } from '../../../block-provider/TemplateBlockProvider'; import { useTemplateBlockContext } from '../../../block-provider/TemplateBlockProvider';
import { useDataBlockProps } from '../../../data-source';
import { useDataBlockRequest } from '../../../data-source/data-block/DataBlockRequestProvider'; import { useDataBlockRequest } from '../../../data-source/data-block/DataBlockRequestProvider';
import { NocoBaseRecursionField } from '../../../formily/NocoBaseRecursionField'; import { NocoBaseRecursionField } from '../../../formily/NocoBaseRecursionField';
import { withDynamicSchemaProps } from '../../../hoc/withDynamicSchemaProps'; import { withDynamicSchemaProps } from '../../../hoc/withDynamicSchemaProps';
@ -150,12 +151,15 @@ const WithForm = (props: WithFormProps) => {
const linkageRules: any[] = const linkageRules: any[] =
(getLinkageRules(fieldSchema) || fieldSchema.parent?.['x-linkage-rules'])?.filter((k) => !k.disabled) || []; (getLinkageRules(fieldSchema) || fieldSchema.parent?.['x-linkage-rules'])?.filter((k) => !k.disabled) || [];
// 关闭弹窗之前,如果有未保存的数据,是否要二次确认
const { confirmBeforeClose = true } = useDataBlockProps() || ({} as any);
useEffect(() => { useEffect(() => {
const id = uid(); const id = uid();
form.addEffects(id, () => { form.addEffects(id, () => {
onFormInputChange(() => { onFormInputChange(() => {
setFormValueChanged?.(true); setFormValueChanged?.(confirmBeforeClose);
}); });
}); });
@ -166,7 +170,7 @@ const WithForm = (props: WithFormProps) => {
return () => { return () => {
form.removeEffects(id); form.removeEffects(id);
}; };
}, [form, props.disabled, setFormValueChanged]); }, [form, props.disabled, setFormValueChanged, confirmBeforeClose]);
useEffect(() => { useEffect(() => {
if (loading) { if (loading) {
@ -219,17 +223,19 @@ const WithForm = (props: WithFormProps) => {
const WithoutForm = (props) => { const WithoutForm = (props) => {
const fieldSchema = useFieldSchema(); const fieldSchema = useFieldSchema();
const { setFormValueChanged } = useActionContext(); const { setFormValueChanged } = useActionContext();
// 关闭弹窗之前,如果有未保存的数据,是否要二次确认
const { confirmBeforeClose = true } = useDataBlockProps() || ({} as any);
const form = useMemo( const form = useMemo(
() => () =>
createForm({ createForm({
disabled: props.disabled, disabled: props.disabled,
effects() { effects() {
onFormInputChange((form) => { onFormInputChange((form) => {
setFormValueChanged?.(true); setFormValueChanged?.(confirmBeforeClose);
}); });
}, },
}), }),
[], [confirmBeforeClose],
); );
return fieldSchema['x-decorator'] === 'FormV2' ? ( return fieldSchema['x-decorator'] === 'FormV2' ? (
<FormDecorator form={form} {...props} /> <FormDecorator form={form} {...props} />