From c4938f6f4e839890b032c75c7a57333a6a9157a9 Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期四, 06 十一月 2025 17:06:10 +0800
Subject: [PATCH] 添加新闻功能
---
web/src/views/next-list.vue | 215 ++++++++++++++++-------------------------------------
1 files changed, 65 insertions(+), 150 deletions(-)
diff --git a/web/src/views/next-list.vue b/web/src/views/next-list.vue
index 6d65381..4158bf8 100644
--- a/web/src/views/next-list.vue
+++ b/web/src/views/next-list.vue
@@ -27,7 +27,6 @@
<el-icon><Search /></el-icon>
鎼滅储
</el-button>
- <el-button @click="resetSearch">閲嶇疆</el-button>
</div>
</div>
@@ -222,6 +221,7 @@
import { ElMessage, ElMessageBox } from 'element-plus'
import { Search, TrophyBase, InfoFilled } from '@element-plus/icons-vue'
import PromotionApi from '@/api/promotion'
+import { getActivity } from '@/api/activity'
const router = useRouter()
@@ -270,62 +270,26 @@
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
- } 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)
- )
+ // 澶勭悊鍒嗛〉鍝嶅簲瀵硅薄
+ if (data && data.content) {
+ competitions.value = data.content
+ pagination.total = parseInt(data.totalElements) || 0
+ } else {
+ // 鍏煎鏃х殑杩斿洖鏍煎紡锛堝鏋滃悗绔繕娌℃洿鏂帮級
+ competitions.value = data || []
+ pagination.total = data ? data.length : 0
}
-
- competitions.value = filteredData
- pagination.total = filteredData.length
+ } catch (error) {
+ console.error('鑾峰彇姣旇禌鏅嬬骇鍒楄〃澶辫触:', error)
+ ElMessage.error('鑾峰彇姣旇禌鏁版嵁澶辫触: ' + (error.message || '鏈煡閿欒'))
+ competitions.value = []
+ pagination.total = 0
} finally {
loading.value = false
}
@@ -380,59 +344,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 +384,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
}
@@ -488,6 +399,8 @@
const handleSelectionChange = (selection) => {
selectedParticipants.value = selection
}
+
+
// 纭鏅嬬骇
const confirmPromotion = async () => {
@@ -510,24 +423,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} 鍚嶄汉鍛榒)
+ const result = await PromotionApi.promoteParticipants(
+ selectedCompetition.value.competitionId, // 涓绘瘮璧汭D
+ participantIds,
+ selectedCompetition.value.id // 褰撳墠闃舵ID浣滀负鐩爣闃舵ID
+ )
+
+ 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 {
@@ -652,7 +567,7 @@
.search-toolbar {
display: flex;
align-items: center;
- justify-content: space-between;
+ justify-content: flex-end;
margin-bottom: 20px;
padding: 16px;
background-color: #f9fafb;
--
Gitblit v1.8.0