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 React from 'react';
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 { CollectOperators } from './CollectOperators';
import { FormBlockProvider } from './FormBlockProvider';
import { FilterCollectionField } from '../modules/blocks/filter-blocks/FilterCollectionField';
export const FilterFormBlockProvider = withDynamicSchemaProps((props) => {
const filedSchema = useFieldSchema();
@ -35,7 +35,7 @@ export const FilterFormBlockProvider = withDynamicSchemaProps((props) => {
}}
>
<DefaultValueProvider isAllowToSetDefaultValue={() => false}>
<FormBlockProvider name="filter-form" {...props}></FormBlockProvider>
<FormBlockProvider name="filter-form" {...props} confirmBeforeClose={false}></FormBlockProvider>
</DefaultValueProvider>
</ActionBarProvider>
</DatePickerProvider>

View File

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