|
|
|
@ -70,8 +70,10 @@ |
|
|
|
<view class="student-name">{{ stu.name }}</view> |
|
|
|
<view class="student-age">年龄:{{ stu.age || '未知' }}岁</view> |
|
|
|
<view class="course-status">课程状态:{{ stu.courseStatus }}</view> |
|
|
|
<view class="course-progress">上课情况:{{ stu.course_progress.used }}/{{ stu.course_progress.total }}节 ({{ stu.course_progress.percentage }}%)</view> |
|
|
|
<view class="expiry-date">到期时间:{{ stu.expiryDate || '未设置' }}</view> |
|
|
|
<view class="course-status">上课情况: |
|
|
|
{{ stu.course_progress.used }}/{{ stu.course_progress.total }}节 ({{ stu.course_progress.percentage }}%) |
|
|
|
</view> |
|
|
|
<view class="expiry-date" v-if="stu.expiryDate">到期时间:{{ stu.expiryDate || '未设置' }}</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
@ -565,69 +567,164 @@ |
|
|
|
viewStudent(stu) { |
|
|
|
console.log(stu, this.schedule_info); |
|
|
|
|
|
|
|
// 根据学员状态和类型构建操作选项 |
|
|
|
let itemList = []; |
|
|
|
if (stu.person_type === 'customer_resource') { |
|
|
|
itemList.push('取消课程'); |
|
|
|
// 如果是等待位学员,且正式位有空位,增加升级选项 |
|
|
|
if (stu.schedule_type === 2 && this.formalEmptySeats.length > 0) { |
|
|
|
itemList.push('升级为正式学员'); |
|
|
|
} |
|
|
|
} else { |
|
|
|
itemList.push('申请请假'); |
|
|
|
} |
|
|
|
|
|
|
|
// 显示操作选项弹窗 |
|
|
|
uni.showActionSheet({ |
|
|
|
title: `学员: ${stu.name}`, |
|
|
|
itemList: stu.person_type === 'customer_resource' ? ['取消课程'] : ['申请请假'], |
|
|
|
itemList: itemList, |
|
|
|
success: (res) => { |
|
|
|
if (res.tapIndex === 0) { |
|
|
|
// 判断学员类型 |
|
|
|
if (stu.person_type === 'customer_resource') { |
|
|
|
// 如果是客户资源,弹出确认取消课程的弹窗 |
|
|
|
uni.showModal({ |
|
|
|
title: '取消课程', |
|
|
|
content: `是否取消学员 ${stu.name} 的课程?`, |
|
|
|
success: async (res) => { |
|
|
|
if (res.confirm) { |
|
|
|
// 用户点击确定,调用schedule_del接口 |
|
|
|
try { |
|
|
|
uni.showLoading({ |
|
|
|
title: '处理中...' |
|
|
|
const selectedOption = itemList[res.tapIndex]; |
|
|
|
|
|
|
|
if (selectedOption === '取消课程') { |
|
|
|
// 弹出确认取消课程的弹窗 |
|
|
|
uni.showModal({ |
|
|
|
title: '取消课程', |
|
|
|
content: `是否取消学员 ${stu.name} 的课程?`, |
|
|
|
success: async (res) => { |
|
|
|
if (res.confirm) { |
|
|
|
// 用户点击确定,调用schedule_del接口 |
|
|
|
try { |
|
|
|
uni.showLoading({ |
|
|
|
title: '处理中...' |
|
|
|
}); |
|
|
|
|
|
|
|
const params = { |
|
|
|
resources_id: stu.resources_id, |
|
|
|
id: this.schedule_info.id |
|
|
|
}; |
|
|
|
|
|
|
|
const result = await apiRoute.schedule_del(params); |
|
|
|
|
|
|
|
uni.hideLoading(); |
|
|
|
|
|
|
|
if (result.code === 1) { |
|
|
|
uni.showToast({ |
|
|
|
title: '取消课程成功', |
|
|
|
icon: 'success' |
|
|
|
}); |
|
|
|
|
|
|
|
const params = { |
|
|
|
resources_id: stu.resources_id, |
|
|
|
id: this.schedule_info.id |
|
|
|
}; |
|
|
|
|
|
|
|
const result = await apiRoute.schedule_del(params); |
|
|
|
|
|
|
|
uni.hideLoading(); |
|
|
|
|
|
|
|
if (result.code === 1) { |
|
|
|
uni.showToast({ |
|
|
|
title: '取消课程成功', |
|
|
|
icon: 'success' |
|
|
|
}); |
|
|
|
|
|
|
|
// 刷新数据 |
|
|
|
await this.getScheduleDetail(); |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
title: result.msg || '取消课程失败', |
|
|
|
icon: 'none' |
|
|
|
}); |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
uni.hideLoading(); |
|
|
|
// 刷新数据 |
|
|
|
await this.getScheduleDetail(); |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
title: '操作失败,请重试', |
|
|
|
title: result.msg || '取消课程失败', |
|
|
|
icon: 'none' |
|
|
|
}); |
|
|
|
console.error('取消课程失败:', error); |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
uni.hideLoading(); |
|
|
|
uni.showToast({ |
|
|
|
title: '操作失败,请重试', |
|
|
|
icon: 'none' |
|
|
|
}); |
|
|
|
console.error('取消课程失败:', error); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} else if (stu.person_type === 'student') { |
|
|
|
// 如果是学生,弹出请假原因输入框 |
|
|
|
this.$refs.leaveReasonModal.open(); |
|
|
|
this.currentStudent = stu; // 保存当前操作的学生信息 |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} else if (selectedOption === '升级为正式学员') { |
|
|
|
// 确认升级操作 |
|
|
|
this.confirmUpgradeStudent(stu); |
|
|
|
} else if (selectedOption === '申请请假') { |
|
|
|
// 如果是学生,弹出请假原因输入框 |
|
|
|
this.$refs.leaveReasonModal.open(); |
|
|
|
this.currentStudent = stu; // 保存当前操作的学生信息 |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 确认升级学员 |
|
|
|
confirmUpgradeStudent(stu) { |
|
|
|
// 检查正式位是否有空位 |
|
|
|
if (this.formalEmptySeats.length === 0) { |
|
|
|
uni.showToast({ |
|
|
|
title: '正式位已满,无法升级', |
|
|
|
icon: 'none' |
|
|
|
}); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
uni.showModal({ |
|
|
|
title: '升级确认', |
|
|
|
content: `是否将等待位学员 ${stu.name} 升级为正式学员?升级后将占用一个正式位。`, |
|
|
|
success: async (res) => { |
|
|
|
if (res.confirm) { |
|
|
|
await this.upgradeStudent(stu); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 执行学员升级 |
|
|
|
async upgradeStudent(stu) { |
|
|
|
try { |
|
|
|
uni.showLoading({ |
|
|
|
title: '升级中...' |
|
|
|
}); |
|
|
|
|
|
|
|
// 构建升级参数 |
|
|
|
const upgradeData = { |
|
|
|
resources_id: stu.resources_id, |
|
|
|
schedule_id: this.course_id, |
|
|
|
student_id: stu.student_id, |
|
|
|
from_schedule_type: 2, // 从等待位 |
|
|
|
to_schedule_type: 1, // 升级到正式位 |
|
|
|
position: this.formalStudents.length + 1, // 新的正式位位置 |
|
|
|
course_type: stu.course_type === 3 ? 1 : stu.course_type // 等待位课程类型改为正式课 |
|
|
|
}; |
|
|
|
|
|
|
|
// 调用升级接口(需要在后端实现) |
|
|
|
const result = await apiRoute.upgradeStudentSchedule(upgradeData); |
|
|
|
|
|
|
|
uni.hideLoading(); |
|
|
|
|
|
|
|
if (result.code === 1) { |
|
|
|
uni.showToast({ |
|
|
|
title: '升级成功', |
|
|
|
icon: 'success' |
|
|
|
}); |
|
|
|
|
|
|
|
// 刷新数据 |
|
|
|
await this.getScheduleDetail(); |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
title: result.msg || '升级失败', |
|
|
|
icon: 'none' |
|
|
|
}); |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
uni.hideLoading(); |
|
|
|
console.error('升级学员失败:', error); |
|
|
|
|
|
|
|
// 尝试获取具体的错误信息 |
|
|
|
let errorMsg = '升级失败'; |
|
|
|
if (error && error.data && error.data.msg) { |
|
|
|
errorMsg = error.data.msg; |
|
|
|
} else if (error && error.message) { |
|
|
|
errorMsg = error.message; |
|
|
|
} else if (typeof error === 'string') { |
|
|
|
errorMsg = error; |
|
|
|
} |
|
|
|
|
|
|
|
uni.showToast({ |
|
|
|
title: errorMsg, |
|
|
|
icon: 'none' |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
getStatusText(status) { |
|
|
|
const statusMap = { |
|
|
|
0: '待上课', |
|
|
|
|