From 21fc12b18d24f49d5010aaf272a0a3310c11a16c Mon Sep 17 00:00:00 2001 From: DevOps Date: Tue, 30 Dec 2025 10:51:28 +0800 Subject: [PATCH] =?UTF-8?q?feat(schedule):=20=E5=89=8D=E7=AB=AF=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=8A=A8=E6=80=81=E6=97=B6=E9=97=B4=E6=AE=B5=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 getScheduleConfig API 调用 - 更新 generateTimeSlots 从后端获取时间配置 - 添加 loadScheduleConfig 和 formatTimeForDisplay 方法 - 时间段不再硬编码,从 ScheduleConfig 动态获取 --- src/api/martial/schedulePlan.js | 11 +++++++ src/views/martial/schedule/index.vue | 48 ++++++++++++++++++++++------ 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/src/api/martial/schedulePlan.js b/src/api/martial/schedulePlan.js index 799a9c8..0d8331f 100644 --- a/src/api/martial/schedulePlan.js +++ b/src/api/martial/schedulePlan.js @@ -207,3 +207,14 @@ export const updateCheckInStatus = (participantId, status) => { data: { participantId, status } }) } + +/** + * 获取赛程配置 + * @returns {Promise} 返回赛程配置信息 + */ +export const getScheduleConfig = () => { + return request({ + url: '/api/martial/schedule/config', + method: 'get' + }) +} diff --git a/src/views/martial/schedule/index.vue b/src/views/martial/schedule/index.vue index b5e0b64..d015c1a 100644 --- a/src/views/martial/schedule/index.vue +++ b/src/views/martial/schedule/index.vue @@ -381,7 +381,7 @@ import { ArrowDown, ArrowRight } from '@element-plus/icons-vue' import { getVenuesByCompetition } from '@/api/martial/venue' import { getCompetitionDetail } from '@/api/martial/competition' import { getScheduleResult, saveAndLockSchedule, saveDraftSchedule, triggerAutoArrange, moveScheduleGroup, exportSchedule } from '@/api/martial/activitySchedule' -import { updateCheckInStatus } from '@/api/martial/schedulePlan' +import { updateCheckInStatus, getScheduleConfig } from '@/api/martial/schedulePlan' export default { name: 'MartialScheduleList', @@ -420,7 +420,8 @@ export default { exceptionDialogVisible: false, exceptionList: [], // 异常参赛人员列表 expandedTeams: {}, // 展开的队伍 { 'groupId-teamId': true } - expandedProjects: {} // 展开的项目 { 'groupId': true },默认收起 + expandedProjects: {}, // 展开的项目 { 'groupId': true },默认收起 + scheduleConfig: { morningStartTime: '08:00', afternoonStartTime: '14:00' } // 赛程配置 } }, computed: { @@ -486,6 +487,7 @@ export default { this.orderId = this.$route.query.orderId if (this.competitionId) { + this.loadScheduleConfig() this.loadCompetitionInfo() this.loadVenues() this.loadScheduleData() @@ -766,15 +768,43 @@ export default { }, // 根据开始和结束时间生成时间段列表 + // 加载赛程配置 + async loadScheduleConfig() { + try { + const res = await getScheduleConfig() + if (res.data?.data) { + this.scheduleConfig = res.data.data + console.log('赛程配置:', this.scheduleConfig) + } + } catch (err) { + console.error('加载赛程配置失败', err) + } + }, + + // 格式化时间为显示格式 (08:00 -> 8:00) + formatTimeForDisplay(time) { + if (!time) return '8:00' + const parts = time.split(':') + const hour = parseInt(parts[0], 10) + const minute = parts[1] || '00' + return `${hour}:${minute}` + }, + generateTimeSlots() { const startTime = this.competitionInfo.competitionStartTime const endTime = this.competitionInfo.competitionEndTime + // 从配置获取时间,格式化为显示格式 + const morningTime = this.formatTimeForDisplay(this.scheduleConfig.morningStartTime || '08:00') + const afternoonTime = this.formatTimeForDisplay(this.scheduleConfig.afternoonStartTime || '14:00') + if (!startTime || !endTime) { this.$message.warning('赛事时间信息不完整,使用默认时间段') + const today = new Date() + const dateStr = `${today.getFullYear()}年${today.getMonth() + 1}月${today.getDate()}日` this.timeSlots = [ - '2025年11月6日 上午8:30', - '2025年11月6日 下午13:30' + `${dateStr} 上午${morningTime}`, + `${dateStr} 下午${afternoonTime}` ] return } @@ -785,7 +815,6 @@ export default { // 遍历每一天 let currentDate = new Date(start) - let dayIndex = 1 while (currentDate <= end) { const year = currentDate.getFullYear() @@ -793,15 +822,14 @@ export default { const day = currentDate.getDate() const dateStr = `${year}年${month}月${day}日` - // 添加上午时段 8:30 - slots.push(`${dateStr} 上午8:30`) + // 添加上午时段 + slots.push(`${dateStr} 上午${morningTime}`) - // 添加下午时段 13:30 - slots.push(`${dateStr} 下午13:30`) + // 添加下午时段 + slots.push(`${dateStr} 下午${afternoonTime}`) // 下一天 currentDate.setDate(currentDate.getDate() + 1) - dayIndex++ } this.timeSlots = slots