guhongwei 4 years ago
parent
commit
20298f50ef
1 changed files with 9 additions and 11 deletions
  1. 9 11
      src/views/classes/parts/class-table.vue

+ 9 - 11
src/views/classes/parts/class-table.vue

@@ -135,7 +135,7 @@ export default {
     ...mapUtil(['fetch']),
     ...lesson(['query', 'create', 'update']),
     ...subject({ getSubject: 'query' }),
-    ...teacher({ getTeacher: 'query' }),
+    ...teacher({ getTeacher: 'query', lessonteafetch: 'lessonteafetch' }),
     ...school({ getSchool: 'query' }),
     async search() {
       let res = await this.fetch({ model: 'lesson', classid: _.get(this.classInfo, '_id') });
@@ -147,17 +147,10 @@ export default {
         this.$set(this, `lessonInfo`, _.omit(res.data, ['lessons']));
         let arr = _.get(res.data, `lessons`, []);
         this.$set(this, `oLessonList`, _.cloneDeep(arr));
+        this.seachTeacher();
         let x = this.getX(JSON.parse(JSON.stringify(arr)));
         this.getY(JSON.parse(JSON.stringify(arr)));
         this.$set(this, `dateList`, x);
-        // for (const val of arr) {
-        //   if (val.teaid) {
-        //     let teacher = this.teacherList.find(f => f.id == val.teaid);
-        //     if (teacher) {
-        //       val.teaphone = teacher.phone;
-        //     }
-        //   }
-        // }
         arr = this.aData(arr);
         console.log(arr);
         this.$set(this, `lessonList`, arr);
@@ -351,11 +344,16 @@ export default {
         arr.map(i => i.time)
       );
     },
-    //教师列表,课程列表
+    //课程列表
     async getOtherList() {
       let res = await this.getSubject();
       if (this.$checkRes(res)) this.$set(this, `subjectList`, res.data);
-      res = await this.getTeacher({ status: '4' });
+    },
+    async seachTeacher() {
+      let arr = this.oLessonList.filter(item => item.teaid != null);
+      let NewArr = _.uniqBy(arr, 'teaid');
+      var ids = NewArr.map(item => item.teaid);
+      let res = await this.lessonteafetch(ids);
       if (this.$checkRes(res)) this.$set(this, `teacherList`, res.data);
     },
     //关闭抽屉