Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 时间轴筛选问题修复 #126

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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<string>();

// 数据源和数据字段配置发生更新时,如果有配置筛选条件,需要清空筛选条件
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 = undefined;
}
};

Expand Down
Loading