feat(schedule): 前端支持动态时间段配置

- 添加 getScheduleConfig API 调用
- 更新 generateTimeSlots 从后端获取时间配置
- 添加 loadScheduleConfig 和 formatTimeForDisplay 方法
- 时间段不再硬编码,从 ScheduleConfig 动态获取
This commit is contained in:
DevOps
2025-12-30 10:51:28 +08:00
parent 21274e9639
commit 21fc12b18d
2 changed files with 49 additions and 10 deletions

View File

@@ -207,3 +207,14 @@ export const updateCheckInStatus = (participantId, status) => {
data: { participantId, status } data: { participantId, status }
}) })
} }
/**
* 获取赛程配置
* @returns {Promise} 返回赛程配置信息
*/
export const getScheduleConfig = () => {
return request({
url: '/api/martial/schedule/config',
method: 'get'
})
}

View File

@@ -381,7 +381,7 @@ import { ArrowDown, ArrowRight } from '@element-plus/icons-vue'
import { getVenuesByCompetition } from '@/api/martial/venue' import { getVenuesByCompetition } from '@/api/martial/venue'
import { getCompetitionDetail } from '@/api/martial/competition' import { getCompetitionDetail } from '@/api/martial/competition'
import { getScheduleResult, saveAndLockSchedule, saveDraftSchedule, triggerAutoArrange, moveScheduleGroup, exportSchedule } from '@/api/martial/activitySchedule' 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 { export default {
name: 'MartialScheduleList', name: 'MartialScheduleList',
@@ -420,7 +420,8 @@ export default {
exceptionDialogVisible: false, exceptionDialogVisible: false,
exceptionList: [], // 异常参赛人员列表 exceptionList: [], // 异常参赛人员列表
expandedTeams: {}, // 展开的队伍 { 'groupId-teamId': true } expandedTeams: {}, // 展开的队伍 { 'groupId-teamId': true }
expandedProjects: {} // 展开的项目 { 'groupId': true },默认收起 expandedProjects: {}, // 展开的项目 { 'groupId': true },默认收起
scheduleConfig: { morningStartTime: '08:00', afternoonStartTime: '14:00' } // 赛程配置
} }
}, },
computed: { computed: {
@@ -486,6 +487,7 @@ export default {
this.orderId = this.$route.query.orderId this.orderId = this.$route.query.orderId
if (this.competitionId) { if (this.competitionId) {
this.loadScheduleConfig()
this.loadCompetitionInfo() this.loadCompetitionInfo()
this.loadVenues() this.loadVenues()
this.loadScheduleData() 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() { generateTimeSlots() {
const startTime = this.competitionInfo.competitionStartTime const startTime = this.competitionInfo.competitionStartTime
const endTime = this.competitionInfo.competitionEndTime 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) { if (!startTime || !endTime) {
this.$message.warning('赛事时间信息不完整,使用默认时间段') this.$message.warning('赛事时间信息不完整,使用默认时间段')
const today = new Date()
const dateStr = `${today.getFullYear()}${today.getMonth() + 1}${today.getDate()}`
this.timeSlots = [ this.timeSlots = [
'2025年11月6日 上午8:30', `${dateStr} 上午${morningTime}`,
'2025年11月6日 下午13:30' `${dateStr} 下午${afternoonTime}`
] ]
return return
} }
@@ -785,7 +815,6 @@ export default {
// 遍历每一天 // 遍历每一天
let currentDate = new Date(start) let currentDate = new Date(start)
let dayIndex = 1
while (currentDate <= end) { while (currentDate <= end) {
const year = currentDate.getFullYear() const year = currentDate.getFullYear()
@@ -793,15 +822,14 @@ export default {
const day = currentDate.getDate() const day = currentDate.getDate()
const dateStr = `${year}${month}${day}` 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) currentDate.setDate(currentDate.getDate() + 1)
dayIndex++
} }
this.timeSlots = slots this.timeSlots = slots