fix(filter): fix $in operatror (#3235)
This commit is contained in:
parent
a6c23d58a1
commit
c2f3cfd6ce
@ -83,8 +83,8 @@ export const transformToFilter = (
|
|||||||
|
|
||||||
values = flatten(values, {
|
values = flatten(values, {
|
||||||
breakOn({ value, path }) {
|
breakOn({ value, path }) {
|
||||||
// 日期字段的 `$dateBetween` 操作符的值是一个数组,需要特殊处理
|
// 下面操作符的值是一个数组,需要特殊处理
|
||||||
if (operators[path] === '$dateBetween') {
|
if (['$dateBetween', '$in'].includes(operators[path])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,34 +525,40 @@ export const EditOperator = () => {
|
|||||||
['x-uid']: uid,
|
['x-uid']: uid,
|
||||||
['x-filter-operators']: storedOperators,
|
['x-filter-operators']: storedOperators,
|
||||||
};
|
};
|
||||||
|
let componentProps = {};
|
||||||
|
|
||||||
// 根据操作符的配置,设置组件的属性
|
// 根据操作符的配置,设置组件的属性
|
||||||
if (operator?.schema?.['x-component']) {
|
if (operator?.schema?.['x-component']) {
|
||||||
_.set(fieldSchema, 'x-component-props.component', operator.schema['x-component']);
|
_.set(fieldSchema, 'x-component-props.component', operator.schema['x-component']);
|
||||||
_.set(field, 'componentProps.component', operator.schema['x-component']);
|
_.set(field, 'componentProps.component', operator.schema['x-component']);
|
||||||
field.reset();
|
field.reset();
|
||||||
|
componentProps = {
|
||||||
|
component: operator.schema['x-component'],
|
||||||
|
...operator.schema['x-component-props'],
|
||||||
|
};
|
||||||
dn.emit('patch', {
|
dn.emit('patch', {
|
||||||
schema: {
|
schema: {
|
||||||
['x-uid']: fieldSchema['x-uid'],
|
['x-uid']: fieldSchema['x-uid'],
|
||||||
['x-component-props']: {
|
['x-component-props']: componentProps,
|
||||||
component: operator.schema['x-component'],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else if (fieldSchema['x-component-props']?.component) {
|
} else if (fieldSchema['x-component-props']?.component) {
|
||||||
_.set(fieldSchema, 'x-component-props.component', null);
|
_.set(fieldSchema, 'x-component-props.component', null);
|
||||||
_.set(field, 'componentProps.component', null);
|
_.set(field, 'componentProps.component', null);
|
||||||
field.reset();
|
field.reset();
|
||||||
|
componentProps = {
|
||||||
|
component: null,
|
||||||
|
...operator.schema['x-component-props'],
|
||||||
|
};
|
||||||
dn.emit('patch', {
|
dn.emit('patch', {
|
||||||
schema: {
|
schema: {
|
||||||
['x-uid']: fieldSchema['x-uid'],
|
['x-uid']: fieldSchema['x-uid'],
|
||||||
['x-component-props']: {
|
['x-component-props']: componentProps,
|
||||||
component: null,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
field.componentProps = componentProps;
|
||||||
dn.emit('patch', {
|
dn.emit('patch', {
|
||||||
schema,
|
schema,
|
||||||
});
|
});
|
||||||
|
@ -6,11 +6,11 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useAPIClient } from '../../../api-client';
|
import { useAPIClient } from '../../../api-client';
|
||||||
import { findFormBlock } from '../../../block-provider';
|
import { findFormBlock } from '../../../block-provider';
|
||||||
|
import { useFormBlockContext } from '../../../block-provider/FormBlockProvider';
|
||||||
import { useCollectionManager } from '../../../collection-manager';
|
import { useCollectionManager } from '../../../collection-manager';
|
||||||
import { compatibleDataId } from '../../../schema-settings/DataTemplates/FormDataTemplates';
|
import { compatibleDataId } from '../../../schema-settings/DataTemplates/FormDataTemplates';
|
||||||
import { useToken } from '../__builtins__';
|
import { useToken } from '../__builtins__';
|
||||||
import { RemoteSelect } from '../remote-select';
|
import { RemoteSelect } from '../remote-select';
|
||||||
import { useFormBlockContext } from '../../../block-provider/FormBlockProvider';
|
|
||||||
|
|
||||||
export interface ITemplate {
|
export interface ITemplate {
|
||||||
config?: {
|
config?: {
|
||||||
@ -40,7 +40,6 @@ const useDataTemplates = () => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { duplicateData } = useFormBlockContext();
|
const { duplicateData } = useFormBlockContext();
|
||||||
const { getCollectionJoinField } = useCollectionManager();
|
const { getCollectionJoinField } = useCollectionManager();
|
||||||
console.log(useFormBlockContext());
|
|
||||||
if (duplicateData) {
|
if (duplicateData) {
|
||||||
return duplicateData;
|
return duplicateData;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user