Commit 4836cc26 by Ivan

feat: group_index 最后一级重复问题

parent d4bf9714
...@@ -50,32 +50,30 @@ module SimpleController::GroupIndex ...@@ -50,32 +50,30 @@ module SimpleController::GroupIndex
def tree_result_mount_data(tree_result, statistics, group_configs, depth=0) def tree_result_mount_data(tree_result, statistics, group_configs, depth=0)
(tree_result || []).map do |key, value| (tree_result || []).map do |key, value|
children = children =
if value.is_a?(Hash) if depth > group_configs.length
tree_result_mount_data(value, statistics, group_configs, depth + 1) []
elsif value.is_a?(Array) elsif value.is_a?(Hash)
fake_tree_result = value.map { |ary_key| [ary_key.last, [ary_key]] }.to_h tree_result_mount_data(value, statistics, group_configs, depth + 1)
if fake_tree_result == tree_result elsif value.is_a?(Array)
[] fake_tree_result = value.map { |ary_key| [ary_key.last, [ary_key]] }.to_h
else tree_result_mount_data(
tree_result_mount_data( fake_tree_result,
fake_tree_result, statistics,
statistics, group_configs,
group_configs, depth + 1,
depth + 1 )
) else
end []
else end
[]
end
{ {
count: tree_result_get_count_sum(value, statistics), count: tree_result_get_count_sum(value, statistics),
children: children, children: children,
}.merge( }.merge(
key.nil? ? { key.nil? ? {
ransack_key: (group_configs[depth] || group_configs.last)[:ransack_key].gsub(/_eq$/, '_null'), ransack_key: group_configs[depth][:ransack_key].gsub(/_eq$/, '_null'),
ransack_value: true, ransack_value: true,
} : { } : {
ransack_key: (group_configs[depth] || group_configs.last)[:ransack_key], ransack_key: group_configs[depth][:ransack_key],
ransack_value: key, ransack_value: key,
} }
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment