lrj
10 小时以前 f04f35b562760afbac0c477357e2a29f77aec3b9
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('获取可晋级参赛者API失败,使用模拟数据:', 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执行晋级
      // 提取参赛者ID
      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 {