Jelajahi Sumber

feat(gameEventProject): 新增项目下拉选项接口并优化排行榜页面

新增 getProjectOptionList 接口用于查询项目下拉选项列表,
优化 RankingBoardPage 页面中项目选项加载逻辑,
移除不必要的分页参数和排序参数,
统一使用精简数据结构。

BREAKING CHANGE: 接口返回数据结构调整为 res.data
zhou 2 minggu lalu
induk
melakukan
f9fb23e8de

+ 12 - 0
src/api/system/gameEventProject/index.ts

@@ -108,3 +108,15 @@ export const getEventProjectCount = () => {
     method: 'get'
   });
 };
+
+/**
+ * 查询项目下拉选项列表(精简数据)
+ * @param query
+ */
+export const getProjectOptionList = (query?: any): AxiosPromise<any[]> => {
+  return request({
+    url: '/system/gameEventProject/optionList',
+    method: 'get',
+    params: query
+  });
+};

+ 4 - 67
src/views/system/gameEvent/RankingBoardPage.vue

@@ -238,7 +238,7 @@
 <script setup lang="ts">
 import { ref, computed, onMounted, onUnmounted, getCurrentInstance, toRefs } from 'vue';
 import { getProjectScoreData, getRankingBoardData, updateBonusData, exportBonusExcel } from '@/api/system/gameScore';
-import { listGameEventProject } from '@/api/system/gameEventProject';
+import { listGameEventProject, getProjectOptionList } from '@/api/system/gameEventProject';
 import { getProjectProgress } from '@/api/system/gameEvent/projectProgress';
 import { ProjectProgressVo, GroupProgressVo } from '@/api/system/gameEvent/types';
 import { useGameEventStore } from '@/store/modules/gameEvent';
@@ -443,14 +443,10 @@ const loadRankGroupOptions = async () => {
 // 获取项目选项(个人和团队)
 const loadProjectOptions = async () => {
   try {
-    const res = await listGameEventProject({
-      eventId: defaultEventInfo.value.eventId,
-      orderByColumn: 'createTime',
-      isAsc: 'desc',
-      pageNum: 1,
-      pageSize: 1000
+    const res = await getProjectOptionList({
+      eventId: defaultEventInfo.value.eventId
     });
-    const allProjects = res.rows || [];
+    const allProjects = res.data || [];
     
     // 个人项目过滤
     personalProjectOptions.value = allProjects.filter(p => p.classification === '0');
@@ -480,65 +476,6 @@ const handleTeamProjectChange = (projectId: string | number) => {
   refreshTeamRanking();
 };
 
-// 加载项目进度信息
-const loadProjectProgress = async () => {
-  try {
-    const res = await getProjectProgress(defaultEventInfo.value.eventId);
-    projectProgress.value = res.data || [];
-    
-    // 计算已完成和总任务数
-    let completed = 0;
-    let total = 0;
-    
-    projectProgress.value.forEach(project => {
-      if (project.groups && project.groups.length > 0) {
-        // 有组别的项目,统计组别
-        project.groups.forEach(group => {
-          total++;
-          if (group.status === '2') { // 已完成
-            completed++;
-          }
-        });
-      } else {
-        // 没有组别的项目,直接统计项目
-        total++;
-        if (project.status === '2') { // 已完成
-          completed++;
-        }
-      }
-    });
-    
-    completedTasks.value = completed;
-    totalTasks.value = total;
-    
-    // 前端也可以做一次排序确保,虽然后端已经排序了
-    // 按完整时间排序(项目时间或最早组别时间)
-    projectProgress.value.sort((a, b) => {
-      const getEarliestTime = (project: ProjectProgressVo) => {
-        if (project.groups && project.groups.length > 0) {
-          // 有组别,找到最早的组别时间
-          const groupTimes = project.groups
-            .map(g => g.beginTime ? new Date(g.beginTime).getTime() : 0)
-            .filter(time => time > 0);
-          if (groupTimes.length > 0) {
-            return Math.min(...groupTimes);
-          }
-        }
-        // 没有组别或组别时间无效,使用项目时间
-        return project.startTime ? new Date(project.startTime).getTime() : 0;
-      };
-      
-      const aTime = getEarliestTime(a);
-      const bTime = getEarliestTime(b);
-      
-      return aTime - bTime;
-    });
-  } catch (error) {
-    console.error('加载项目进度失败:', error);
-  }
-};
-
-
 // 获取排名显示文本
 const getRankDisplay = (item: any, index: number, list: any[]) => {
   if (item.rank === '-' || item.rank === undefined || item.rank === null || item.rank === 0 || item.rank === '0') {