2 Commits

2 changed files with 15 additions and 8 deletions

View File

@@ -164,11 +164,15 @@
<h2>批量添加比赛</h2>
<div class="form-group">
<label>比赛数据(每行一条,用逗号分隔)</label>
<textarea id="batch-match-data" rows="12" placeholder="比赛代码,主队,客队,比赛时间,轮次
例如:
M001,阿根廷,法国,2026-07-15 21:00,决赛
M002,巴西,德国,2026-07-14 18:00,决赛
M003,西班牙,荷兰,2026-07-14 21:00,半决赛"></textarea>
<textarea id="batch-match-data" rows="14" placeholder="比赛代码,主队,客队,比赛时间,轮次,状态,主队比分,客队比分
示例:
M001,阿根廷,法国,2026-07-15 21:00,决赛,upcoming,-,-
M002,巴西,德国,2026-07-14 18:00,半决赛,finished,2,1
M003,西班牙,荷兰,2026-07-14 21:00,半决赛,upcoming,-,-
状态upcoming即将进行或 finished已完成
比分:未进行的比赛用 - 表示"></textarea>
</div>
<div class="form-group">
<label>轮次(可选,批量设置)</label>

View File

@@ -429,13 +429,14 @@ async function batchAddMatches() {
const lines = dataText.split('\n').filter(line => line.trim());
let successCount = 0;
let failCount = 0;
let errors = [];\n
let errors = [];
for (const line of lines) {
const parts = line.split(',').map(p => p.trim());
if (parts.length < 3) {
failCount++;
errors.push(`格式错误: ${line}`);n continue;
errors.push(`格式错误: ${line}`);
continue;
}
const matchData = {
@@ -444,7 +445,9 @@ async function batchAddMatches() {
away_team: parts[2],
match_time: parts[3] || null,
round_name: parts[4] || defaultRound || '小组赛',
status: 'upcoming'
status: parts[5] || 'upcoming',
home_score: (parts[6] && parts[6] !== '-') ? parseInt(parts[6]) : null,
away_score: (parts[7] && parts[7] !== '-') ? parseInt(parts[7]) : null
};
try {