From 142e02c5a8986ea9fb89cc36d22be437a1f6e745 Mon Sep 17 00:00:00 2001 From: yxh01132861 Date: Tue, 23 Jan 2024 10:26:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=97=B6=E9=97=B4=E8=BD=B4=E7=AD=9B?= =?UTF-8?q?=E9=80=89=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/widgets/TimeLine/Component/index.tsx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/li-analysis-assets/src/widgets/TimeLine/Component/index.tsx b/packages/li-analysis-assets/src/widgets/TimeLine/Component/index.tsx index 8ab17ec5..bfea354c 100644 --- a/packages/li-analysis-assets/src/widgets/TimeLine/Component/index.tsx +++ b/packages/li-analysis-assets/src/widgets/TimeLine/Component/index.tsx @@ -49,6 +49,7 @@ const TimeLineControl: React.FC = (props) => { // 获取数据源 const [dataset] = useDataset(datasetId, { filter: dataSetFilter }); + const dateFilterNodeRef = useRef(null); // 数据源和数据字段配置发生更新时,如果有配置筛选条件,需要清空筛选条件 useEffect(() => { @@ -80,6 +81,10 @@ const TimeLineControl: React.FC = (props) => { isTimeLineFilter(item, dateField, dataWidgetId), ); + if (filterNode?.id) { + dateFilterNodeRef.current = filterNode.id; + } + const selectedRange = filterNode?.value; const isTimeXField = fieldType === 'date'; @@ -93,14 +98,15 @@ const TimeLineControl: React.FC = (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', @@ -114,8 +120,9 @@ const TimeLineControl: React.FC = (props) => { // 删除筛选条件 const delFilterNode = () => { - if (filterNode?.id) { - removeFilterNode(filterNode?.id); + if (dateFilterNodeRef.current) { + removeFilterNode(dateFilterNodeRef.current); + dateFilterNodeRef.current = null; } };