|
|
@@ -152,9 +152,9 @@
|
|
|
>
|
|
|
<el-option label="全部队伍" :value="ALL_GROUPS_VALUE"></el-option>
|
|
|
<el-option
|
|
|
- v-for="group in flatRankGroupOptions"
|
|
|
+ v-for="group in rankGroupOptions"
|
|
|
:key="group.rgId"
|
|
|
- :label="group.displayName"
|
|
|
+ :label="group.rgName"
|
|
|
:value="group.rgId"
|
|
|
/>
|
|
|
</el-select>
|
|
|
@@ -390,52 +390,35 @@ const loadTeamProjectScores = async () => {
|
|
|
handleRankGroupChange(selectedRankGroupId.value);
|
|
|
};
|
|
|
|
|
|
-// 扁平化的分组选项
|
|
|
-const flatRankGroupOptions = ref<any[]>([]);
|
|
|
-
|
|
|
-// 将树形结构打平
|
|
|
-const flattenTree = (tree: any[]) => {
|
|
|
- const arr: any[] = [];
|
|
|
- tree.forEach(node => {
|
|
|
- arr.push({
|
|
|
- ...node,
|
|
|
- displayName: node.rgName
|
|
|
- });
|
|
|
- if (node.children && node.children.length > 0) {
|
|
|
- arr.push(...flattenTree(node.children));
|
|
|
- }
|
|
|
- });
|
|
|
- return arr;
|
|
|
-};
|
|
|
-
|
|
|
-// 获取所有子节点ID(包含自身)
|
|
|
-const getAllChildIds = (rgId: string | number, options: any[]): (string | number)[] => {
|
|
|
- const ids: (string | number)[] = [rgId];
|
|
|
- const findChildren = (parentId: string | number) => {
|
|
|
- options.forEach(opt => {
|
|
|
- if (opt.parentId === parentId) {
|
|
|
- ids.push(opt.rgId);
|
|
|
- findChildren(opt.rgId);
|
|
|
- }
|
|
|
- });
|
|
|
- };
|
|
|
- findChildren(rgId);
|
|
|
- return ids;
|
|
|
-};
|
|
|
-
|
|
|
// 处理分组筛选变化
|
|
|
const handleRankGroupChange = (rgId: string | number | null | undefined) => {
|
|
|
if (rgId === null || rgId === undefined || rgId === '' || rgId === ALL_GROUPS_VALUE) {
|
|
|
// 显示所有队伍
|
|
|
filteredTeamScores.value = teamScores.value;
|
|
|
} else {
|
|
|
- // 获取当前选中分组及其所有子分组的ID集合
|
|
|
- const targetIds = getAllChildIds(rgId, flatRankGroupOptions.value);
|
|
|
- // 筛选所属分组在集合内的队伍
|
|
|
+ // 筛选所属分组的队伍(现在后端已处理父子关系,但此处是前端过滤已加载的数据)
|
|
|
+ // 注意:如果看板是全量数据在前端筛选,前端依然需要知道哪些子分组属于该父分组
|
|
|
+ // 或者更简单的做法:看板数据在获取时就根据 rgId 传参给后端。
|
|
|
+
|
|
|
+ // 鉴于看板通常是全量计算好后前端切分,我们这里保留一个简单的打平用于辅助过滤
|
|
|
+ const targetIds = getFlatIds(rgId);
|
|
|
filteredTeamScores.value = teamScores.value.filter(team => targetIds.includes(team.rgId));
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+// 从扁平列表中获取某个节点下的所有子孙ID(用于前端筛选)
|
|
|
+const getFlatIds = (rgId: string | number) => {
|
|
|
+ const ids: (string | number)[] = [rgId];
|
|
|
+ const targetIdStr = String(rgId);
|
|
|
+ // 遍历扁平列表,通过 ancestors 祖级路径识别所有子孙节点
|
|
|
+ rankGroupOptions.value.forEach(item => {
|
|
|
+ if (item.ancestors && item.ancestors.split(',').includes(targetIdStr)) {
|
|
|
+ ids.push(item.rgId);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return ids;
|
|
|
+};
|
|
|
+
|
|
|
// 获取分组选项
|
|
|
const loadRankGroupOptions = async () => {
|
|
|
try {
|
|
|
@@ -443,10 +426,7 @@ const loadRankGroupOptions = async () => {
|
|
|
eventId: defaultEventInfo.value.eventId,
|
|
|
status: '0'
|
|
|
});
|
|
|
- // 保存原始树形数据
|
|
|
- rankGroupOptions.value = res.data;
|
|
|
- // 打平用于下拉显示
|
|
|
- flatRankGroupOptions.value = flattenTree(res.data);
|
|
|
+ rankGroupOptions.value = res.rows;
|
|
|
} catch (error) {
|
|
|
console.error('获取分组列表失败:', error);
|
|
|
}
|