|
@@ -70,7 +70,7 @@
|
|
</el-table-column>
|
|
</el-table-column>
|
|
<el-table-column label="项目" align="center" prop="projectName" v-if="columns[1].visible" />
|
|
<el-table-column label="项目" align="center" prop="projectName" v-if="columns[1].visible" />
|
|
<!-- <el-table-column label="分组" align="center" prop="groupType" v-if="columns[2].visible" /> -->
|
|
<!-- <el-table-column label="分组" align="center" prop="groupType" v-if="columns[2].visible" /> -->
|
|
-
|
|
|
|
|
|
+
|
|
<el-table-column label="状态" align="center" prop="status" v-if="columns[4].visible">
|
|
<el-table-column label="状态" align="center" prop="status" v-if="columns[4].visible">
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
<el-select v-model="scope.row.status" placeholder="请选择状态">
|
|
<el-select v-model="scope.row.status" placeholder="请选择状态">
|
|
@@ -203,12 +203,12 @@ const printScores = async () => {
|
|
text: '正在准备打印数据...',
|
|
text: '正在准备打印数据...',
|
|
background: 'rgba(0, 0, 0, 0.7)'
|
|
background: 'rgba(0, 0, 0, 0.7)'
|
|
});
|
|
});
|
|
-
|
|
|
|
|
|
+
|
|
let projectsToPrint = [];
|
|
let projectsToPrint = [];
|
|
-
|
|
|
|
|
|
+
|
|
// 如果有选择项目,则打印选中的项目
|
|
// 如果有选择项目,则打印选中的项目
|
|
if (ids.value.length > 0) {
|
|
if (ids.value.length > 0) {
|
|
- projectsToPrint = projectList.value.filter(project =>
|
|
|
|
|
|
+ projectsToPrint = projectList.value.filter(project =>
|
|
ids.value.includes(project.projectId)
|
|
ids.value.includes(project.projectId)
|
|
);
|
|
);
|
|
} else {
|
|
} else {
|
|
@@ -238,30 +238,30 @@ const printScores = async () => {
|
|
projectId: project.projectId,
|
|
projectId: project.projectId,
|
|
classification: project.classification,
|
|
classification: project.classification,
|
|
pageNum: 1,
|
|
pageNum: 1,
|
|
- pageSize: 1000
|
|
|
|
|
|
+ pageSize: 1000
|
|
});
|
|
});
|
|
-
|
|
|
|
|
|
+
|
|
// 获取成绩数据并补充队伍和运动员信息
|
|
// 获取成绩数据并补充队伍和运动员信息
|
|
const scores = scoreRes.rows || [];
|
|
const scores = scoreRes.rows || [];
|
|
-
|
|
|
|
|
|
+
|
|
// 按积分排序,取前3名
|
|
// 按积分排序,取前3名
|
|
const sortedScores = scores
|
|
const sortedScores = scores
|
|
.filter(score => score.scorePoint && score.scorePoint > 0) // 只显示有积分的成绩
|
|
.filter(score => score.scorePoint && score.scorePoint > 0) // 只显示有积分的成绩
|
|
.sort((a: any, b: any) => (b.scorePoint || 0) - (a.scorePoint || 0)) // 按积分降序排列
|
|
.sort((a: any, b: any) => (b.scorePoint || 0) - (a.scorePoint || 0)) // 按积分降序排列
|
|
.slice(0, 3); // 只取前3名
|
|
.slice(0, 3); // 只取前3名
|
|
-
|
|
|
|
|
|
+
|
|
const scoresWithDetails = await Promise.all(
|
|
const scoresWithDetails = await Promise.all(
|
|
sortedScores.map(async (score: any) => {
|
|
sortedScores.map(async (score: any) => {
|
|
let teamName = '-';
|
|
let teamName = '-';
|
|
let athleteName = '-';
|
|
let athleteName = '-';
|
|
-
|
|
|
|
|
|
+
|
|
try {
|
|
try {
|
|
// 获取队伍信息
|
|
// 获取队伍信息
|
|
if (score.teamId) {
|
|
if (score.teamId) {
|
|
const teamRes = await getGameTeam(score.teamId);
|
|
const teamRes = await getGameTeam(score.teamId);
|
|
teamName = teamRes.data.teamName || `队伍${score.teamId}`;
|
|
teamName = teamRes.data.teamName || `队伍${score.teamId}`;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// 获取运动员信息
|
|
// 获取运动员信息
|
|
if (score.athleteId) {
|
|
if (score.athleteId) {
|
|
const athleteRes = await getGameAthlete(score.athleteId);
|
|
const athleteRes = await getGameAthlete(score.athleteId);
|
|
@@ -270,7 +270,7 @@ const printScores = async () => {
|
|
} catch (error) {
|
|
} catch (error) {
|
|
console.warn('获取队伍或运动员信息失败:', error);
|
|
console.warn('获取队伍或运动员信息失败:', error);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return {
|
|
return {
|
|
...score,
|
|
...score,
|
|
teamName,
|
|
teamName,
|
|
@@ -278,7 +278,7 @@ const printScores = async () => {
|
|
};
|
|
};
|
|
})
|
|
})
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+
|
|
return {
|
|
return {
|
|
...project,
|
|
...project,
|
|
scores: scoresWithDetails
|
|
scores: scoresWithDetails
|
|
@@ -298,18 +298,18 @@ const printScores = async () => {
|
|
|
|
|
|
// 构建打印HTML内容
|
|
// 构建打印HTML内容
|
|
const printHtml = buildPrintHtml(projectsWithScores);
|
|
const printHtml = buildPrintHtml(projectsWithScores);
|
|
-
|
|
|
|
|
|
+
|
|
// 使用 Blob 和 URL.createObjectURL 来避免弹窗拦截问题
|
|
// 使用 Blob 和 URL.createObjectURL 来避免弹窗拦截问题
|
|
const blob = new Blob([printHtml], { type: 'text/html' });
|
|
const blob = new Blob([printHtml], { type: 'text/html' });
|
|
const url = URL.createObjectURL(blob);
|
|
const url = URL.createObjectURL(blob);
|
|
-
|
|
|
|
|
|
+
|
|
// 创建隐藏的 iframe 来处理打印
|
|
// 创建隐藏的 iframe 来处理打印
|
|
const iframe = document.createElement('iframe');
|
|
const iframe = document.createElement('iframe');
|
|
iframe.style.position = 'absolute';
|
|
iframe.style.position = 'absolute';
|
|
iframe.style.top = '-9999px';
|
|
iframe.style.top = '-9999px';
|
|
iframe.style.left = '-9999px';
|
|
iframe.style.left = '-9999px';
|
|
document.body.appendChild(iframe);
|
|
document.body.appendChild(iframe);
|
|
-
|
|
|
|
|
|
+
|
|
iframe.onload = () => {
|
|
iframe.onload = () => {
|
|
try {
|
|
try {
|
|
// 打印完成后清理
|
|
// 打印完成后清理
|
|
@@ -321,14 +321,14 @@ const printScores = async () => {
|
|
console.error('清理打印资源失败:', error);
|
|
console.error('清理打印资源失败:', error);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
-
|
|
|
|
|
|
+
|
|
// 在 iframe 中加载并打印
|
|
// 在 iframe 中加载并打印
|
|
const iframeDoc = iframe.contentDocument || iframe.contentWindow?.document;
|
|
const iframeDoc = iframe.contentDocument || iframe.contentWindow?.document;
|
|
if (iframeDoc) {
|
|
if (iframeDoc) {
|
|
iframeDoc.open();
|
|
iframeDoc.open();
|
|
iframeDoc.write(printHtml);
|
|
iframeDoc.write(printHtml);
|
|
iframeDoc.close();
|
|
iframeDoc.close();
|
|
-
|
|
|
|
|
|
+
|
|
// 等待内容加载后打印
|
|
// 等待内容加载后打印
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
try {
|
|
try {
|
|
@@ -359,7 +359,7 @@ const printScores = async () => {
|
|
*/
|
|
*/
|
|
const buildPrintHtml = (projects: any[]) => {
|
|
const buildPrintHtml = (projects: any[]) => {
|
|
const printTime = new Date().toLocaleString('zh-CN');
|
|
const printTime = new Date().toLocaleString('zh-CN');
|
|
-
|
|
|
|
|
|
+
|
|
let html = `
|
|
let html = `
|
|
<!DOCTYPE html>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<html>
|
|
@@ -394,14 +394,14 @@ const buildPrintHtml = (projects: any[]) => {
|
|
// 为每个项目添加成绩表格
|
|
// 为每个项目添加成绩表格
|
|
projects.forEach(project => {
|
|
projects.forEach(project => {
|
|
const scores = project.scores || [];
|
|
const scores = project.scores || [];
|
|
-
|
|
|
|
|
|
+
|
|
html += `
|
|
html += `
|
|
<div class="project-section">
|
|
<div class="project-section">
|
|
<div class="project-title">
|
|
<div class="project-title">
|
|
- <span class="title-label">${project.projectId}</span>
|
|
|
|
- <span class="title-label">${getProjectTypeName(project.projectType)} ${project.projectName}</span>
|
|
|
|
|
|
+ <span class="title-label">${project.projectId}</span>
|
|
|
|
+ <span class="title-label">${getProjectTypeName(project.projectType)} ${project.projectName}</span>
|
|
</div>
|
|
</div>
|
|
-
|
|
|
|
|
|
+
|
|
<table class="score-table">
|
|
<table class="score-table">
|
|
<thead>
|
|
<thead>
|
|
<tr>
|
|
<tr>
|
|
@@ -468,7 +468,7 @@ const formatScore = (score: number | string) => {
|
|
*/
|
|
*/
|
|
const getProjectTypeName = (type: string) => {
|
|
const getProjectTypeName = (type: string) => {
|
|
if (!game_project_type.value || !type) return '未知';
|
|
if (!game_project_type.value || !type) return '未知';
|
|
-
|
|
|
|
|
|
+
|
|
const typeItem = game_project_type.value.find((item: any) => item.value === type);
|
|
const typeItem = game_project_type.value.find((item: any) => item.value === type);
|
|
return typeItem ? typeItem.label : '未知';
|
|
return typeItem ? typeItem.label : '未知';
|
|
};
|
|
};
|
|
@@ -477,7 +477,7 @@ const exportScoresNames = () => {
|
|
// 获取默认赛事ID
|
|
// 获取默认赛事ID
|
|
const event = gameEventStore.defaultEventInfo;
|
|
const event = gameEventStore.defaultEventInfo;
|
|
const eventId = event?.eventId;
|
|
const eventId = event?.eventId;
|
|
-
|
|
|
|
|
|
+
|
|
if (!eventId) {
|
|
if (!eventId) {
|
|
proxy?.$modal.msgWarning('未指定赛事,无法导出');
|
|
proxy?.$modal.msgWarning('未指定赛事,无法导出');
|
|
return;
|
|
return;
|
|
@@ -542,4 +542,4 @@ onMounted(() => {
|
|
refreshData();
|
|
refreshData();
|
|
// });
|
|
// });
|
|
});
|
|
});
|
|
-</script>
|
|
|
|
|
|
+</script>
|