Skip to content

Commit

Permalink
fix: 时间轴筛选问题修复
Browse files Browse the repository at this point in the history
  • Loading branch information
yxh01132861 committed Jan 23, 2024
1 parent d890f02 commit 142e02c
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const TimeLineControl: React.FC<TimeLineControlType> = (props) => {

// 获取数据源
const [dataset] = useDataset(datasetId, { filter: dataSetFilter });
const dateFilterNodeRef = useRef(null);

// 数据源和数据字段配置发生更新时,如果有配置筛选条件,需要清空筛选条件
useEffect(() => {
Expand Down Expand Up @@ -80,6 +81,10 @@ const TimeLineControl: React.FC<TimeLineControlType> = (props) => {
isTimeLineFilter(item, dateField, dataWidgetId),
);

if (filterNode?.id) {
dateFilterNodeRef.current = filterNode.id;
}

const selectedRange = filterNode?.value;
const isTimeXField = fieldType === 'date';

Expand All @@ -93,14 +98,15 @@ const TimeLineControl: React.FC<TimeLineControlType> = (props) => {

const onFilterNodeChange = (value: Selection | any) => {
// 更新筛选
if (filterNode?.id) {
runUpdateFilterNode(filterNode?.id, { value });
if (dateFilterNodeRef.current) {
runUpdateFilterNode(dateFilterNodeRef.current, { value });
return;
}

dateFilterNodeRef.current = getUniqueId();
// 添加筛选
const _filterNode: TimeLineFilter = {
id: getUniqueId(),
id: dateFilterNodeRef.current,
type: fieldType as 'date',
field: dateField,
operator: 'BETWEEN',
Expand All @@ -114,8 +120,9 @@ const TimeLineControl: React.FC<TimeLineControlType> = (props) => {

// 删除筛选条件
const delFilterNode = () => {
if (filterNode?.id) {
removeFilterNode(filterNode?.id);
if (dateFilterNodeRef.current) {
removeFilterNode(dateFilterNodeRef.current);
dateFilterNodeRef.current = null;
}
};

Expand Down

0 comments on commit 142e02c

Please sign in to comment.