fix: fix operator called of date field (#2701)
This commit is contained in:
parent
b0069ca64a
commit
9f147085a5
@ -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)) {
|
||||
|
@ -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<Field>();
|
||||
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,
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user