25 changed files with 1583 additions and 680 deletions
@ -1,29 +1,37 @@ |
|||||
{ |
{ |
||||
"id": "课程安排编号", |
"id": "课程安排编号", |
||||
"idPlaceholder": "请输入课程安排编号", |
"idPlaceholder": "请输入课程安排编号", |
||||
"campusId": "校区ID", |
"campusId": "校区", |
||||
"campusIdPlaceholder": "请输入校区ID", |
"campusIdPlaceholder": "请选择校区", |
||||
"venueId": "场地ID", |
"venueId": "场地", |
||||
"venueIdPlaceholder": "请输入场地ID", |
"venueIdPlaceholder": "请选择场地", |
||||
"courseDate": "上课日期", |
"courseDate": "上课日期", |
||||
"courseDatePlaceholder": "请输入上课日期", |
"courseDatePlaceholder": "请选择上课日期", |
||||
"timeSlot": "上课时段", |
"timeSlot": "上课时段", |
||||
"timeSlotPlaceholder": "请输入上课时段", |
"timeSlotPlaceholder": "请选择上课时段", |
||||
"courseId": "课程ID", |
"courseId": "课程", |
||||
"courseIdPlaceholder": "请输入课程ID", |
"courseIdPlaceholder": "请选择课程", |
||||
"coachId": "上课教练ID", |
"coachId": "上课教练", |
||||
"coachIdPlaceholder": "请输入上课教练ID", |
"coachIdPlaceholder": "请选择上课教练", |
||||
"participants": "参与人员列表", |
"participants": "参与人员", |
||||
"participantsPlaceholder": "请输入参与人员列表", |
"participantsPlaceholder": "请选择参与人员", |
||||
"studentIds": "上课学生列表", |
"studentIds": "参与学生", |
||||
"studentIdsPlaceholder": "请输入上课学生列表", |
"studentIdsPlaceholder": "请选择参与学生", |
||||
"availableCapacity": "根据场地容量判断的可安排学员位置数量", |
"availableCapacity": "根据场地容量判断的可安排学员位置数量", |
||||
"availableCapacityPlaceholder": "请输入根据场地容量判断的可安排学员位置数量", |
"availableCapacityPlaceholder": "请输入根据场地容量判断的可安排学员位置数量", |
||||
"status": "课程状态:", |
"status": "课程状态", |
||||
"statusPlaceholder": "请输入课程状态:", |
"statusPlaceholder": "请选择课程状态", |
||||
"addCourseSchedule": "添加课程安排", |
"addCourseSchedule": "添加课程安排", |
||||
"updateCourseSchedule": "编辑课程安排", |
"updateCourseSchedule": "编辑课程安排", |
||||
"courseScheduleDeleteTips": "确定要删除该数据吗?", |
"courseScheduleDeleteTips": "确定要删除该数据吗?", |
||||
"startDate": "请选择开始时间", |
"startDate": "请选择开始时间", |
||||
"endDate": "请选择结束时间" |
"endDate": "请选择结束时间", |
||||
|
"pending": "待开始", |
||||
|
"upcoming": "即将开始", |
||||
|
"ongoing": "进行中", |
||||
|
"completed": "已结束", |
||||
|
"autoSchedule": "自动排课", |
||||
|
"autoSchedulePlaceholder": "请选择是否自动排课", |
||||
|
"yes": "是", |
||||
|
"no": "否" |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,113 @@ |
|||||
|
/** |
||||
|
* 根据场地信息生成可用时间段 |
||||
|
* @param venueInfo 场地信息对象 |
||||
|
* @returns 时间段数组,格式为["08:00-09:00", "09:00-10:00"] |
||||
|
*/ |
||||
|
export const generateTimeSlots = (venueInfo: any) => { |
||||
|
if (!venueInfo) return [] |
||||
|
|
||||
|
const timeSlots: string[] = [] |
||||
|
|
||||
|
// 如果场地已有预设时间段,优先使用
|
||||
|
if (venueInfo.time_slots && Array.isArray(venueInfo.time_slots)) { |
||||
|
return venueInfo.time_slots.map((slot: string) => slot.trim()); |
||||
|
} |
||||
|
|
||||
|
// 根据time_range_type生成不同的时间段
|
||||
|
switch (venueInfo.time_range_type) { |
||||
|
case 'fixed': |
||||
|
// 从fixed_time_ranges中获取固定时间段
|
||||
|
try { |
||||
|
// 确保fixed_time_ranges是数组
|
||||
|
const fixedRanges = Array.isArray(venueInfo.fixed_time_ranges) |
||||
|
? venueInfo.fixed_time_ranges |
||||
|
: (typeof venueInfo.fixed_time_ranges === 'string' |
||||
|
? JSON.parse(venueInfo.fixed_time_ranges || '[]') |
||||
|
: []); |
||||
|
|
||||
|
fixedRanges.forEach((range: any) => { |
||||
|
// 确保start_time和end_time存在
|
||||
|
if (range && range.start_time && range.end_time) { |
||||
|
timeSlots.push(`${range.start_time}-${range.end_time}`) |
||||
|
} |
||||
|
}) |
||||
|
} catch (error) { |
||||
|
console.error('解析固定时间段失败:', error) |
||||
|
} |
||||
|
break |
||||
|
|
||||
|
case 'all': |
||||
|
// 全天可用,但中午12:30-14:00不可用
|
||||
|
// 早上8点到中午12:30,步长60分钟
|
||||
|
for (let hour = 8; hour <= 12; hour++) { |
||||
|
for (let minute = 0; minute < 60; minute += 60) { |
||||
|
if (hour === 12 && minute === 30) continue // 跳过12:30
|
||||
|
|
||||
|
const startHour = hour |
||||
|
const startMinute = minute |
||||
|
const endHour = minute === 30 ? hour + 1 : hour |
||||
|
const endMinute = minute === 30 ? 0 : 30 |
||||
|
|
||||
|
const startTime = `${startHour.toString().padStart(2, '0')}:${startMinute.toString().padStart(2, '0')}` |
||||
|
const endTime = `${endHour.toString().padStart(2, '0')}:${endMinute.toString().padStart(2, '0')}` |
||||
|
|
||||
|
timeSlots.push(`${startTime}-${endTime}`) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 下午14:00到晚上22:00,步长60分钟
|
||||
|
for (let hour = 14; hour < 22; hour++) { |
||||
|
for (let minute = 0; minute < 60; minute += 60) { |
||||
|
const startHour = hour |
||||
|
const startMinute = minute |
||||
|
const endHour = minute === 30 ? hour + 1 : hour |
||||
|
const endMinute = minute === 30 ? 0 : 30 |
||||
|
|
||||
|
const startTime = `${startHour.toString().padStart(2, '0')}:${startMinute.toString().padStart(2, '0')}` |
||||
|
const endTime = `${endHour.toString().padStart(2, '0')}:${endMinute.toString().padStart(2, '0')}` |
||||
|
|
||||
|
timeSlots.push(`${startTime}-${endTime}`) |
||||
|
} |
||||
|
} |
||||
|
break |
||||
|
|
||||
|
case 'range': |
||||
|
// 使用指定的时间范围,步长60分钟
|
||||
|
if (venueInfo.time_range_start && venueInfo.time_range_end) { |
||||
|
const startTimeParts = venueInfo.time_range_start.split(':') |
||||
|
const endTimeParts = venueInfo.time_range_end.split(':') |
||||
|
|
||||
|
if (startTimeParts.length === 2 && endTimeParts.length === 2) { |
||||
|
const startHour = parseInt(startTimeParts[0]) |
||||
|
const startMinute = parseInt(startTimeParts[1]) |
||||
|
const endHour = parseInt(endTimeParts[0]) |
||||
|
const endMinute = parseInt(endTimeParts[1]) |
||||
|
|
||||
|
// 计算总分钟数
|
||||
|
const startTotalMinutes = startHour * 60 + startMinute |
||||
|
const endTotalMinutes = endHour * 60 + endMinute |
||||
|
|
||||
|
// 以60分钟为步长生成时间段
|
||||
|
for (let minutes = startTotalMinutes; minutes < endTotalMinutes; minutes += 60) { |
||||
|
const startHour = Math.floor(minutes / 60) |
||||
|
const startMinute = minutes % 60 |
||||
|
const endHour = Math.floor((minutes + 60) / 60) |
||||
|
const endMinute = (minutes + 60) % 60 |
||||
|
|
||||
|
const startTime = `${startHour.toString().padStart(2, '0')}:${startMinute.toString().padStart(2, '0')}` |
||||
|
const endTime = `${endHour.toString().padStart(2, '0')}:${endMinute.toString().padStart(2, '0')}` |
||||
|
|
||||
|
timeSlots.push(`${startTime}-${endTime}`) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
break |
||||
|
} |
||||
|
|
||||
|
// 添加现有时间段,如果有的话
|
||||
|
if (venueInfo.time_slot && !timeSlots.includes(venueInfo.time_slot)) { |
||||
|
timeSlots.push(venueInfo.time_slot); |
||||
|
} |
||||
|
|
||||
|
return timeSlots |
||||
|
} |
||||
Loading…
Reference in new issue