|
@@ -3,29 +3,54 @@
|
|
|
<!-- 新增:顶部搜索框 -->
|
|
|
<div class="flex items-center mb-4">
|
|
|
<el-button type="primary" @click="refreshData"><el-icon><Refresh /></el-icon> 刷新</el-button>
|
|
|
- <el-input v-model="searchValue" placeholder="输入姓名搜索" style="margin-left: 20px; width: 200px;" clearable @keyup.enter="loadAthleteScores">
|
|
|
+ <el-button type="success" @click="calculateRankings" :loading="rankingLoading">
|
|
|
+ <el-icon><Trophy /></el-icon> 计算排名
|
|
|
+ </el-button>
|
|
|
+ <el-input
|
|
|
+ v-model="searchValue"
|
|
|
+ :placeholder="projectClassification === '0' ? '输入运动员姓名搜索' : '输入队伍名称搜索'"
|
|
|
+ style="margin-left: 20px; width: 200px;"
|
|
|
+ clearable
|
|
|
+ @keyup.enter="loadData">
|
|
|
<template #prefix>
|
|
|
<el-icon><Search /></el-icon>
|
|
|
</template>
|
|
|
</el-input>
|
|
|
+ <div class="ml-4 text-gray-600">
|
|
|
+ <el-tag :type="projectClassification === '0' ? 'success' : 'warning'" class="mr-2">
|
|
|
+ {{ projectClassification === '0' ? '个人项目' : '团体项目' }}
|
|
|
+ </el-tag>
|
|
|
+ <span>{{ projectClassification === '0' ? '管理运动员个人成绩' : '管理队伍团队成绩' }}</span>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
|
|
|
<el-card shadow="never">
|
|
|
- <el-table v-loading="loading" border :data="athleteScores">
|
|
|
+ <el-table v-loading="loading" border :data="dataList">
|
|
|
<el-table-column type="selection" width="55" align="center" />
|
|
|
- <el-table-column label="ID" align="center" prop="projectId" />
|
|
|
+ <el-table-column label="队伍ID" align="center" prop="teamId" />
|
|
|
<el-table-column label="项目" align="center" prop="projectName" />
|
|
|
- <!-- <el-table-column label="分组" align="center" prop="groupType" /> -->
|
|
|
<el-table-column label="项目类型" align="center" prop="projectType" >
|
|
|
<template #default="scope">
|
|
|
<dict-tag :options="game_project_type" :value="scope.row.projectType" />
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="单位" align="center" prop="unit" />
|
|
|
- <el-table-column label="姓名" align="center" prop="name" />
|
|
|
- <el-table-column label="号码" align="center" prop="athleteCode" />
|
|
|
+ <el-table-column label="队伍名称" align="center" prop="teamName" />
|
|
|
+
|
|
|
+ <!-- 个人项目显示运动员信息 -->
|
|
|
+ <template v-if="projectClassification === '0'">
|
|
|
+ <el-table-column label="姓名" align="center" prop="name" />
|
|
|
+ <el-table-column label="号码" align="center" prop="athleteCode" />
|
|
|
+ <el-table-column label="个人成绩" align="center" prop="individualPerformance" />
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <!-- 团体项目显示队伍信息 -->
|
|
|
+ <template v-else>
|
|
|
+ <!-- <el-table-column label="队伍名称" align="center" prop="teamName" /> -->
|
|
|
+ <!-- <el-table-column label="队伍编号" align="center" prop="teamCode" /> -->
|
|
|
+ <el-table-column label="团队成绩" align="center" prop="teamPerformance" />
|
|
|
+ </template>
|
|
|
+
|
|
|
<el-table-column label="积分" align="center" prop="scorePoint" />
|
|
|
- <el-table-column label="成绩" align="center" prop="scoreValue" />
|
|
|
<el-table-column label="排名" align="center" prop="scoreRank" />
|
|
|
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
|
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
@@ -39,17 +64,33 @@
|
|
|
</el-card>
|
|
|
|
|
|
<!-- 添加或修改裁判对话框 -->
|
|
|
- <el-dialog :title="dialog.title" v-model="dialog.visible" width="800px" append-to-body>
|
|
|
+ <el-dialog :title="dialog.title" v-model="dialog.visible" width="400px" append-to-body>
|
|
|
<el-form ref="scoreFormRef" :model="form" :rules="rules" label-width="80px">
|
|
|
- <el-form-item label="积分" prop="scorePoint">
|
|
|
- <el-input v-model="form.scorePoint" placeholder="输入积分" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="成绩" prop="scoreValue">
|
|
|
- <el-input v-model="form.scoreValue" placeholder="输入成绩" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="排名" prop="scoreRank">
|
|
|
- <el-input v-model="form.scoreRank" placeholder="输入排名" />
|
|
|
- </el-form-item>
|
|
|
+ <!-- 个人项目显示个人成绩字段 -->
|
|
|
+ <template v-if="projectClassification === '0'">
|
|
|
+ <el-form-item label="个人成绩" prop="individualPerformance">
|
|
|
+ <el-input
|
|
|
+ v-model="form.individualPerformance"
|
|
|
+ placeholder="输入个人成绩"
|
|
|
+ type="number"
|
|
|
+ step="0.01"
|
|
|
+ @input="handleIndividualPerformanceInput"
|
|
|
+ @blur="handleIndividualPerformanceBlur" />
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <!-- 团体项目显示团队成绩字段 -->
|
|
|
+ <template v-else>
|
|
|
+ <el-form-item label="团队成绩" prop="teamPerformance">
|
|
|
+ <el-input
|
|
|
+ v-model="form.teamPerformance"
|
|
|
+ placeholder="输入团队成绩"
|
|
|
+ type="number"
|
|
|
+ step="0.01"
|
|
|
+ @input="handleTeamPerformanceInput"
|
|
|
+ @blur="handleTeamPerformanceBlur" />
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
</el-form>
|
|
|
<template #footer>
|
|
|
<div class="dialog-footer">
|
|
@@ -59,15 +100,14 @@
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
|
|
|
- <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="loadAthleteScores" />
|
|
|
+ <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="handlePagination({page: queryParams.pageNum, limit: queryParams.pageSize})" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup name="GameScoreEdit" lang="ts">
|
|
|
import { onMounted, ref } from 'vue';
|
|
|
import { useRoute } from 'vue-router';
|
|
|
-import { listGameAthlete } from '@/api/system/gameAthlete/index';
|
|
|
-import { listGameScore, delGameScore, getGameScore, addGameScore, updateGameScore } from '@/api/system/gameScore/index';
|
|
|
+import { getProjectScoreData, updateScoreAndRecalculate } from '@/api/system/gameScore/index';
|
|
|
import { GameScoreForm } from '@/api/system/gameScore/types';
|
|
|
import Pagination from '@/components/Pagination/index.vue';
|
|
|
|
|
@@ -76,43 +116,19 @@ const { game_project_type } = toRefs<any>(proxy?.useDict('game_project_type'));
|
|
|
|
|
|
const route = useRoute();
|
|
|
const buttonLoading = ref(false);
|
|
|
-const athleteScores = ref<AthleteScore[]>([]);
|
|
|
+const rankingLoading = ref(false);
|
|
|
+const dataList = ref<any[]>([]);
|
|
|
const loading = ref(true);
|
|
|
const total = ref(0);
|
|
|
|
|
|
// 定义搜索框状态变量
|
|
|
const searchValue = ref('');
|
|
|
|
|
|
-// 定义一个简化版的类型,只包含需要的属性
|
|
|
-interface AthleteScore {
|
|
|
- // GameAthleteVO 属性
|
|
|
- athleteId?: string | number;
|
|
|
- userId?: string | number;
|
|
|
- eventId?: string | number;
|
|
|
- teamId?: string | number;
|
|
|
- athleteCode?: string;
|
|
|
- name?: string;
|
|
|
- unit?: string;
|
|
|
- groupType?: string;
|
|
|
- number?: string;
|
|
|
- // GameEventProjectVO 属性 (排除scoreValue)
|
|
|
- projectId?: string | number;
|
|
|
- projectName?: string;
|
|
|
- projectType?: string;
|
|
|
- startTime?: string;
|
|
|
- endTime?: string;
|
|
|
- // GameScoreVO 属性
|
|
|
- scoreId?: string | number;
|
|
|
- scoreValue?: number;
|
|
|
- scoreRank?: number;
|
|
|
- scorePoint?: number;
|
|
|
- updateTime?: string;
|
|
|
-}
|
|
|
-
|
|
|
const eventId = route.params.eventId as string;
|
|
|
const projectId = route.params.projectId as string;
|
|
|
const projectName = route.params.projectName as string;
|
|
|
const projectType = route.params.projectType as string;
|
|
|
+const projectClassification = route.params.classification as string || '0'; // 默认为个人项目
|
|
|
|
|
|
const queryParams = reactive({
|
|
|
pageNum: 1,
|
|
@@ -121,13 +137,42 @@ const queryParams = reactive({
|
|
|
projectId: projectId,
|
|
|
projectName: projectName,
|
|
|
projectType: projectType,
|
|
|
+ classification: projectClassification,
|
|
|
});
|
|
|
|
|
|
//刷新数据方法
|
|
|
const refreshData = () => {
|
|
|
searchValue.value = '';
|
|
|
- loadAthleteScores();
|
|
|
+ loadData(true); // 刷新时自动计算排名
|
|
|
};
|
|
|
+
|
|
|
+// 计算排名方法
|
|
|
+const calculateRankings = async () => {
|
|
|
+ try {
|
|
|
+ rankingLoading.value = true;
|
|
|
+
|
|
|
+ // 调用后端接口重新计算排名和积分
|
|
|
+ await updateScoreAndRecalculate({
|
|
|
+ eventId: eventId,
|
|
|
+ projectId: projectId,
|
|
|
+ scoreType: projectClassification === '0' ? 'individual' : 'team',
|
|
|
+ statusFlag: '0',
|
|
|
+ status: '0',
|
|
|
+ remark: '手动触发排名计算'
|
|
|
+ } as GameScoreForm);
|
|
|
+
|
|
|
+ proxy?.$modal.msgSuccess("排名计算完成");
|
|
|
+
|
|
|
+ // 重新加载数据以显示新的排名和积分
|
|
|
+ await loadData(false); // 不自动计算排名,避免循环
|
|
|
+ } catch (error) {
|
|
|
+ console.error("排名计算失败:", error);
|
|
|
+ proxy?.$modal.msgError("排名计算失败,请稍后再试");
|
|
|
+ } finally {
|
|
|
+ rankingLoading.value = false;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
const scoreFormRef = ref<ElFormInstance>();
|
|
|
const dialog = reactive<DialogOption>({
|
|
|
visible: false,
|
|
@@ -135,150 +180,238 @@ const dialog = reactive<DialogOption>({
|
|
|
});
|
|
|
|
|
|
const form = reactive({
|
|
|
- scorePoint: 0,
|
|
|
- scoreValue: 0.0,
|
|
|
- scoreRank: 0,
|
|
|
+ scorePoint: null,
|
|
|
+ individualPerformance: 0,
|
|
|
+ teamPerformance: 0,
|
|
|
+ scoreRank: null,
|
|
|
scoreId: 0,
|
|
|
+ athleteId: 0,
|
|
|
+ teamId: 0,
|
|
|
+ eventId: '',
|
|
|
+ projectId: '',
|
|
|
+ athleteCode: '',
|
|
|
+ userId: 0,
|
|
|
+ teamName: '', // 个人项目和团体项目都使用
|
|
|
+ updateTime: '',
|
|
|
});
|
|
|
|
|
|
const rules = {
|
|
|
- scorePoint: [
|
|
|
- { required: true, message: "积分不能为空", trigger: "blur" }
|
|
|
- ],
|
|
|
- scoreValue: [
|
|
|
- { required: true, message: "成绩不能为空", trigger: "blur" }
|
|
|
+ individualPerformance: [
|
|
|
+ { required: true, message: "个人成绩不能为空", trigger: "blur" },
|
|
|
+ {
|
|
|
+ validator: (rule: any, value: any, callback: any) => {
|
|
|
+ if (value !== '' && value !== null && value !== undefined) {
|
|
|
+ const numValue = parseFloat(value);
|
|
|
+ if (isNaN(numValue)) {
|
|
|
+ callback(new Error('请输入有效的数字'));
|
|
|
+ } else if (numValue < 0) {
|
|
|
+ callback(new Error('成绩不能为负数'));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ trigger: "blur"
|
|
|
+ }
|
|
|
],
|
|
|
- scoreRank: [
|
|
|
- { required: true, message: "排名不能为空", trigger: "change" }
|
|
|
+ teamPerformance: [
|
|
|
+ { required: true, message: "团队成绩不能为空", trigger: "blur" },
|
|
|
+ {
|
|
|
+ validator: (rule: any, value: any, callback: any) => {
|
|
|
+ if (value !== '' && value !== null && value !== undefined) {
|
|
|
+ const numValue = parseFloat(value);
|
|
|
+ if (isNaN(numValue)) {
|
|
|
+ callback(new Error('请输入有效的数字'));
|
|
|
+ } else if (numValue < 0) {
|
|
|
+ callback(new Error('成绩不能为负数'));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ trigger: "blur"
|
|
|
+ }
|
|
|
],
|
|
|
}
|
|
|
|
|
|
+// 成绩输入处理函数
|
|
|
+const handleIndividualPerformanceInput = (value: string) => {
|
|
|
+ // 确保输入的是有效数字
|
|
|
+ if (value && !isNaN(parseFloat(value))) {
|
|
|
+ form.individualPerformance = parseFloat(value);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const handleIndividualPerformanceBlur = () => {
|
|
|
+ // 失焦时确保数据类型正确
|
|
|
+ if (form.individualPerformance !== null && form.individualPerformance !== undefined) {
|
|
|
+ const numValue = parseFloat(String(form.individualPerformance));
|
|
|
+ if (!isNaN(numValue)) {
|
|
|
+ form.individualPerformance = numValue;
|
|
|
+ } else {
|
|
|
+ form.individualPerformance = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const handleTeamPerformanceInput = (value: string) => {
|
|
|
+ // 确保输入的是有效数字
|
|
|
+ if (value && !isNaN(parseFloat(value))) {
|
|
|
+ form.teamPerformance = parseFloat(value);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const handleTeamPerformanceBlur = () => {
|
|
|
+ // 失焦时确保数据类型正确
|
|
|
+ if (form.teamPerformance !== null && form.teamPerformance !== undefined) {
|
|
|
+ const numValue = parseFloat(String(form.teamPerformance));
|
|
|
+ if (!isNaN(numValue)) {
|
|
|
+ form.teamPerformance = numValue;
|
|
|
+ } else {
|
|
|
+ form.teamPerformance = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
/** 取消按钮 */
|
|
|
const cancel = () => {
|
|
|
- // reset();
|
|
|
dialog.visible = false;
|
|
|
}
|
|
|
+
|
|
|
/** 编辑按钮 */
|
|
|
-const editScore = (row: AthleteScore) => {
|
|
|
+const editScore = (row: any) => {
|
|
|
dialog.visible = true;
|
|
|
- // 将当前行数据复制到编辑表单中
|
|
|
+ // 将当前行数据复制到编辑表单中,确保成绩数据类型正确
|
|
|
Object.assign(form, {
|
|
|
scoreId: row.scoreId,
|
|
|
- scorePoint: row.scorePoint,
|
|
|
- scoreValue: row.scoreValue,
|
|
|
- scoreRank: row.scoreRank,
|
|
|
+ scorePoint: row.scorePoint || null,
|
|
|
+ individualPerformance: parseFloat(String(row.individualPerformance)) || 0,
|
|
|
+ teamPerformance: parseFloat(String(row.teamPerformance)) || 0,
|
|
|
+ scoreRank: row.scoreRank || null,
|
|
|
athleteId: row.athleteId,
|
|
|
+ teamId: row.teamId,
|
|
|
athleteCode: row.athleteCode,
|
|
|
userId: row.userId,
|
|
|
eventId: row.eventId,
|
|
|
- teamId: row.teamId,
|
|
|
projectId: row.projectId,
|
|
|
- unit: row.unit,
|
|
|
+ teamName: row.teamName || '', // 统一使用teamName字段
|
|
|
updateTime: row.updateTime,
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/** 提交按钮 */
|
|
|
-const submitForm = () => {
|
|
|
+const submitForm = async () => {
|
|
|
scoreFormRef.value?.validate(async (valid: boolean) => {
|
|
|
if (valid) {
|
|
|
try {
|
|
|
buttonLoading.value = true;
|
|
|
|
|
|
- // 根据 form 中的数据创建提交对象
|
|
|
- const submitForm: GameScoreForm = {
|
|
|
- ...form,
|
|
|
- // updateTime: new Date().toISOString() // 在提交时设置updateTime
|
|
|
- };
|
|
|
-
|
|
|
- // 调用更新或添加接口
|
|
|
- if (form.scoreId) {
|
|
|
- await updateGameScore(submitForm);
|
|
|
+ // 确保成绩数据类型正确
|
|
|
+ let individualPerformance = 0;
|
|
|
+ let teamPerformance = 0;
|
|
|
+
|
|
|
+ if (projectClassification === '0') {
|
|
|
+ // 个人项目
|
|
|
+ individualPerformance = parseFloat(String(form.individualPerformance)) || 0;
|
|
|
+ if (isNaN(individualPerformance)) {
|
|
|
+ individualPerformance = 0;
|
|
|
+ }
|
|
|
} else {
|
|
|
- await addGameScore(submitForm);
|
|
|
+ // 团体项目
|
|
|
+ teamPerformance = parseFloat(String(form.teamPerformance)) || 0;
|
|
|
+ if (isNaN(teamPerformance)) {
|
|
|
+ teamPerformance = 0;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ // 构建提交数据,确保使用正确的scoreId
|
|
|
+ const submitForm: GameScoreForm = {
|
|
|
+ scoreId: form.scoreId, // 确保使用正确的scoreId
|
|
|
+ scorePoint: form.scorePoint || 0,
|
|
|
+ individualPerformance: individualPerformance,
|
|
|
+ teamPerformance: teamPerformance,
|
|
|
+ scoreRank: form.scoreRank || 0,
|
|
|
+ athleteId: form.athleteId,
|
|
|
+ teamId: form.teamId,
|
|
|
+ eventId: eventId,
|
|
|
+ projectId: projectId,
|
|
|
+ scoreType: projectClassification === '0' ? 'individual' : 'team',
|
|
|
+ statusFlag: '0',
|
|
|
+ status: '0',
|
|
|
+ remark: projectClassification === '0' ? '个人项目成绩' : '团体项目成绩'
|
|
|
+ };
|
|
|
+
|
|
|
+ // 调用后端接口更新成绩并重新计算排名积分
|
|
|
+ await updateScoreAndRecalculate(submitForm);
|
|
|
+
|
|
|
proxy?.$modal.msgSuccess("操作成功");
|
|
|
dialog.visible = false;
|
|
|
- await loadAthleteScores(); // 重新加载数据以反映更改
|
|
|
+ loadData(false); // 提交成功后不自动计算排名,用户需要手动点击排名按钮
|
|
|
} catch (error) {
|
|
|
+ console.error("提交失败:", error);
|
|
|
proxy?.$modal.msgError("操作失败,请稍后再试");
|
|
|
} finally {
|
|
|
buttonLoading.value = false;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
-// 加载运动员成绩列表方法,支持搜索
|
|
|
-const loadAthleteScores = async () => {
|
|
|
+// 加载数据方法,支持搜索
|
|
|
+const loadData = async (autoCalculateRanking = false) => {
|
|
|
loading.value = true;
|
|
|
- const resAthletes = await listGameAthlete({
|
|
|
- eventId: eventId,
|
|
|
- pageNum: queryParams.pageNum,
|
|
|
- pageSize: queryParams.pageSize,
|
|
|
- // 使用name属性替代keyword进行搜索
|
|
|
- name: searchValue.value,
|
|
|
- orderByColumn: '',
|
|
|
- isAsc: ''
|
|
|
- });
|
|
|
- const athletes = resAthletes.rows;
|
|
|
- total.value = resAthletes.total;
|
|
|
-
|
|
|
- const athleteScoresData: AthleteScore[] = [];
|
|
|
-
|
|
|
- for (const athlete of athletes) {
|
|
|
- try {
|
|
|
- // 使用 listGameScore 替换 getGameScore
|
|
|
- const resScores = await listGameScore({
|
|
|
- athleteId: athlete.athleteId,
|
|
|
- pageNum: queryParams.pageNum,
|
|
|
- pageSize: queryParams.pageSize,
|
|
|
- orderByColumn: '',
|
|
|
- isAsc: ''
|
|
|
- });
|
|
|
- const scores = resScores.rows;
|
|
|
-
|
|
|
- // 找到与当前 athleteId 匹配的成绩记录
|
|
|
- const score = scores.find(scoreItem => scoreItem.athleteId === athlete.athleteId);
|
|
|
- //如果运动员的参与项目列表中没有项目,则跳过
|
|
|
- if (athlete.projectValue === null || athlete.projectValue === '') {
|
|
|
- continue;
|
|
|
- }
|
|
|
- athleteScoresData.push({
|
|
|
- ...athlete,
|
|
|
- scoreId: score?.scoreId ?? 0,
|
|
|
- scorePoint: score?.scorePoint ?? 0,
|
|
|
- scoreValue: score?.scoreValue ?? 0.0,
|
|
|
- scoreRank: score?.scoreRank ?? 0,
|
|
|
- updateTime: score?.updateTime ?? '',
|
|
|
- eventId: eventId,
|
|
|
- projectId: projectId, // 直接使用路由传来的 projectId
|
|
|
- projectName: projectName,
|
|
|
- projectType: projectType,
|
|
|
- });
|
|
|
- } catch (error) {
|
|
|
- // 如果获取成绩失败,使用默认值
|
|
|
- athleteScoresData.push({
|
|
|
- ...athlete,
|
|
|
- scoreId: 0,
|
|
|
- scorePoint: 0,
|
|
|
- scoreValue: 0.0,
|
|
|
- scoreRank: 0,
|
|
|
- updateTime: '',
|
|
|
- eventId: eventId,
|
|
|
- projectId: projectId, // 直接使用路由传来的 projectId
|
|
|
- projectName: projectName,
|
|
|
- projectType: projectType,
|
|
|
- });
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 调用后端接口获取综合数据
|
|
|
+ const response = await getProjectScoreData({
|
|
|
+ eventId: eventId,
|
|
|
+ projectId: projectId,
|
|
|
+ classification: projectClassification,
|
|
|
+ searchValue: searchValue.value,
|
|
|
+ pageNum: queryParams.pageNum,
|
|
|
+ pageSize: queryParams.pageSize
|
|
|
+ });
|
|
|
+
|
|
|
+ // 处理返回的数据
|
|
|
+ const rows = response.rows || [];
|
|
|
+
|
|
|
+ // 为每行数据添加项目相关信息
|
|
|
+ dataList.value = rows.map((row: any) => ({
|
|
|
+ ...row,
|
|
|
+ projectName: projectName,
|
|
|
+ projectType: projectType,
|
|
|
+ }));
|
|
|
+
|
|
|
+ total.value = response.total || 0;
|
|
|
+
|
|
|
+ // 只有在自动计算排名的情况下才进行排名计算
|
|
|
+ if (autoCalculateRanking) {
|
|
|
+ await calculateRankings();
|
|
|
}
|
|
|
+ } catch (error) {
|
|
|
+ console.error("加载数据失败:", error);
|
|
|
+ proxy?.$modal.msgError("数据加载失败");
|
|
|
+ dataList.value = [];
|
|
|
+ total.value = 0;
|
|
|
+ } finally {
|
|
|
+ loading.value = false;
|
|
|
}
|
|
|
+};
|
|
|
|
|
|
- athleteScores.value = athleteScoresData;
|
|
|
- loading.value = false;
|
|
|
+// 分页组件事件处理
|
|
|
+const handlePagination = (paginationData: { page: number, limit: number }) => {
|
|
|
+ console.log('分页事件数据:', paginationData); // 添加调试日志
|
|
|
+ queryParams.pageNum = paginationData.page;
|
|
|
+ queryParams.pageSize = paginationData.limit;
|
|
|
+ console.log('更新后的查询参数:', queryParams); // 添加调试日志
|
|
|
+ loadData(false); // 分页加载不自动计算排名
|
|
|
};
|
|
|
|
|
|
onMounted(() => {
|
|
|
- loadAthleteScores();
|
|
|
+ loadData(true); // 页面初始化时自动计算排名
|
|
|
});
|
|
|
</script>
|