|
@@ -82,10 +82,24 @@
|
|
|
|
|
|
<el-table-column label="状态" align="center" prop="status" v-if="columns[4].visible">
|
|
|
<template #default="scope">
|
|
|
- <el-select v-model="scope.row.status" placeholder="请选择状态">
|
|
|
- <el-option label="进行中" value="0"></el-option>
|
|
|
- <el-option label="完赛" value="1"></el-option>
|
|
|
- </el-select>
|
|
|
+ <el-tag :type="getStatusType(scope.row)">
|
|
|
+ {{ getStatusText(scope.row) }}
|
|
|
+ </el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="参赛总人/队数" align="center" prop="totalParticipants" v-if="columns[7].visible">
|
|
|
+ <template #default="scope">
|
|
|
+ {{ scope.row.totalParticipants || 0 }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="完赛人/队数" align="center" prop="completedParticipants" v-if="columns[8].visible">
|
|
|
+ <template #default="scope">
|
|
|
+ {{ scope.row.completedParticipants || 0 }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="未完赛人/队数" align="center" prop="incompleteParticipants" v-if="columns[9].visible">
|
|
|
+ <template #default="scope">
|
|
|
+ {{ scope.row.incompleteParticipants || 0 }}
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="比赛时间" align="center" prop="startTime" v-if="columns[5].visible" />
|
|
@@ -155,6 +169,9 @@ const columns = ref<FieldOption[]>([
|
|
|
{ key: 4, label: '状态', visible: true },
|
|
|
{ key: 5, label: '比赛时间', visible: true },
|
|
|
{ key: 6, label: '更新时间', visible: true },
|
|
|
+ { key: 7, label: '参赛总人数', visible: true },
|
|
|
+ { key: 8, label: '完赛人数', visible: true },
|
|
|
+ { key: 9, label: '未完赛人数', visible: true },
|
|
|
]);
|
|
|
|
|
|
// 下拉框数据
|
|
@@ -710,6 +727,38 @@ const getProjectTypeName = (type: string) => {
|
|
|
return typeItem ? typeItem.label : '未知';
|
|
|
};
|
|
|
|
|
|
+/**
|
|
|
+ * 获取状态文本
|
|
|
+ */
|
|
|
+const getStatusText = (row: any) => {
|
|
|
+ const totalParticipants = row.totalParticipants || 0;
|
|
|
+ const completedParticipants = row.completedParticipants || 0;
|
|
|
+
|
|
|
+ // 如果完赛人/队数等于参赛总人/队数,显示完赛
|
|
|
+ if (totalParticipants > 0 && completedParticipants === totalParticipants) {
|
|
|
+ return '完赛';
|
|
|
+ }
|
|
|
+
|
|
|
+ // 否则显示进行中
|
|
|
+ return '进行中';
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取状态标签类型
|
|
|
+ */
|
|
|
+const getStatusType = (row: any) => {
|
|
|
+ const totalParticipants = row.totalParticipants || 0;
|
|
|
+ const completedParticipants = row.completedParticipants || 0;
|
|
|
+
|
|
|
+ // 如果完赛人/队数等于参赛总人/队数,显示成功状态
|
|
|
+ if (totalParticipants > 0 && completedParticipants === totalParticipants) {
|
|
|
+ return 'success';
|
|
|
+ }
|
|
|
+
|
|
|
+ // 否则显示警告状态
|
|
|
+ return 'warning';
|
|
|
+};
|
|
|
+
|
|
|
const exportScoresNames = () => {
|
|
|
// 获取默认赛事ID
|
|
|
const event = gameEventStore.defaultEventInfo;
|
|
@@ -740,6 +789,9 @@ const loadProjects = async () => {
|
|
|
const res = await listGameEventProject(queryParams.value);
|
|
|
projectList.value = res.rows;
|
|
|
total.value = res.total;
|
|
|
+
|
|
|
+ // 为每个项目计算参赛人数
|
|
|
+ await calculateParticipantCounts();
|
|
|
} catch (error) {
|
|
|
console.error('加载项目列表失败:', error);
|
|
|
proxy?.$modal.msgError('加载项目列表失败');
|
|
@@ -748,6 +800,61 @@ const loadProjects = async () => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+/**
|
|
|
+ * 计算每个项目的参赛人数
|
|
|
+ */
|
|
|
+const calculateParticipantCounts = async () => {
|
|
|
+ for (const project of projectList.value) {
|
|
|
+ try {
|
|
|
+ // 获取该项目的成绩数据
|
|
|
+ const scoreRes = await getProjectScoreData({
|
|
|
+ eventId: project.eventId,
|
|
|
+ projectId: project.projectId,
|
|
|
+ classification: project.classification,
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 1000
|
|
|
+ });
|
|
|
+
|
|
|
+ const scores = scoreRes.rows || [];
|
|
|
+
|
|
|
+ // 计算参赛总人数(去重后的队伍或运动员数量)
|
|
|
+ const uniqueParticipants = new Set();
|
|
|
+ scores.forEach(score => {
|
|
|
+ if (project.classification === '0') {
|
|
|
+ // 个人项目:按运动员ID去重
|
|
|
+ if (score.athleteId) {
|
|
|
+ uniqueParticipants.add(score.athleteId);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 团体项目:按队伍ID去重
|
|
|
+ if (score.teamId) {
|
|
|
+ uniqueParticipants.add(score.teamId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 使用类型断言添加新属性
|
|
|
+ (project as any).totalParticipants = uniqueParticipants.size;
|
|
|
+
|
|
|
+ // 计算完赛人数(有成绩记录的)
|
|
|
+ const completedScores = scores.filter(score =>
|
|
|
+ score.individualPerformance || score.teamPerformance
|
|
|
+ );
|
|
|
+ (project as any).completedParticipants = completedScores.length;
|
|
|
+
|
|
|
+ // 计算未完赛人数
|
|
|
+ (project as any).incompleteParticipants = (project as any).totalParticipants - (project as any).completedParticipants;
|
|
|
+
|
|
|
+ } catch (error) {
|
|
|
+ console.error(`计算项目 ${project.projectName} 参赛人数失败:`, error);
|
|
|
+ // 设置默认值
|
|
|
+ (project as any).totalParticipants = 0;
|
|
|
+ (project as any).completedParticipants = 0;
|
|
|
+ (project as any).incompleteParticipants = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
/** 搜索按钮操作 */
|
|
|
const handleQuery = () => {
|
|
|
queryParams.value.pageNum = 1;
|