lrf402788946 před 4 roky
rodič
revize
9050c8b948
1 změnil soubory, kde provedl 37 přidání a 2 odebrání
  1. 37 2
      layout/admin/navBar/default-select.vue

+ 37 - 2
layout/admin/navBar/default-select.vue

@@ -47,6 +47,7 @@
 
 <script>
 import _ from 'lodash';
+const moment = require('moment');
 import { mapState, mapMutations, createNamespacedHelpers } from 'vuex';
 const { mapActions: trainBatch } = createNamespacedHelpers('trainBatch');
 const { mapActions: trainplan } = createNamespacedHelpers('trainplan');
@@ -147,15 +148,49 @@ export default {
       let planid = _.get(this.defaultOption, 'planid');
       if (!termid) return;
       let res;
+      let orginList = [];
       if (this.user.type == 1) {
-        res = await this.getClassList({ termid: this.defaultOption.termid, headteacherid: this.user.userid });
-        if (this.$checkRes(res)) this.$set(this, `classList`, res.data);
+        res = await this.getClassList({ planid: planid, headteacherid: this.user.userid });
+        if (this.$checkRes(res)) {
+          orginList = res.data;
+          this.$set(
+            this,
+            `classList`,
+            res.data.filter(f => f.termid == termid)
+          );
+        }
       }
       if (this.user.type == 3) {
         res = await this.teaclass({ planid: planid, teaid: this.user.userid });
+        orginList = res.data;
         const elm = res.data.filter(item => item.termid == termid);
         this.$set(this, `classList`, elm);
       }
+      //班级数据正确验证
+      let options = _.cloneDeep(this.options);
+      if (this.classList.length <= 0) {
+        delete options.classid;
+        this.$set(this, `options`, options);
+      } else {
+        let res = await this.classList.find(f => f._id === options.classid);
+        if (!res) {
+          delete options.classid;
+          this.$set(this, `options`, options);
+        }
+      }
+      //教师/班主任,如果今天有班级选择
+      for (const i of orginList) {
+        const { startdate, enddate } = i;
+        const r = moment().isBetween(startdate, enddate, null, '[]');
+        if (r) {
+          const { _id, termid } = i;
+          let options = _.cloneDeep(this.options);
+          options.classid = _id;
+          options.termid = termid;
+          this.$set(this, `options`, options);
+          break;
+        }
+      }
     },
   },
   watch: {