From 8c4fc3db130d01f9f0fd95b76153a2f191d8bfa8 Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Wed, 17 Jan 2024 15:28:34 +0800 Subject: [PATCH] * Modify genComponentData filter logic. --- module/screen/model.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/module/screen/model.php b/module/screen/model.php index 3a8e8c695f..6e9d246291 100644 --- a/module/screen/model.php +++ b/module/screen/model.php @@ -282,7 +282,26 @@ class screenModel extends model $component->chartConfig->dataset = $component->option->dataset; $component->chartConfig->fields = json_decode($chart->fields); - $component->chartConfig->filters = $this->getChartFilters($chart); + + // 如果传过来的component->chartConfig中有filters,判断filters是否发生了改变,改变则重置filters,其中单个filter的linkedGlobalFilter属性就不存在了 + $latestFilters = $this->getChartFilters($chart); + if(!isset($component->chartConfig->filters)) + { + $component->chartConfig->filters = $latestFilters; + } + else + { + $oldFilters = $component->chartConfig->filters; + $filterChanged = false; + + if(count($oldFilters) != count($latestFilters)) $filterChanged = true; + foreach($oldFilters as $index => $oldFilter) + { + if($oldFilter['field'] != $latestFilters[$index]['field']) $filterChanged = true; + } + + if($filterChanged) $component->chartConfig->filters = $latestFilters; + } if($type == 'chart' && (!$chart->builtin or in_array($chart->id, $this->config->screen->builtinChart))) {