|
|
|
@ -43,6 +43,9 @@ |
|
|
|
:formal-has-empty="formalEmptySeats.length > 0" |
|
|
|
@confirm-action="handleConfirmAction" |
|
|
|
/> |
|
|
|
|
|
|
|
<!-- 学员详情弹窗 --> |
|
|
|
<student-detail-modal ref="studentDetailModalRef" /> |
|
|
|
</el-dialog> |
|
|
|
</template> |
|
|
|
|
|
|
|
@ -61,6 +64,7 @@ import CourseInfoSection from './course-info-section.vue' |
|
|
|
import StudentSection from './student-section.vue' |
|
|
|
import StudentSearchModal from './student-search-modal.vue' |
|
|
|
import StudentActionMenu from './student-action-menu.vue' |
|
|
|
import StudentDetailModal from './student-detail-modal.vue' |
|
|
|
|
|
|
|
import type { |
|
|
|
StudentInfo, |
|
|
|
@ -104,6 +108,9 @@ const currentSlot = ref<SlotInfo>({ type: 'formal', index: 1 }) |
|
|
|
const currentStudent = ref<StudentInfo | null>(null) |
|
|
|
const presetStudent = ref<StudentInfo | null>(null) |
|
|
|
|
|
|
|
// 学员详情弹窗引用 |
|
|
|
const studentDetailModalRef = ref() |
|
|
|
|
|
|
|
// 暴露给父组件的方法 |
|
|
|
const open = (scheduleId: number, resourceId?: number, studentId?: number) => { |
|
|
|
if (scheduleId) { |
|
|
|
@ -630,40 +637,59 @@ const handleCancelLeave = async (student: StudentInfo) => { |
|
|
|
// 学员签到 |
|
|
|
const handleStudentCheckin = async (student: StudentInfo) => { |
|
|
|
try { |
|
|
|
const statusOptions = [ |
|
|
|
{ label: '待上课', value: 0 }, |
|
|
|
{ label: '已签到', value: 1 }, |
|
|
|
{ label: '请假', value: 2 } |
|
|
|
] |
|
|
|
const currentStatus = student.status === 1 ? '已签到' : student.status === 2 ? '请假' : '待上课' |
|
|
|
|
|
|
|
const currentStatus = statusOptions.find(opt => opt.value === student.status) |
|
|
|
// 如果已经签到,询问是否取消签到 |
|
|
|
if (student.status === 1) { |
|
|
|
const result = await ElMessageBox.confirm( |
|
|
|
`学员 ${student.name} 当前状态:${currentStatus}\n\n确定要取消签到吗?`, |
|
|
|
'取消签到确认', |
|
|
|
{ |
|
|
|
confirmButtonText: '取消签到', |
|
|
|
cancelButtonText: '保持现状', |
|
|
|
type: 'warning' |
|
|
|
} |
|
|
|
) |
|
|
|
|
|
|
|
const { value: statusValue } = await ElMessageBox.prompt( |
|
|
|
`当前状态:${currentStatus?.label || '未知'}\n请选择新的签到状态:`, |
|
|
|
'更新签到状态', |
|
|
|
if (result === 'confirm') { |
|
|
|
const response = await updateStudentStatus({ |
|
|
|
schedule_id: scheduleInfo.value.id, |
|
|
|
person_id: student.person_id || student.id, |
|
|
|
status: 0, // 改为待上课 |
|
|
|
reason: '管理员取消签到' |
|
|
|
}) |
|
|
|
|
|
|
|
if (response.code === 1) { |
|
|
|
ElMessage.success('已取消签到状态') |
|
|
|
} else { |
|
|
|
ElMessage.error(response.msg || '取消签到失败') |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 其他状态,询问是否签到 |
|
|
|
const result = await ElMessageBox.confirm( |
|
|
|
`学员 ${student.name} 当前状态:${currentStatus}\n\n确定要标记为已签到吗?`, |
|
|
|
'签到确认', |
|
|
|
{ |
|
|
|
confirmButtonText: '确定', |
|
|
|
confirmButtonText: '确认签到', |
|
|
|
cancelButtonText: '取消', |
|
|
|
inputPlaceholder: '请选择状态: 0-待上课, 1-已签到, 2-请假', |
|
|
|
inputPattern: /^[0-2]$/, |
|
|
|
inputErrorMessage: '请输入 0、1 或 2' |
|
|
|
type: 'info' |
|
|
|
} |
|
|
|
) |
|
|
|
|
|
|
|
const newStatus = parseInt(statusValue) |
|
|
|
|
|
|
|
if (!isNaN(newStatus) && newStatus !== student.status && [0, 1, 2].includes(newStatus)) { |
|
|
|
if (result === 'confirm') { |
|
|
|
const response = await updateStudentStatus({ |
|
|
|
schedule_id: scheduleInfo.value.id, |
|
|
|
person_id: student.person_id || student.id, |
|
|
|
status: newStatus, |
|
|
|
reason: `签到状态更新为: ${statusOptions.find(opt => opt.value === newStatus)?.label}` |
|
|
|
status: 1, // 标记为已签到 |
|
|
|
reason: '管理员确认签到' |
|
|
|
}) |
|
|
|
|
|
|
|
if (response.code === 1) { |
|
|
|
ElMessage.success('签到状态更新成功') |
|
|
|
ElMessage.success('签到成功') |
|
|
|
} else { |
|
|
|
ElMessage.error(response.msg || '签到状态更新失败') |
|
|
|
ElMessage.error(response.msg || '签到失败') |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
@ -677,10 +703,20 @@ const handleStudentCheckin = async (student: StudentInfo) => { |
|
|
|
// 查看学员详情 |
|
|
|
const handleViewStudentDetails = async (student: StudentInfo) => { |
|
|
|
try { |
|
|
|
// 这里可以打开学员详情页面或弹窗 |
|
|
|
ElMessage.info('查看学员详情功能开发中') |
|
|
|
// TODO: 实现学员详情查看功能 |
|
|
|
console.log('查看学员详情:', student) |
|
|
|
// 从StudentInfo中获取student_id或person_id作为学员ID |
|
|
|
const studentId = student.student_id || student.person_id || student.id |
|
|
|
|
|
|
|
if (!studentId) { |
|
|
|
ElMessage.warning('无法获取学员ID') |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// 打开学员详情弹窗 |
|
|
|
if (studentDetailModalRef.value) { |
|
|
|
await studentDetailModalRef.value.open(studentId) |
|
|
|
} else { |
|
|
|
ElMessage.error('学员详情组件未正确加载') |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('查看学员详情失败:', error) |
|
|
|
ElMessage.error('查看学员详情失败') |
|
|
|
|