Browse Source

班级课表选择教师,同一科目统一一个教师

lrf402788946 5 years ago
parent
commit
eebe22663a
2 changed files with 55 additions and 3 deletions
  1. 17 1
      src/views/train-plan/parts/class-table.vue
  2. 38 2
      src/views/train-plan/term-lesson.vue

+ 17 - 1
src/views/train-plan/parts/class-table.vue

@@ -169,6 +169,7 @@ export default {
       }
       obj = this.resetData(obj, num);
       this.$set(this.lessonList, yIndex, { ...this.lessonList[yIndex], ...obj });
+      this.setSubTea();
       this.drawer = false;
     },
     //提交整理数据
@@ -258,7 +259,22 @@ export default {
       if (_.get(data, 'teaname')) obj[`teaname_day${index}`] = _.get(data, 'teaname');
       return obj;
     },
-    //修改:
+    //修改:选择科目/教师后,将次科目的所有数据统一
+    setSubTea() {
+      let duplicate = _.cloneDeep(this.lessonList);
+      let arr = this.returnData(duplicate);
+      let teaList = arr.filter(f => f.teaid);
+      let res = arr.map(i => {
+        let r = teaList.find(f => f.subid == i.subid);
+        if (r) {
+          i.teaid = r.teaid;
+          i.teaname = r.teaname;
+        }
+        return i;
+      });
+      res = this.aData(res);
+      this.$set(this, 'lessonList', res);
+    },
     //根据时间排序
     getOrderForTime(data) {
       let duplicate = JSON.parse(JSON.stringify(data));

+ 38 - 2
src/views/train-plan/term-lesson.vue

@@ -5,18 +5,54 @@
 </template>
 
 <script>
+import _ from 'lodash';
 import detailFrame from '@frame/layout/admin/detail-frame';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: lesson } = createNamespacedHelpers('lesson');
+const { mapActions: classes } = createNamespacedHelpers('classes');
 export default {
   name: 'term-lesson',
   props: {},
   components: { detailFrame },
   data: function() {
-    return {};
+    return {
+      options: {},
+      lessonList: [],
+      classList: [],
+    };
   },
   created() {},
-  methods: {},
+  methods: {
+    ...lesson({ getLesson: 'query' }),
+    ...classes({ getClass: 'query' }),
+    async search() {
+      let termid = _.get(this.defaultOption, `termid`);
+      if (!termid) return;
+      let lessons = await this.getLesson({ termid });
+      if (this.$checkRes(lessons)) this.$set(this, `lessonList`, lessons.data);
+      let classes = await this.getClass({ termid });
+      if (this.$checkRes(classes)) this.$set(this, `classList`, classes.data);
+    },
+  },
+  watch: {
+    defaultOption: {
+      immediate: true,
+      deep: true,
+      handler(val) {
+        if (!_.get(this, 'options')) {
+          this.$set(this, `options`, _.cloneDeep(val));
+          this.search();
+        } else {
+          let ntermid = _.get(val, 'termid');
+          let otermid = _.get(this.options, 'termid');
+          if (ntermid && !_.isEqual(ntermid, otermid)) {
+            this.$set(this, `options`, _.cloneDeep(val));
+            this.search();
+          }
+        }
+      },
+    },
+  },
   computed: {
     ...mapState(['user', 'defaultOption']),
     pageTitle() {