|
|
@ -45,7 +45,6 @@ |
|
|
<view class="student-swiper-content"> |
|
|
<view class="student-swiper-content"> |
|
|
<StudentInfoCard |
|
|
<StudentInfoCard |
|
|
:student="student" |
|
|
:student="student" |
|
|
:actions="[]" |
|
|
|
|
|
:show-details="true" |
|
|
:show-details="true" |
|
|
@action="handleStudentAction" |
|
|
@action="handleStudentAction" |
|
|
/> |
|
|
/> |
|
|
@ -656,18 +655,25 @@ export default { |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
handleStudentAction({ action, student }) { |
|
|
handleStudentAction({ action, student }) { |
|
|
this.setCurrentStudent(student) |
|
|
// this.setCurrentStudent(student) |
|
|
|
|
|
console.log('学生操作:', action, student) |
|
|
switch (action.key) { |
|
|
|
|
|
case 'course_info': |
|
|
// 处理不同的学员操作 |
|
|
this.switch_tags_type = 2 |
|
|
switch (action) { |
|
|
|
|
|
case 'edit': |
|
|
|
|
|
// 编辑学员信息 - 打开编辑弹窗并回显数据 |
|
|
|
|
|
this.openEditStudentDialog(student) |
|
|
break |
|
|
break |
|
|
case 'fitness_record': |
|
|
case 'view': |
|
|
this.switch_tags_type = 4 |
|
|
// 查看学员详情 |
|
|
|
|
|
this.viewStudentDetail(student) |
|
|
break |
|
|
break |
|
|
case 'study_plan': |
|
|
case 'delete': |
|
|
this.switch_tags_type = 5 |
|
|
// 删除学员 |
|
|
|
|
|
this.confirmDeleteStudent(student) |
|
|
break |
|
|
break |
|
|
|
|
|
default: |
|
|
|
|
|
console.log('未处理的学员操作:', action) |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
@ -1011,15 +1017,100 @@ export default { |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 打开编辑学员信息弹窗 |
|
|
|
|
|
openEditStudentDialog(student) { |
|
|
|
|
|
// 确保组件已经挂载后再调用 |
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
if (this.$refs.studentEditPopup) { |
|
|
|
|
|
console.log('打开编辑学员弹窗,学员信息:', student) |
|
|
|
|
|
// 调用组件的 openEdit 方法并传入学员数据进行回显 |
|
|
|
|
|
this.$refs.studentEditPopup.openEdit(student) |
|
|
|
|
|
} else { |
|
|
|
|
|
console.error('studentEditPopup 组件引用不存在') |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: '组件加载中,请稍后再试', |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 查看学员详情 |
|
|
|
|
|
viewStudentDetail(student) { |
|
|
|
|
|
console.log('查看学员详情:', student) |
|
|
|
|
|
// 可以显示一个详情弹窗或跳转到详情页面 |
|
|
|
|
|
const detailInfo = ` |
|
|
|
|
|
姓名:${student.name} |
|
|
|
|
|
性别:${student.gender === 1 ? '男' : student.gender === 2 ? '女' : '未知'} |
|
|
|
|
|
年龄:${student.age || '未知'} |
|
|
|
|
|
生日:${student.birthday || '未知'} |
|
|
|
|
|
联系电话:${student.contact_phone || '未填写'} |
|
|
|
|
|
紧急联系人:${student.emergency_contact || '未填写'} |
|
|
|
|
|
备注:${student.note || '无'} |
|
|
|
|
|
状态:${student.status === 1 ? '有效' : '无效'} |
|
|
|
|
|
`.trim() |
|
|
|
|
|
|
|
|
|
|
|
uni.showModal({ |
|
|
|
|
|
title: '学员详情', |
|
|
|
|
|
content: detailInfo, |
|
|
|
|
|
showCancel: false, |
|
|
|
|
|
confirmText: '知道了' |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 确认删除学员 |
|
|
|
|
|
confirmDeleteStudent(student) { |
|
|
|
|
|
uni.showModal({ |
|
|
|
|
|
title: '确认删除', |
|
|
|
|
|
content: `确定要删除学员"${student.name}"吗?此操作无法撤销。`, |
|
|
|
|
|
success: (res) => { |
|
|
|
|
|
if (res.confirm) { |
|
|
|
|
|
this.deleteStudent(student) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 删除学员 |
|
|
|
|
|
async deleteStudent(student) { |
|
|
|
|
|
try { |
|
|
|
|
|
// 这里需要调用删除学员的API |
|
|
|
|
|
// const res = await apiRoute.deleteStudent({ student_id: student.id }) |
|
|
|
|
|
// if (res.code === 1) { |
|
|
|
|
|
uni.showToast({ title: '删除成功', icon: 'success' }) |
|
|
|
|
|
// 刷新学员列表 |
|
|
|
|
|
await this.getStudentList() |
|
|
|
|
|
// } else { |
|
|
|
|
|
// uni.showToast({ title: res.msg || '删除失败', icon: 'none' }) |
|
|
|
|
|
// } |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('删除学员失败:', error) |
|
|
|
|
|
uni.showToast({ title: '删除失败', icon: 'none' }) |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async handleStudentEditConfirm(result) { |
|
|
async handleStudentEditConfirm(result) { |
|
|
try { |
|
|
try { |
|
|
// 调用学生添加API接口 |
|
|
console.log('学员编辑确认结果:', result) |
|
|
const res = await apiRoute.xs_addStudent(result.studentData) |
|
|
|
|
|
|
|
|
let res |
|
|
|
|
|
if (result.isEditing) { |
|
|
|
|
|
// 编辑模式 - 调用学员信息更新API |
|
|
|
|
|
console.log('编辑学员信息:', result.studentData) |
|
|
|
|
|
res = await apiRoute.xs_editStudent(result.studentData) |
|
|
|
|
|
} else { |
|
|
|
|
|
// 新增模式 - 调用学员添加API |
|
|
|
|
|
console.log('新增学员信息:', result.studentData) |
|
|
|
|
|
res = await apiRoute.xs_addStudent(result.studentData) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (res.code === 1) { |
|
|
if (res.code === 1) { |
|
|
this.$refs.studentEditPopup.close() |
|
|
this.$refs.studentEditPopup.close() |
|
|
uni.showToast({ title: '保存成功', icon: 'success' }) |
|
|
uni.showToast({ |
|
|
|
|
|
title: result.isEditing ? '编辑成功' : '添加成功', |
|
|
|
|
|
icon: 'success' |
|
|
|
|
|
}) |
|
|
// 保存成功后刷新学生列表 |
|
|
// 保存成功后刷新学生列表 |
|
|
await this.getStudentList() |
|
|
await this.getStudentList() |
|
|
} else { |
|
|
} else { |
|
|
|