Skip to content

Commit

Permalink
fix: 问题修复
Browse files Browse the repository at this point in the history
  • Loading branch information
yxh01132861 committed Dec 22, 2023
1 parent e710ad7 commit 963272e
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { DateConfig } from '@antv/li-p2';
import type { FilterDateConfigType } from '@antv/li-p2';
import React from 'react';
import { FilterDateConfig } from '@antv/li-p2';

export interface DateItemProps {
value: DateConfig;
onChange: (value: DateConfig) => void;
value: FilterDateConfigType;
onChange: (value: FilterDateConfigType) => void;
}

const DateItem: React.FC<DateItemProps> = (props) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { DownOutlined } from '@ant-design/icons';
import type { NumberConfig } from '@antv/li-p2';
import type { FilterNumberConfigType } from '@antv/li-p2';
import { FilterNumberConfig } from '@antv/li-p2';
import { Button, Popover } from 'antd';
import React, { useState } from 'react';
import useStyle from './style';

export interface NumberItemProps {
value: NumberConfig;
onChange: (value: NumberConfig) => void;
value: FilterNumberConfigType;
onChange: (value: FilterNumberConfigType) => void;
}

const NumberItem: React.FC<NumberItemProps> = (props) => {
Expand All @@ -29,7 +29,7 @@ const NumberItem: React.FC<NumberItemProps> = (props) => {
};

const onSubmit = () => {
const numberNode = { ...defaluValue, ...valAndOperator } as NumberConfig;
const numberNode = { ...defaluValue, ...valAndOperator } as FilterNumberConfigType;
onChange(numberNode);
setOpen(false);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { StringConfig } from '@antv/li-p2';
import type { FilterStringConfigType } from '@antv/li-p2';
import { FilterStringConfig } from '@antv/li-p2';
import { uniq } from 'lodash-es';
import React, { useMemo } from 'react';

export interface StringItemProps {
value: StringConfig;
value: FilterStringConfigType;
field: string;
data: Record<string, any>[];
onChange: (value: StringConfig) => void;
onChange: (value: FilterStringConfigType) => void;
}

const StringItem: React.FC<StringItemProps> = (props) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const LIFilterControl: React.FC<LIFilterControlProps> = (props) => {
const { data: tableData = [] } = dataset || {};
const [filterList, setFilterList] = useState(defaultFilters);
// 筛选数据
const [_, { addFilterNode, updateFilter }] = useDatasetFilter(datasetId);
const [_, { addFilterNode, updateFilterNode, updateFilter }] = useDatasetFilter(datasetId);
const firstMountRef = useRef(false);

// 首次挂载
Expand Down Expand Up @@ -55,7 +55,9 @@ const LIFilterControl: React.FC<LIFilterControlProps> = (props) => {
});

setFilterList(_filterList);
updateFilter({ relation: 'AND', children: getFilterNodes(_filterList) });

const filterNode = getFilterNodes([val])[0];
updateFilterNode(val.id, filterNode);
};

if (!defaultFilters.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { FilterDateSetting } from '../../../components';
import { DEFAULT_OPTIONS } from '../../../components/FilterDateConfig/contents';
import { getTimeFormat } from '../../../components/FilterDateConfig/helper';
import type { GranularityItem } from '../../../components/FilterDateConfig/type';
import type { DateConfig as FilterDateType } from '../../../type';
import type { FilterDateConfigType as FilterDateType } from '../../../type';
import { getOptions } from './helper';
import useStyle from './style';
export interface DateItemProps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { usePrefixCls } from '@formily/antd-v5/esm/__builtins__';
import cls from 'classnames';
import React from 'react';
import type { NumberConfig } from '../../../type';
import type { FilterNumberConfigType } from '../../../type';
import { FilterNumberConfig } from '../../../components';
import useStyle from './style';

export interface NumberItemProps {
value: NumberConfig;
value: FilterNumberConfigType;
/**
* 选择发生改变时
*/
onChange: (value: NumberConfig) => void;
onChange: (value: FilterNumberConfigType) => void;
}

const NumberItem: React.FC<NumberItemProps> = (props) => {
Expand All @@ -24,7 +24,7 @@ const NumberItem: React.FC<NumberItemProps> = (props) => {
...defaultValue,
value: val,
operator,
} as NumberConfig;
} as FilterNumberConfigType;
onChange(_value);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { Radio } from 'antd';
import cls from 'classnames';
import React from 'react';
import { FilterStringConfig } from '../../../components';
import type { StringConfig } from '../../../type';
import type { FilterStringConfigType } from '../../../type';
import useStyle from './style';
export interface StringItemProps {
value: StringConfig;
value: FilterStringConfigType;
options: string[];
onChange: (value: StringConfig) => void;
onChange: (value: FilterStringConfigType) => void;
}

const StringItem: React.FC<StringItemProps> = (props) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { DateConfig, NumberConfig, StringConfig, OptionType } from '../type';
import type { FilterDateConfigType, FilterNumberConfigType, FilterStringConfigType, OptionType } from '../type';

export const getDefaultValue = (field: OptionType, id: string) => {
if (field.type === 'string') {
const _filter: StringConfig = {
const _filter: FilterStringConfigType = {
id,
title: field.value,
field: field.value,
Expand All @@ -17,7 +17,7 @@ export const getDefaultValue = (field: OptionType, id: string) => {
}

if (field.type === 'date') {
const _filter: DateConfig = {
const _filter: FilterDateConfigType = {
id,
title: field.value,
field: field.value,
Expand All @@ -32,7 +32,7 @@ export const getDefaultValue = (field: OptionType, id: string) => {
return _filter;
}

const _filter: NumberConfig = {
const _filter: FilterNumberConfigType = {
id,
title: field.value,
field: field.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type FilterConfigBase = {
field: string;
};

export type StringConfig = FilterConfigBase & {
export type FilterStringConfigType = FilterConfigBase & {
type: 'string';
operator: 'IN';
value?: string[];
Expand All @@ -52,7 +52,7 @@ export type StringConfig = FilterConfigBase & {
};
};

export type DateConfig = FilterConfigBase & {
export type FilterDateConfigType = FilterConfigBase & {
type: 'date';
/** 日期粒度 */
granularity: Granularity;
Expand All @@ -66,7 +66,7 @@ export type DateConfig = FilterConfigBase & {
};
};

export type NumberConfig = FilterConfigBase &
export type FilterNumberConfigType = FilterConfigBase &
(
| {
type: 'number';
Expand All @@ -80,4 +80,4 @@ export type NumberConfig = FilterConfigBase &
}
);

export type FilterConfig = DateConfig | NumberConfig | StringConfig;
export type FilterConfig = FilterDateConfigType | FilterNumberConfigType | FilterStringConfigType;
7 changes: 6 additions & 1 deletion packages/li-p2/src/components/Formily/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ export { default as Slider } from './Slider';
export { default as SliderRange } from './SliderRange';
export { default as TimeGranularitySelect } from './TimeGranularitySelect';
export { default as FilterConfiguration } from './FilterConfiguration';
export type { FilterConfig, DateConfig, NumberConfig, StringConfig } from './FilterConfiguration/type';
export type {
FilterConfig,
FilterDateConfigType,
FilterNumberConfigType,
FilterStringConfigType,
} from './FilterConfiguration/type';
export { default as FilterDateConfig } from './FilterConfiguration/components/FilterDateConfig';
export { default as FilterStringConfig } from './FilterConfiguration/components/FilterStringConfig';
export { default as FilterNumberConfig } from './FilterConfiguration/components/FilterNumberConfig';

0 comments on commit 963272e

Please sign in to comment.