guhongwei 4 years ago
parent
commit
7651e0338e
1 changed files with 42 additions and 5 deletions
  1. 42 5
      src/views/home.vue

+ 42 - 5
src/views/home.vue

@@ -30,6 +30,8 @@
 import _ from 'lodash';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: classes } = createNamespacedHelpers('classes');
+const { mapActions: trainplan } = createNamespacedHelpers('trainplan');
+const { mapActions: director } = createNamespacedHelpers('director');
 export default {
   name: 'home',
   props: {},
@@ -38,27 +40,62 @@ export default {
     return {
       loading: true,
       list: [],
+      // 班主任
+      dirList: [],
     };
   },
-  created() {
+  async created() {
+    await this.getOtherList();
     this.search();
   },
   methods: {
     ...classes(['query']),
+    ...director({ getDirList: 'query' }),
+    ...trainplan({ trainplanFetch: 'fetch', trainplanUpdate: 'update', updateclass: 'updateclass', updatereteacher: 'updatereteacher' }),
     async search() {
       let planid = _.get(this.defaultOption, 'planid');
-      let res = await this.query({ planid: planid, headteacherid: this.user.userid });
+      const res = await this.trainplanFetch(planid);
+      // let res = await this.query({ planid: planid, headteacherid: this.user.userid });
       if (res.errcode == 0) {
-        console.log(res.data);
-        this.$set(this, `list`, res.data);
+        let data = res.data.termnum;
+        //按期排序
+        data = data.map(i => {
+          i.term = i.term * 1;
+          return i;
+        });
+        data = _.orderBy(data, ['term'], ['asc']);
+        console.log(data);
+        let newData = [];
+        for (const termnum of data) {
+          for (const batchnum of termnum.batchnum) {
+            for (const classes of batchnum.class) {
+              const dirData = {
+                term: termnum.term,
+                startdate: batchnum.startdate,
+                enddate: batchnum.enddate,
+                name: classes.name,
+                headteacherid: classes.headteacherid,
+              };
+              let headteacherData = this.dirList.find(i => i.id == classes.headteacherid);
+              if (headteacherData) dirData.headteacher = headteacherData.name;
+              newData.push(dirData);
+            }
+          }
+        }
+        let dirClass = newData.filter(i => i.headteacherid == this.user.userid);
+        if (dirClass) this.$set(this, `list`, dirClass);
       }
-      console.log(res);
       this.loading = false;
     },
     getDay(date) {
       var str = '星期' + '日一二三四五六'.charAt(new Date(date).getDay());
       return str;
     },
+    // 查询部门加班主任
+    async getOtherList() {
+      let res = await this.getDirList();
+      if (this.$checkRes(res)) this.$set(this, `dirList`, res.data);
+    },
   },
   computed: {
     ...mapState(['user', 'defaultOption']),