From f04f35b562760afbac0c477357e2a29f77aec3b9 Mon Sep 17 00:00:00 2001 From: lrj <owen.stl@gmail.com> Date: 星期四, 02 十月 2025 13:51:47 +0800 Subject: [PATCH] fix: 修复评审次数重复显示问题 --- web/src/views/next-list.vue | 192 ++++++++++++----------------------------------- 1 files changed, 49 insertions(+), 143 deletions(-) diff --git a/web/src/views/next-list.vue b/web/src/views/next-list.vue index 6d65381..addeb22 100644 --- a/web/src/views/next-list.vue +++ b/web/src/views/next-list.vue @@ -270,62 +270,19 @@ const loadData = async () => { loading.value = true try { - // 灏濊瘯浣跨敤鐪熷疄API const data = await PromotionApi.getPromotionCompetitions({ name: searchForm.name, page: pagination.page, size: pagination.size }) - competitions.value = data - pagination.total = data.length + competitions.value = data || [] + pagination.total = data ? data.length : 0 } catch (error) { - console.warn('API璋冪敤澶辫触锛屼娇鐢ㄦā鎷熸暟鎹�:', error) - - // API澶辫触鏃朵娇鐢ㄦā鎷熸暟鎹� - const mockData = [ - { - id: 1, - competitionName: '2027鍒涙柊鍒涗笟澶ц禌', - stageName: '绗竴闃舵', - maxParticipants: null, - currentCount: 15, - status: 1, - startTime: '2024-01-01T00:00:00', - endTime: '2024-03-31T23:59:59' - }, - { - id: 2, - competitionName: '2027鍒涙柊鍒涗笟澶ц禌', - stageName: '绗簩闃舵', - maxParticipants: 50, - currentCount: 8, - status: 1, - startTime: '2024-04-01T00:00:00', - endTime: '2024-06-30T23:59:59' - }, - { - id: 3, - competitionName: '2027鍒涙柊鍒涗笟澶ц禌', - stageName: '绗笁闃舵', - maxParticipants: 10, - currentCount: 0, - status: 0, - startTime: '2024-07-01T00:00:00', - endTime: '2024-08-31T23:59:59' - } - ] - - let filteredData = mockData - if (searchForm.name) { - filteredData = mockData.filter(item => - item.competitionName.includes(searchForm.name) || - item.stageName.includes(searchForm.name) - ) - } - - competitions.value = filteredData - pagination.total = filteredData.length + console.error('鑾峰彇姣旇禌鏅嬬骇鍒楄〃澶辫触:', error) + ElMessage.error('鑾峰彇姣旇禌鏁版嵁澶辫触: ' + (error.message || '鏈煡閿欒')) + competitions.value = [] + pagination.total = 0 } finally { loading.value = false } @@ -380,59 +337,37 @@ const loadPromotableParticipants = async (currentStageId) => { participantsLoading.value = true try { - // 浣跨敤鏂扮殑API鑾峰彇鍙檵绾у弬璧涜�� const data = await PromotionApi.getPromotableParticipants(currentStageId) - promotableData.value = data - originalParticipants.value = data.participants - participants.value = data.participants - } catch (error) { - console.warn('鑾峰彇鍙檵绾у弬璧涜�匒PI澶辫触锛屼娇鐢ㄦā鎷熸暟鎹�:', error) - // API澶辫触鏃朵娇鐢ㄦā鎷熸暟鎹� - const mockData = { - participants: [ - { - id: 1, - playerId: 101, - playerName: 'UK2025', - projectName: '鏅鸿兘瀹跺眳绯荤粺', - phone: '13800138001', - averageScore: 85.5, - ratingCount: 3, - applyTime: '2024-01-15T10:30:00', - state: 1 - }, - { - id: 2, - playerId: 102, - playerName: '寮犱笁', - projectName: 'AI鍥惧儚璇嗗埆', - phone: '13800138002', - averageScore: 92.0, - ratingCount: 3, - applyTime: '2024-01-16T14:20:00', - state: 1 - }, - { - id: 3, - playerId: 103, - playerName: '鏉庡洓', - projectName: '鍖哄潡閾惧簲鐢�', - phone: '13800138003', - averageScore: 78.3, - ratingCount: 2, - applyTime: '2024-01-17T09:15:00', - state: 1 - } - ], - selectableCount: 10, - totalCount: 15, - previousStageName: '绗竴闃舵', - currentStageName: '绗簩闃舵' + if (data) { + promotableData.value = data + originalParticipants.value = data.participants || [] + participants.value = data.participants || [] + } else { + // 濡傛灉娌℃湁鏁版嵁锛屽垵濮嬪寲涓虹┖ + promotableData.value = { + participants: [], + selectableCount: 0, + totalCount: 0, + previousStageName: '', + currentStageName: '' + } + originalParticipants.value = [] + participants.value = [] } + } catch (error) { + console.error('鑾峰彇鍙檵绾у弬璧涜�呭け璐�:', error) + ElMessage.error('鑾峰彇鍙檵绾у弬璧涜�呮暟鎹け璐�: ' + (error.message || '鏈煡閿欒')) - promotableData.value = mockData - originalParticipants.value = mockData.participants - participants.value = mockData.participants + // 閿欒鏃跺垵濮嬪寲涓虹┖鏁版嵁 + promotableData.value = { + participants: [], + selectableCount: 0, + totalCount: 0, + previousStageName: '', + currentStageName: '' + } + originalParticipants.value = [] + participants.value = [] } finally { participantsLoading.value = false } @@ -442,43 +377,12 @@ const loadParticipants = async (competitionId) => { participantsLoading.value = true try { - // 灏濊瘯浣跨敤鐪熷疄API鑾峰彇鍙傝禌浜哄憳 const participantsData = await PromotionApi.getCompetitionParticipants(competitionId) - participants.value = participantsData + participants.value = participantsData || [] } catch (error) { - console.warn('鑾峰彇鍙傝禌浜哄憳API澶辫触锛屼娇鐢ㄦā鎷熸暟鎹�:', error) - // API澶辫触鏃朵娇鐢ㄦā鎷熸暟鎹� - const mockParticipants = [ - { - id: 1, - playerName: 'UK2025', - projectName: '鏅鸿兘瀹跺眳绯荤粺', - phone: '13800138001', - averageScore: 85.5, - ratingCount: 3, - applyTime: '2024-01-15T10:30:00' - }, - { - id: 2, - playerName: '寮犱笁', - projectName: 'AI鍥惧儚璇嗗埆', - phone: '13800138002', - averageScore: 92.0, - ratingCount: 3, - applyTime: '2024-01-16T14:20:00' - }, - { - id: 3, - playerName: '鏉庡洓', - projectName: '鍖哄潡閾惧簲鐢�', - phone: '13800138003', - averageScore: 78.3, - ratingCount: 2, - applyTime: '2024-01-17T09:15:00' - } - ] - - participants.value = mockParticipants + console.error('鑾峰彇鍙傝禌浜哄憳澶辫触:', error) + ElMessage.error('鑾峰彇鍙傝禌浜哄憳鏁版嵁澶辫触: ' + (error.message || '鏈煡閿欒')) + participants.value = [] } finally { participantsLoading.value = false } @@ -510,24 +414,26 @@ promotionLoading.value = true try { - // 灏濊瘯浣跨敤鐪熷疄API鎵ц鏅嬬骇 + // 鎻愬彇鍙傝禌鑰匢D const participantIds = selectedParticipants.value.map(p => p.id) + const result = await PromotionApi.promoteParticipants( selectedCompetition.value.id, participantIds, null // 鐩爣闃舵ID锛岃繖閲屽彲浠ユ牴鎹渶瑕佽缃� ) - ElMessage.success(result.message || `鎴愬姛鏅嬬骇 ${result.promotedCount} 鍚嶄汉鍛榒) + if (result && result.success) { + ElMessage.success(result.message || `鎴愬姛鏅嬬骇 ${result.promotedCount} 鍚嶄汉鍛榒) + handlePromotionDialogClose() + loadData() // 閲嶆柊鍔犺浇鏁版嵁 + } else { + ElMessage.error(result?.message || '鏅嬬骇鎿嶄綔澶辫触') + } } catch (error) { - console.warn('鏅嬬骇API澶辫触锛屼娇鐢ㄦā鎷熸搷浣�:', error) - // API澶辫触鏃舵ā鎷熸垚鍔� - await new Promise(resolve => setTimeout(resolve, 1000)) - ElMessage.success(`鎴愬姛鏅嬬骇 ${selectedParticipants.value.length} 鍚嶄汉鍛榒) + console.error('鏅嬬骇鎿嶄綔澶辫触:', error) + ElMessage.error('鏅嬬骇鎿嶄綔澶辫触: ' + (error.message || '鏈煡閿欒')) } - - handlePromotionDialogClose() - loadData() // 閲嶆柊鍔犺浇鏁版嵁 } catch { // 鐢ㄦ埛鍙栨秷 } finally { -- Gitblit v1.8.0