Browse Source

修改初次加载顶部出问题

lrf402788946 5 years ago
parent
commit
d2c05026bc
1 changed files with 17 additions and 8 deletions
  1. 17 8
      layout/admin/navBar/default-select.vue

+ 17 - 8
layout/admin/navBar/default-select.vue

@@ -70,9 +70,9 @@ export default {
   async created() {
     // this.$set(this, `options`, _.cloneDeep(this.defaultOption));
     this.search({ type: 'planYear' });
-    this.checkOption();
-    if (this.user.type == 1 || this.user.type == 3) this.getClassOption();
-    this.loading = false;
+    // this.checkOption();
+    // if (this.user.type == 1 || this.user.type == 3) this.getClassOption();
+    // this.loading = false;
   },
   methods: {
     ...mapMutations(['deleteUser', 'changeOpt']),
@@ -81,6 +81,13 @@ export default {
     ...setting({ sFetch: 'fetch', sUpdate: 'update' }),
     ...classes({ getClassList: 'query' }), //仅供班主任使用
     ...lesson({ teaclass: 'teaclass' }), //仅供老师使用
+    checkOption() {
+      console.log(_.cloneDeep(this.options));
+      if (_.get(this.options, 'planid')) {
+        this.search({ type: 'plan', planyearid: _.get(this.options, 'planyearid') });
+      }
+      this.loading = false;
+    },
     async search({ type, ...info }) {
       let res = await _.get(this, `get${type}`)({ ...info });
       if (this.$checkRes(res)) {
@@ -93,11 +100,6 @@ export default {
         }
       }
     },
-    checkOption() {
-      if (_.get(this.options, 'planid')) {
-        this.search({ type: 'plan', planyearid: _.get(this.options, 'planyearid') });
-      }
-    },
     async changeList(type, data) {
       let obj = { type };
       let res;
@@ -169,6 +171,13 @@ export default {
       immediate: true,
       deep: true,
     },
+    options: {
+      immediate: true,
+      deep: true,
+      handler(val, oval) {
+        if (!_.isEqual(val, oval) && val) this.checkOption();
+      },
+    },
   },
   computed: {
     ...mapState(['user', 'defaultOption']),