diff --git a/packages/core/client/src/filter-provider/utils.ts b/packages/core/client/src/filter-provider/utils.ts index 9bf65e62a..848ef9a6f 100644 --- a/packages/core/client/src/filter-provider/utils.ts +++ b/packages/core/client/src/filter-provider/utils.ts @@ -83,6 +83,11 @@ export const transformToFilter = ( values = flatten(values, { breakOn({ value, path }) { + // 日期字段的 `$dateBetween` 操作符的值是一个数组,需要特殊处理 + if (operators[path] === '$dateBetween') { + return true; + } + const collectionField = getCollectionJoinField(`${collectionName}.${path}`); if (collectionField?.target) { if (Array.isArray(value)) { diff --git a/packages/core/client/src/schema-component/antd/form-item/SchemaSettingOptions.tsx b/packages/core/client/src/schema-component/antd/form-item/SchemaSettingOptions.tsx index 2b37aa985..3f24d67dc 100644 --- a/packages/core/client/src/schema-component/antd/form-item/SchemaSettingOptions.tsx +++ b/packages/core/client/src/schema-component/antd/form-item/SchemaSettingOptions.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; import { useFormBlockContext } from '../../../block-provider'; import { useCollection, useCollectionManager } from '../../../collection-manager'; -import { isPatternDisabled, SchemaSettings } from '../../../schema-settings'; +import { SchemaSettings, isPatternDisabled } from '../../../schema-settings'; import { useCompile, useDesignable, useFieldModeOptions } from '../../hooks'; import { useOperatorList } from '../filter/useOperators'; import { isFileCollection } from './FormItem'; @@ -496,6 +496,7 @@ export const useEnsureOperatorsValid = () => { export const EditOperator = () => { const compile = useCompile(); const fieldSchema = useFieldSchema(); + const field = useField(); const { t } = useTranslation(); const { dn } = useDesignable(); const operatorList = useOperatorList(); @@ -513,10 +514,39 @@ export const EditOperator = () => { options={compile(operatorList)} onChange={(v) => { storedOperators[fieldSchema.name] = v; + const operator = operatorList.find((item) => item.value === v); const schema: ISchema = { ['x-uid']: uid, ['x-filter-operators']: storedOperators, }; + + // 根据操作符的配置,设置组件的属性 + if (operator?.schema?.['x-component']) { + _.set(fieldSchema, 'x-component-props.component', operator.schema['x-component']); + _.set(field, 'componentProps.component', operator.schema['x-component']); + field.reset(); + dn.emit('patch', { + schema: { + ['x-uid']: fieldSchema['x-uid'], + ['x-component-props']: { + component: operator.schema['x-component'], + }, + }, + }); + } else if (fieldSchema['x-component-props']?.component) { + _.set(fieldSchema, 'x-component-props.component', null); + _.set(field, 'componentProps.component', null); + field.reset(); + dn.emit('patch', { + schema: { + ['x-uid']: fieldSchema['x-uid'], + ['x-component-props']: { + component: null, + }, + }, + }); + } + dn.emit('patch', { schema, });