feat(schedule): 前端支持动态时间段配置
- 添加 getScheduleConfig API 调用 - 更新 generateTimeSlots 从后端获取时间配置 - 添加 loadScheduleConfig 和 formatTimeForDisplay 方法 - 时间段不再硬编码,从 ScheduleConfig 动态获取
This commit is contained in:
@@ -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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user