Skip to content

Commit 8058e42

Browse files
committed
fix:fix bug
1 parent e2bd9c4 commit 8058e42

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

src/frontend/platform/src/pages/Dashboard/components/config/ComponentConfigDrawer.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -387,18 +387,19 @@ export function ComponentConfigDrawer() {
387387
}
388388
}, [chartType])
389389
editingComponent?.dataset_code
390-
useEffect(() => {
391-
setFilterGroup({
392-
logic: "and",
393-
conditions: []
394-
})
395-
}, [editingComponent?.dataset_code])
396390
// 数据集改变
397391
const handleDatasetChange = useCallback((datasetCode: string) => {
398392
if (editingComponent) {
399393
updateEditingComponent({ dataset_code: datasetCode })
394+
// 只有当数据集真正改变时才重置
395+
if (editingComponent.dataset_code !== datasetCode) {
396+
setFilterGroup({
397+
logic: "and",
398+
conditions: []
399+
})
400+
}
400401
}
401-
}, [editingComponent, updateEditingComponent])
402+
}, [editingComponent, updateEditingComponent, setFilterGroup])
402403

403404
// 拖拽开始
404405
const handleDragStart = useCallback((e: React.DragEvent, data: any) => {
@@ -1230,6 +1231,7 @@ export function ComponentConfigDrawer() {
12301231
onChange={handleSaveFilter}
12311232
fields={datasetFields}
12321233
dataset_code={editingComponent?.dataset_code}
1234+
filtersLogic={editingComponent?.data_config.filtersLogic}
12331235
dimensions={[...categoryDimensions, ...stackDimensions, ...valueDimensions]}
12341236
/>
12351237
</div>

src/frontend/platform/src/pages/Dashboard/components/config/FilterConditionDialog.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,8 @@ export function FilterConditionDialog({
304304
onChange,
305305
fields,
306306
dataset_code = "",
307-
dimensions = []
307+
dimensions = [],
308+
filtersLogic
308309
}: Props) {
309310
const { t } = useTranslation("dashboard")
310311
const [draft, setDraft] = useState<FilterGroup>({
@@ -414,7 +415,7 @@ export function FilterConditionDialog({
414415
})
415416

416417
setDraft({
417-
logic: safeValue.logic ?? "and",
418+
logic: filtersLogic ?? "and",
418419
conditions: newConditions.length > 0 ? newConditions : [createEmptyCondition()]
419420
})
420421
setError(null)

src/frontend/platform/src/pages/Dashboard/components/config/useChartState.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ export function useChartState(initialComponent: any) {
692692
limitType: limitType === "limit" ? "limited" as const : "all" as const,
693693
...(limitType === "limit" && { limit: Number(limitValue) })
694694
},
695+
filtersLogic: filterGroup?.logic || 'and',
695696
isConfigured: true,
696697
}
697698
}, [categoryDimensions, stackDimensions, valueDimensions, filterGroup, sortPriorityOrder])

0 commit comments

Comments
 (0)