lrj
1 天以前 93eb6b470773bc49ea6e1a9d4cbd914eb95d525b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
<template>
  <div class="review-container">
    <el-card>
      <template #header>
        <div class="card-header">
          <h3 class="card-title">项目评审</h3>
        </div>
      </template>
 
      <el-form :inline="true" class="search-form">
        <el-form-item label="选择比赛">
          <el-select
            v-model="selectedActivity"
            placeholder="请选择比赛"
            @change="handleActivityChange"
            style="width: 300px"
            clearable
            filterable
          >
            <el-option
              v-for="activity in activities"
              :key="activity.id"
              :label="getActivityDisplayName(activity)"
              :value="activity.id"
            >
              <span>{{ getActivityName(activity) }}</span>
              <span v-if="activity.pid > 0" style="color: #409eff; margin-left: 8px;">
                {{ activity.name }}
              </span>
            </el-option>
          </el-select>
        </el-form-item>
        
        <el-form-item label="项目名称">
          <el-input
            v-model="searchName"
            placeholder="请输入项目名称"
            @keyup.enter="loadProjects"
            style="width: 200px"
          />
        </el-form-item>
        
        <el-form-item>
          <el-button type="primary" @click="loadProjects" :loading="projectsLoading">
            搜索
          </el-button>
          <el-button @click="resetSearch">重置</el-button>
        </el-form-item>
      </el-form>
 
      <el-table 
        :data="projects" 
        style="width: 100%" 
        v-loading="projectsLoading"
        empty-text="请先选择比赛"
      >
        <el-table-column prop="playerName" label="项目名称" min-width="150">
          <template #default="scope">
            {{ scope.row.projectName || scope.row.playerName }}
          </template>
        </el-table-column>
        <el-table-column prop="playerName" label="参赛人姓名" min-width="120" />
        <el-table-column prop="phone" label="联系电话" min-width="120" />
        <el-table-column prop="ratingCount" label="评审次数" width="100" align="center">
          <template #default="scope">
            <el-tag :type="scope.row.ratingCount > 0 ? 'success' : 'info'">
              {{ scope.row.ratingCount }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="averageScore" label="平均分" width="100" align="center">
          <template #default="scope">
            <span v-if="scope.row.averageScore > 0" class="score">
              {{ scope.row.averageScore.toFixed(1) }}
            </span>
            <span v-else class="no-score">未评分</span>
          </template>
        </el-table-column>
        <el-table-column prop="applyTime" label="报名时间" width="180">
          <template #default="scope">
            {{ formatDate(scope.row.applyTime) }}
          </template>
        </el-table-column>
        <el-table-column prop="state" label="状态" width="100" align="center">
          <template #default="scope">
            <el-tag :type="getStateType(scope.row.state)">
              {{ getStateName(scope.row.state) }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="120" fixed="right">
          <template #default="scope">
            <el-button type="primary" link @click="viewDetails(scope.row.id)">
              详情评审
            </el-button>
          </template>
        </el-table-column>
      </el-table>
 
      <!-- 分页 -->
      <div class="pagination-container" v-if="total > 0">
        <el-pagination
          v-model:current-page="currentPage"
          v-model:page-size="pageSize"
          :page-sizes="[10, 20, 50, 100]"
          :total="total"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
    </el-card>
  </div>
</template>
 
<script setup>
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import { getActiveActivities, getCompetitionProjects } from '@/api/projectReview'
 
const router = useRouter()
 
// 响应式数据
const activities = ref([])
const selectedActivity = ref(null)
const projects = ref([])
const searchName = ref('')
const activitiesLoading = ref(false)
const projectsLoading = ref(false)
 
// 分页数据
const currentPage = ref(1)
const pageSize = ref(10)
const total = ref(0)
 
// 加载比赛列表
const loadActivities = async () => {
  activitiesLoading.value = true
  try {
    const data = await getActiveActivities()
    activities.value = data
  } catch (error) {
    ElMessage.error(error.message)
  } finally {
    activitiesLoading.value = false
  }
}
 
// 加载项目列表
const loadProjects = async () => {
  if (!selectedActivity.value) {
    ElMessage.warning('请先选择比赛')
    return
  }
  
  projectsLoading.value = true
  try {
    const response = await getCompetitionProjects(
      selectedActivity.value,
      currentPage.value - 1, // 后端从0开始
      pageSize.value,
      searchName.value
    )
    
    projects.value = response.content || []
    total.value = response.totalElements || 0
  } catch (error) {
    console.error('加载项目列表失败:', error)
    ElMessage.error('加载项目列表失败')
    // 如果API调用失败,显示空数据
    projects.value = []
    total.value = 0
  } finally {
    projectsLoading.value = false
  }
}
 
// 处理比赛选择变化
const handleActivityChange = (activityId) => {
  currentPage.value = 1
  loadProjects()
}
 
// 重置搜索
const resetSearch = () => {
  searchName.value = ''
  currentPage.value = 1
  if (selectedActivity.value) {
    loadProjects()
  }
}
 
// 分页处理
const handleSizeChange = (size) => {
  pageSize.value = size
  currentPage.value = 1
  loadProjects()
}
 
const handleCurrentChange = (page) => {
  currentPage.value = page
  loadProjects()
}
 
// 查看详情
const viewDetails = (projectId) => {
  router.push(`/project-review/${projectId}/detail`)
}
 
// 格式化日期
const formatDate = (dateString) => {
  if (!dateString) return '-'
  return new Date(dateString).toLocaleString('zh-CN')
}
 
// 获取状态类型
const getStateType = (state) => {
  const stateMap = {
    0: 'danger',  // 已拒绝
    1: 'warning', // 待审核
    2: 'success', // 已通过
    3: 'info'     // 已结束
  }
  return stateMap[state] || 'info'
}
 
// 获取状态名称
const getStateName = (state) => {
  const stateMap = {
    0: '已拒绝',
    1: '待评审',
    2: '已通过',
    3: '已结束'
  }
  return stateMap[state] || '未知'
}
 
// 获取比赛名称(如果是阶段,返回父比赛名称;如果是比赛,返回自己的名称)
const getActivityName = (activity) => {
  if (activity.pid > 0 && activity.parent) {
    return activity.parent.name
  }
  return activity.name
}
 
// 获取活动显示名称(用于搜索和选中时显示)
const getActivityDisplayName = (activity) => {
  if (activity.pid > 0 && activity.parent) {
    return `${activity.parent.name} - ${activity.name}`
  }
  return activity.name
}
 
// 获取阶段名称(如果是阶段,返回阶段名称;如果是比赛,返回比赛名称)
const getStageName = (activity) => {
  return activity.name
}
 
// 组件挂载时加载数据
onMounted(() => {
  loadActivities()
})
</script>
 
<style scoped>
.review-container {
  padding: 20px;
}
 
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
 
.card-title {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
}
 
.search-form {
  margin-bottom: 20px;
  padding: 20px;
  background-color: #f5f7fa;
  border-radius: 4px;
}
 
.score {
  color: #67c23a;
  font-weight: 600;
}
 
.no-score {
  color: #909399;
  font-style: italic;
}
 
.pagination-container {
  margin-top: 20px;
  display: flex;
  justify-content: center;
}
 
:deep(.el-table) {
  border-radius: 4px;
}
 
:deep(.el-table th) {
  background-color: #fafafa;
}
 
:deep(.el-tag) {
  border-radius: 12px;
}
</style>