diff --git a/api/member.js b/api/member.js
index 09ef174..8740ab2 100644
--- a/api/member.js
+++ b/api/member.js
@@ -170,6 +170,31 @@ export default {
})
},
+ //教练端-获取班级列表
+ jlGetClassesList(data = {}) {
+ let url = '/member/get_classes_list'
+ return http.get(url, data).then(res => {
+ return res;
+ })
+ },
+
+ //教练端-获取班级列表
+ jlGetCoursesList(data = {}) {
+ let url = '/member/get_courses_list'
+ return http.get(url, data).then(res => {
+ return res;
+ })
+ },
+
+ //教练端-获取学员列表
+ jlGetStudentList(data = {}) {
+ let url = '/member/student_list'
+ return http.get(url, data).then(res => {
+ return res;
+ })
+ },
+
+
diff --git a/pages/coach/job/add.vue b/pages/coach/job/add.vue
index 77fec73..7a45415 100644
--- a/pages/coach/job/add.vue
+++ b/pages/coach/job/add.vue
@@ -29,6 +29,25 @@
+
+
+
+
+
+
+
+
- 提交
+ 提交
@@ -61,34 +80,121 @@ export default {
return {
show_class:false,
show_course:false,
+ show_student:false,
+ //班级可选值列表
options_class_arr:[
- { value: 1, text: '班级1' },
- { value: 2, text: '班级2' },
- { value: 3, text: '班级3' }
+ // { value: 1, text: '班级1' },
],
+ //课程可选值列表
options_course_arr:[
- { value: 1, text: '课程1' },
- { value: 2, text: '课程2' },
- { value: 3, text: '课程3' }
+ // { value: 1, text: '课程1' },
+ ],
+ //学员可选值列表
+ options_student_arr:[
+ // {
+ // text: '标签3',
+ // value: '3',
+ // checked: false,//是否选中
+ // }
],
- formData:{
- type:'1',//作业类型(单选)
- class_name:'',//班级(下拉)
- class_id:'',//班级(下拉)
- course_name:'',//课程(下拉)
- course_id:'',//课程(下拉)
- homework:'',//作业(文本域)
+ //表单数据
+ formData: {
+ type: '1',//作业类型(单选)|1班级,2学员
+ course_id: '',//课程id(下拉)
+ course_id_name: '',//课程id(中文名字)
+
+ content_type: '',//作业类型(单选)|1图片,2视频
+ content_text: '',//文字作业内容
+
+ classes_id: '',//班级id(下拉)
+ classes_id_name: '',//班级id(中文名字)
+
+ students_ids: '',//学员id 逗号拼接
+ students_ids_name:'',//学员id数组(中文名字)
}
}
},
onLoad() {
+ },
+ onShow() {
+ this.init()
},
methods: {
+ //初始化
+ async init() {
+ // 获取班级-学员二级联动(用来获取班级列表)
+ this.getClassesList()
+ // 全部课程名称列表
+ this.getCoursesList()
+ // 学员列表
+ this.getStudentList()
+ },
+
+ //获取班级列表
+ async getClassesList(){
+ let res = await memberApi.jlGetClassesList({})
+ if(res.code != 1){
+ uni.showToast({
+ title: res.msg,
+ icon: 'none'
+ })
+ return
+ }
+ this.options_class_arr = []
+ res.data.forEach((v,k)=>{
+ this.options_class_arr.push({
+ text: v.name,
+ value: v.id,
+ })
+ })
+ },
+ //获取课程列表
+ async getCoursesList(){
+ let res = await memberApi.jlGetCoursesList({})
+ if(res.code != 1){
+ uni.showToast({
+ title: res.msg,
+ icon: 'none'
+ })
+ return
+ }
+
+ this.options_course_arr = []
+ res.data.forEach((v,k)=>{
+ this.options_course_arr.push({
+ text: v.name,
+ value: v.id,
+ })
+ })
+ },
+
+ //获取学员列表
+ async getStudentList() {
+ let res = await memberApi.jlGetStudentList({})
+ if (res.code != 1) {
+ uni.showToast({
+ title: res.msg,
+ icon: 'none'
+ })
+ return
+ }
+
+ this.options_student_arr = []
+ res.data.forEach((v, k) => {
+ this.options_student_arr.push({
+ text: v.name,
+ value: v.id,
+ checked: false,//是否选中
+ })
+ })
+ },
+
+
//监听选择器-班级
changeClass(e) {
console.log('选择器-班级', e);
@@ -103,14 +209,59 @@ export default {
this.formData.course_name = e.text; // 更新 course_name
this.show_course = false; // 关闭选择器
},
+ //监听选择器-学员
+ changeStudent(e) {
+ console.log('选择器-学员', e);
+ let id_arr = []
+ let name_arr = []
+ e.options.forEach((v,k)=>{
+ id_arr.push(v.value)
+ name_arr.push(v.text)
+ })
+ //数组转字符
+ this.formData.students_ids = id_arr.join(',')
+ this.formData.students_ids_name = name_arr.join(',')
+ this.show_student = false; // 关闭选择器
+ },
//监听选择器-作业类型
changeType(e) {
console.log('选择器-作业类型', e);
- this.formData.type = e.value; // 更新 type
+ this.formData.type = e.detail.value; // 更新 type
+
+ //1=班级作业
+ if(e.detail.value == 1){
+ //清空学员选择信息
+ this.formData.students_ids = ''
+ this.formData.students_ids_name = ''
+ }
},
//发布作业
+ async submetForm(){
+ let data = {...this.formData}
+ console.log('提交',data)
+ return
+
+ let res = await memberApi.jlPublishJob(data)
+ if (res.code != 1){
+ uni.showToast({
+ title: res.msg,
+ icon: 'none'
+ })
+ return
+ }
+ uni.showToast({
+ title: res.msg,
+ icon: 'success'
+ })
+ //延迟1s
+ setTimeout(() => {
+ uni.navigateTo({
+ url: '/pages/coach/home/index'
+ })
+ }, 1000)
+ },
}
}