|
|
|
@ -194,7 +194,7 @@ |
|
|
|
size="mini" |
|
|
|
class="remark-btn" |
|
|
|
@click="openAddRemark(v)"> |
|
|
|
添加备注 |
|
|
|
{{v.remarks ? '修改备注' : '添加备注'}} |
|
|
|
</button> |
|
|
|
</view> |
|
|
|
<view class="call-remark"> |
|
|
|
@ -218,7 +218,7 @@ |
|
|
|
<uni-popup ref="remarkPopup" type="dialog"> |
|
|
|
<view class="custom-popup-dialog"> |
|
|
|
<view class="dialog-header"> |
|
|
|
<text class="dialog-title">通话备注</text> |
|
|
|
<text class="dialog-title">{{currentRecord && currentRecord.remarks ? '修改备注' : '添加备注'}}</text> |
|
|
|
</view> |
|
|
|
<view class="dialog-content"> |
|
|
|
<view class="remark-textarea-container"> |
|
|
|
@ -248,45 +248,48 @@ |
|
|
|
<view class="course-edit-container"> |
|
|
|
<view class="edit-section"> |
|
|
|
<view class="section-title">主教练(单选)</view> |
|
|
|
<view v-if="coachList.length === 0" class="empty-tip">暂无主教练数据</view> |
|
|
|
<view class="coach-list"> |
|
|
|
<view |
|
|
|
v-for="coach in coachList" |
|
|
|
:key="coach.id" |
|
|
|
:key="coach.person_id" |
|
|
|
class="coach-item" |
|
|
|
:class="{selected: selectedMainCoach === coach.id}" |
|
|
|
@click="selectMainCoach(coach.id)"> |
|
|
|
:class="{selected: selectedMainCoach === coach.person_id}" |
|
|
|
@click="selectMainCoach(coach.person_id)"> |
|
|
|
<view class="coach-name">{{ coach.name }}</view> |
|
|
|
<view class="coach-check" v-if="selectedMainCoach === coach.id">✓</view> |
|
|
|
<view class="coach-check" v-if="selectedMainCoach === coach.person_id">✓</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<view class="edit-section"> |
|
|
|
<view class="section-title">教务(单选)</view> |
|
|
|
<view v-if="educationList.length === 0" class="empty-tip">暂无教务数据</view> |
|
|
|
<view class="coach-list"> |
|
|
|
<view |
|
|
|
v-for="education in educationList" |
|
|
|
:key="education.id" |
|
|
|
:key="education.person_id" |
|
|
|
class="coach-item" |
|
|
|
:class="{selected: selectedEducation === education.id}" |
|
|
|
@click="selectEducation(education.id)"> |
|
|
|
:class="{selected: selectedEducation === education.person_id}" |
|
|
|
@click="selectEducation(education.person_id)"> |
|
|
|
<view class="coach-name">{{ education.name }}</view> |
|
|
|
<view class="coach-check" v-if="selectedEducation === education.id">✓</view> |
|
|
|
<view class="coach-check" v-if="selectedEducation === education.person_id">✓</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<view class="edit-section"> |
|
|
|
<view class="section-title">助教(多选)</view> |
|
|
|
<view v-if="assistantList.length === 0" class="empty-tip">暂无助教数据</view> |
|
|
|
<view class="coach-list"> |
|
|
|
<view |
|
|
|
v-for="assistant in assistantList" |
|
|
|
:key="assistant.id" |
|
|
|
:key="assistant.person_id" |
|
|
|
class="coach-item" |
|
|
|
:class="{selected: selectedAssistants.includes(assistant.id)}" |
|
|
|
@click="toggleAssistant(assistant.id)"> |
|
|
|
:class="{selected: selectedAssistants.includes(assistant.person_id)}" |
|
|
|
@click="toggleAssistant(assistant.person_id)"> |
|
|
|
<view class="coach-name">{{ assistant.name }}</view> |
|
|
|
<view class="coach-check" v-if="selectedAssistants.includes(assistant.id)">✓</view> |
|
|
|
<view class="coach-check" v-if="selectedAssistants.includes(assistant.person_id)">✓</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
@ -621,7 +624,7 @@ |
|
|
|
|
|
|
|
// 打开添加备注弹窗 |
|
|
|
openAddRemark(record) { |
|
|
|
this.remark_content = ''; |
|
|
|
this.remark_content = record.remarks || ''; // 如果有现有备注,显示出来 |
|
|
|
this.currentRecord = record; |
|
|
|
this.$refs.remarkPopup.open(); |
|
|
|
}, |
|
|
|
@ -636,50 +639,52 @@ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 检查是否选中了通话记录 |
|
|
|
if (!this.currentRecord || !this.currentRecord.id) { |
|
|
|
uni.showToast({ |
|
|
|
title: '未选中通话记录', |
|
|
|
icon: 'none' |
|
|
|
}); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
uni.showLoading({ |
|
|
|
title: '提交中...', |
|
|
|
mask: true |
|
|
|
}); |
|
|
|
|
|
|
|
// 使用更新备注的接口而不是添加新记录 |
|
|
|
const params = { |
|
|
|
staff_id: this.userInfo.id, // 员工id |
|
|
|
resource_id: this.clientInfo.resource_id, // 资源ID |
|
|
|
resource_type: '', // 资源类型 |
|
|
|
communication_type: 'note', // 沟通类型: phone-电话, note-备注 |
|
|
|
communication_result: 'success', // 沟通结果 |
|
|
|
remarks: this.remark_content, // 备注内容 |
|
|
|
tag: null // 标签 |
|
|
|
id: this.currentRecord.id, // 通话记录ID |
|
|
|
remarks: this.remark_content // 备注内容 |
|
|
|
}; |
|
|
|
|
|
|
|
// 如果是针对特定通话记录的备注,添加关联ID |
|
|
|
if (this.currentRecord && this.currentRecord.id) { |
|
|
|
params.related_record_id = this.currentRecord.id; // 关联的通话记录ID |
|
|
|
console.log('添加备注到通话记录:', this.currentRecord); |
|
|
|
} |
|
|
|
console.log('更新通话记录备注:', params); |
|
|
|
|
|
|
|
const res = await apiRoute.xs_communicationRecordsAdd(params); |
|
|
|
// 调用更新备注的接口 |
|
|
|
const res = await apiRoute.xs_communicationRecordsEdit(params); |
|
|
|
|
|
|
|
if (res.code !== 1) { |
|
|
|
uni.showToast({ |
|
|
|
title: res.msg || '添加备注失败', |
|
|
|
title: res.msg || '更新备注失败', |
|
|
|
icon: 'none' |
|
|
|
}); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
uni.showToast({ |
|
|
|
title: '添加备注成功', |
|
|
|
title: '备注更新成功', |
|
|
|
icon: 'success' |
|
|
|
}); |
|
|
|
|
|
|
|
// 刷新通话记录列表 |
|
|
|
this.getListCallUp(); |
|
|
|
await this.getListCallUp(); |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
console.error('添加备注失败:', error); |
|
|
|
console.error('更新备注失败:', error); |
|
|
|
uni.showToast({ |
|
|
|
title: '添加备注失败,请重试', |
|
|
|
title: '更新备注失败,请重试', |
|
|
|
icon: 'none' |
|
|
|
}); |
|
|
|
} finally { |
|
|
|
@ -820,61 +825,67 @@ |
|
|
|
// 获取人员列表(教练、教务、助教) |
|
|
|
async getPersonnelList() { |
|
|
|
try { |
|
|
|
// 使用新的获取人员列表API |
|
|
|
try { |
|
|
|
const res = await apiRoute.getPersonnelList(); |
|
|
|
if (res.code === 1 && res.data) { |
|
|
|
const personnel = res.data || []; |
|
|
|
|
|
|
|
// 按角色分类人员 - 根据实际数据结构调整 |
|
|
|
this.coachList = personnel.filter(p => { |
|
|
|
return p.role_name && ( |
|
|
|
p.role_name.includes('教练') || |
|
|
|
p.role_name.includes('教师') || |
|
|
|
(p.roles && p.roles.some(role => role.includes('教练') || role.includes('教师'))) |
|
|
|
); |
|
|
|
}); |
|
|
|
|
|
|
|
this.educationList = personnel.filter(p => { |
|
|
|
return p.role_name && ( |
|
|
|
p.role_name.includes('教务') || |
|
|
|
(p.roles && p.roles.some(role => role.includes('教务'))) |
|
|
|
); |
|
|
|
}); |
|
|
|
|
|
|
|
this.assistantList = personnel.filter(p => { |
|
|
|
return p.role_name && ( |
|
|
|
p.role_name.includes('助教') || |
|
|
|
(p.roles && p.roles.some(role => role.includes('助教'))) |
|
|
|
); |
|
|
|
}); |
|
|
|
|
|
|
|
console.log('getPersonnelList - 人员列表获取成功'); |
|
|
|
console.log('教练列表:', this.coachList); |
|
|
|
console.log('教务列表:', this.educationList); |
|
|
|
console.log('助教列表:', this.assistantList); |
|
|
|
return true; |
|
|
|
} else { |
|
|
|
console.warn('API返回错误:', res.msg); |
|
|
|
throw new Error(res.msg); |
|
|
|
} |
|
|
|
} catch (apiError) { |
|
|
|
console.warn('使用API获取人员列表失败,使用模拟数据:', apiError); |
|
|
|
console.log('getPersonnelList - 开始获取教练数据'); |
|
|
|
|
|
|
|
uni.showLoading({ |
|
|
|
title: '获取教练数据...' |
|
|
|
}); |
|
|
|
|
|
|
|
const res = await apiRoute.common_getCoachList(); |
|
|
|
console.log('getPersonnelList - API响应:', res); |
|
|
|
|
|
|
|
uni.hideLoading(); |
|
|
|
|
|
|
|
if (res.code === 1 && res.data) { |
|
|
|
// 直接使用后端返回的分类数据 |
|
|
|
this.coachList = res.data.coach_list || []; |
|
|
|
this.educationList = res.data.education_list || []; |
|
|
|
this.assistantList = res.data.assistant_list || []; |
|
|
|
|
|
|
|
console.log('getPersonnelList - 教练数据获取成功'); |
|
|
|
console.log('教练列表:', this.coachList); |
|
|
|
console.log('教务列表:', this.educationList); |
|
|
|
console.log('助教列表:', this.assistantList); |
|
|
|
return true; |
|
|
|
} else { |
|
|
|
console.warn('API返回错误:', res); |
|
|
|
|
|
|
|
// 显示API错误信息 |
|
|
|
uni.showToast({ |
|
|
|
title: res.msg || '获取教练数据失败', |
|
|
|
icon: 'none' |
|
|
|
}); |
|
|
|
|
|
|
|
// 如果API调用失败,使用模拟数据 |
|
|
|
this.coachList = this.getMockCoachList(); |
|
|
|
this.educationList = this.getMockEducationList(); |
|
|
|
this.assistantList = this.getMockAssistantList(); |
|
|
|
|
|
|
|
console.log('getPersonnelList - 使用模拟人员数据'); |
|
|
|
console.log('getPersonnelList - 使用模拟教练数据'); |
|
|
|
console.log('模拟教练列表:', this.coachList); |
|
|
|
console.log('模拟教务列表:', this.educationList); |
|
|
|
console.log('模拟助教列表:', this.assistantList); |
|
|
|
return true; |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('getPersonnelList - 获取人员列表异常:', error); |
|
|
|
console.error('getPersonnelList - 获取教练列表异常:', error); |
|
|
|
uni.hideLoading(); |
|
|
|
|
|
|
|
// 显示错误信息 |
|
|
|
uni.showToast({ |
|
|
|
title: '网络错误,使用模拟数据', |
|
|
|
icon: 'none' |
|
|
|
}); |
|
|
|
|
|
|
|
// 降级到模拟数据 |
|
|
|
this.coachList = this.getMockCoachList(); |
|
|
|
this.educationList = this.getMockEducationList(); |
|
|
|
this.assistantList = this.getMockAssistantList(); |
|
|
|
|
|
|
|
console.log('getPersonnelList - 使用模拟教练数据(异常情况)'); |
|
|
|
console.log('模拟教练列表:', this.coachList); |
|
|
|
console.log('模拟教务列表:', this.educationList); |
|
|
|
console.log('模拟助教列表:', this.assistantList); |
|
|
|
return false; |
|
|
|
} |
|
|
|
}, |
|
|
|
@ -882,60 +893,86 @@ |
|
|
|
// 获取模拟教练数据 |
|
|
|
getMockCoachList() { |
|
|
|
return [ |
|
|
|
{ id: 1, name: '张教练' }, |
|
|
|
{ id: 5, name: '陈教练' }, |
|
|
|
{ id: 7, name: '刘教练' } |
|
|
|
{ id: 1, person_id: 1, name: '张教练', head_img: '', phone: '' }, |
|
|
|
{ id: 5, person_id: 5, name: '陈教练', head_img: '', phone: '' }, |
|
|
|
{ id: 7, person_id: 7, name: '刘教练', head_img: '', phone: '' } |
|
|
|
]; |
|
|
|
}, |
|
|
|
|
|
|
|
// 获取模拟教务数据 |
|
|
|
getMockEducationList() { |
|
|
|
return [ |
|
|
|
{ id: 2, name: '李教务' }, |
|
|
|
{ id: 8, name: '周教务' } |
|
|
|
{ id: 2, person_id: 2, name: '李教务', head_img: '', phone: '' }, |
|
|
|
{ id: 8, person_id: 8, name: '周教务', head_img: '', phone: '' } |
|
|
|
]; |
|
|
|
}, |
|
|
|
|
|
|
|
// 获取模拟助教数据 |
|
|
|
getMockAssistantList() { |
|
|
|
return [ |
|
|
|
{ id: 3, name: '王助教' }, |
|
|
|
{ id: 4, name: '赵助教' }, |
|
|
|
{ id: 6, name: '孙助教' }, |
|
|
|
{ id: 9, name: '钱助教' } |
|
|
|
{ id: 3, person_id: 3, name: '王助教', head_img: '', phone: '' }, |
|
|
|
{ id: 4, person_id: 4, name: '赵助教', head_img: '', phone: '' }, |
|
|
|
{ id: 6, person_id: 6, name: '孙助教', head_img: '', phone: '' }, |
|
|
|
{ id: 9, person_id: 9, name: '钱助教', head_img: '', phone: '' } |
|
|
|
]; |
|
|
|
}, |
|
|
|
|
|
|
|
// 打开课程编辑弹窗 |
|
|
|
openCourseEditDialog(course) { |
|
|
|
async openCourseEditDialog(course) { |
|
|
|
this.currentCourse = course; |
|
|
|
|
|
|
|
// 设置当前选中的配置 |
|
|
|
// 确保教练数据已加载 |
|
|
|
console.log('打开教练配置弹窗,检查教练数据:', { |
|
|
|
coachList: this.coachList, |
|
|
|
educationList: this.educationList, |
|
|
|
assistantList: this.assistantList |
|
|
|
}); |
|
|
|
|
|
|
|
// 如果教练数据为空,重新获取 |
|
|
|
if (!this.coachList.length && !this.educationList.length && !this.assistantList.length) { |
|
|
|
console.log('教练数据为空,重新获取...'); |
|
|
|
await this.getPersonnelList(); |
|
|
|
} |
|
|
|
|
|
|
|
// 设置当前选中的配置,使用person_id进行回显 |
|
|
|
this.selectedMainCoach = course.main_coach_id; |
|
|
|
this.selectedEducation = course.education_id; |
|
|
|
this.selectedAssistants = course.assistant_ids ? course.assistant_ids.split(',').map(Number) : []; |
|
|
|
|
|
|
|
console.log('打开教练配置弹窗:', { |
|
|
|
course: course, |
|
|
|
selectedMainCoach: this.selectedMainCoach, |
|
|
|
selectedEducation: this.selectedEducation, |
|
|
|
selectedAssistants: this.selectedAssistants, |
|
|
|
coachListLength: this.coachList.length, |
|
|
|
educationListLength: this.educationList.length, |
|
|
|
assistantListLength: this.assistantList.length |
|
|
|
}); |
|
|
|
|
|
|
|
this.$refs.courseEditPopup.open(); |
|
|
|
}, |
|
|
|
|
|
|
|
// 选择主教练 |
|
|
|
selectMainCoach(coachId) { |
|
|
|
this.selectedMainCoach = coachId; |
|
|
|
selectMainCoach(personId) { |
|
|
|
this.selectedMainCoach = personId; |
|
|
|
console.log('选择主教练:', personId); |
|
|
|
}, |
|
|
|
|
|
|
|
// 选择教务 |
|
|
|
selectEducation(educationId) { |
|
|
|
this.selectedEducation = educationId; |
|
|
|
selectEducation(personId) { |
|
|
|
this.selectedEducation = personId; |
|
|
|
console.log('选择教务:', personId); |
|
|
|
}, |
|
|
|
|
|
|
|
// 切换助教选择 |
|
|
|
toggleAssistant(assistantId) { |
|
|
|
const index = this.selectedAssistants.indexOf(assistantId); |
|
|
|
toggleAssistant(personId) { |
|
|
|
const index = this.selectedAssistants.indexOf(personId); |
|
|
|
if (index > -1) { |
|
|
|
this.selectedAssistants.splice(index, 1); |
|
|
|
} else { |
|
|
|
this.selectedAssistants.push(assistantId); |
|
|
|
this.selectedAssistants.push(personId); |
|
|
|
} |
|
|
|
console.log('切换助教选择:', personId, '当前选中:', this.selectedAssistants); |
|
|
|
}, |
|
|
|
|
|
|
|
// 确认修改教练配置 |
|
|
|
@ -948,9 +985,9 @@ |
|
|
|
|
|
|
|
const params = { |
|
|
|
student_course_id: this.currentCourse.id, |
|
|
|
main_coach_id: this.selectedMainCoach, |
|
|
|
education_id: this.selectedEducation, |
|
|
|
assistant_ids: this.selectedAssistants.join(',') |
|
|
|
main_coach_id: this.selectedMainCoach, // 使用person_id |
|
|
|
education_id: this.selectedEducation, // 使用person_id |
|
|
|
assistant_ids: this.selectedAssistants.join(',') // 使用person_id数组 |
|
|
|
}; |
|
|
|
|
|
|
|
console.log('准备保存教练配置:', params); |
|
|
|
@ -981,22 +1018,22 @@ |
|
|
|
const courseIndex = this.courseInfo.findIndex(c => c.id === this.currentCourse.id); |
|
|
|
if (courseIndex > -1) { |
|
|
|
// 更新主教练 |
|
|
|
const mainCoach = this.coachList.find(c => c.id === this.selectedMainCoach); |
|
|
|
const mainCoach = this.coachList.find(c => c.person_id === this.selectedMainCoach); |
|
|
|
if (mainCoach) { |
|
|
|
this.courseInfo[courseIndex].main_coach_id = this.selectedMainCoach; |
|
|
|
this.courseInfo[courseIndex].main_coach_name = mainCoach.name; |
|
|
|
} |
|
|
|
|
|
|
|
// 更新教务 |
|
|
|
const education = this.educationList.find(e => e.id === this.selectedEducation); |
|
|
|
const education = this.educationList.find(e => e.person_id === this.selectedEducation); |
|
|
|
if (education) { |
|
|
|
this.courseInfo[courseIndex].education_id = this.selectedEducation; |
|
|
|
this.courseInfo[courseIndex].education_name = education.name; |
|
|
|
} |
|
|
|
|
|
|
|
// 更新助教 |
|
|
|
const assistantNames = this.selectedAssistants.map(id => { |
|
|
|
const assistant = this.assistantList.find(a => a.id === id); |
|
|
|
const assistantNames = this.selectedAssistants.map(personId => { |
|
|
|
const assistant = this.assistantList.find(a => a.person_id === personId); |
|
|
|
return assistant ? assistant.name : ''; |
|
|
|
}).filter(name => name).join(', '); |
|
|
|
|
|
|
|
@ -1754,4 +1791,11 @@ |
|
|
|
width: 40rpx; |
|
|
|
text-align: center; |
|
|
|
} |
|
|
|
|
|
|
|
.empty-tip { |
|
|
|
color: #999; |
|
|
|
font-size: 28rpx; |
|
|
|
text-align: center; |
|
|
|
padding: 40rpx 0; |
|
|
|
} |
|
|
|
</style> |