更新
This commit is contained in:
@@ -412,11 +412,32 @@ class FirstVisitConversionLogic
|
||||
/** @param array<int,array<string,mixed>> $rows @return array<int,array<string,mixed>> */
|
||||
private static function rankingRows(array $rows): array
|
||||
{
|
||||
if (count($rows) === 1 && is_array($rows[0]['children'] ?? null) && $rows[0]['children'] !== []) {
|
||||
return $rows[0]['children'];
|
||||
// lists 里可能同时存在“未绑定/未分配部门”等虚拟根节点。它们会让顶层节点数量
|
||||
// 大于 1,导致原逻辑无法展开唯一的真实组织根节点,图表最终只显示医院汇总行。
|
||||
$visibleRows = array_values(array_filter($rows, static function (array $row): bool {
|
||||
return (int) ($row['id'] ?? 0) > 0 && !((bool) ($row['_virtual_bucket'] ?? false));
|
||||
}));
|
||||
|
||||
// 每个可见顶层分支只展示同一层级:有权限看到下级时展示直属子部门;没有可见
|
||||
// 下级时保留当前部门。这样既能按角色/DataScope 展示子部门,也不会把父子汇总
|
||||
// 同时放进占比图造成重复计算。
|
||||
$chartRows = [];
|
||||
foreach ($visibleRows as $row) {
|
||||
$children = array_values(array_filter(
|
||||
is_array($row['children'] ?? null) ? $row['children'] : [],
|
||||
static fn (array $child): bool => (int) ($child['id'] ?? 0) > 0
|
||||
&& !((bool) ($child['_virtual_bucket'] ?? false))
|
||||
));
|
||||
if ($children !== []) {
|
||||
foreach ($children as $child) {
|
||||
$chartRows[] = $child;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
$chartRows[] = $row;
|
||||
}
|
||||
|
||||
return $rows;
|
||||
return $chartRows;
|
||||
}
|
||||
|
||||
/** @param array<int,array<string,mixed>> $rows @return array<int,array<string,mixed>> */
|
||||
|
||||
Reference in New Issue
Block a user