lrf402788946 5 роки тому
батько
коміт
09522a55d8
3 змінених файлів з 37 додано та 31 видалено
  1. 9 9
      src/views/jobfair/list.vue
  2. 10 8
      src/views/jobs/list.vue
  3. 18 14
      src/views/talk/list.vue

+ 9 - 9
src/views/jobfair/list.vue

@@ -69,14 +69,19 @@ export default {
     currentPage: 1,
     list: [],
     totalRow: 0,
-    type: '',
   }),
   created() {
-    this.$set(this, `type`, this.$route.params.type);
     this.search();
   },
   mounted() {},
-  computed: {},
+  computed: {
+    type() {
+      return this.$route.params.type;
+    },
+  },
+  watch: {
+    type: 'search',
+  },
   methods: {
     ...mapActions(['jobfairOperation']),
     async search(page) {
@@ -85,7 +90,7 @@ export default {
         skip = (page - 1) * this.$limit;
       }
       let newData = { skip: skip, limit: this.$limit, ...this.searchInfo };
-      this.type === 'in' ? (newData['schid'] = 999991) : '';
+      this.type === 'in' ? (newData['schid'] = this.$site) : '';
       let result = await this.jobfairOperation({ type: 'list', data: newData });
       if (`${result.errcode}` === '0') {
         //给this=>vue的实例下在中的list属性,赋予result。data的值
@@ -96,11 +101,6 @@ export default {
       }
     },
   },
-  beforeRouteUpdate(to, from, next) {
-    this.$set(this, `type`, to.params.type);
-    this.search();
-    next();
-  },
 };
 </script>
 

+ 10 - 8
src/views/jobs/list.vue

@@ -66,12 +66,19 @@ export default {
     currentPage: 1,
     totalRow: 0,
     list: [],
-    type: '',
   }),
   created() {
     this.search();
+    // console.log(this.$route.params.type === 'official' ? 0 : 1);
+  },
+  computed: {
+    type() {
+      return this.$route.params.type === 'official' ? 0 : 1;
+    },
+  },
+  watch: {
+    type: 'search',
   },
-  computed: {},
   methods: {
     ...mapActions(['postOperation']),
     async search(page) {
@@ -80,7 +87,7 @@ export default {
         skip = (page - 1) * this.$limit;
       }
       let newData = { skip: skip, limit: this.$limit, ...this.searchInfo }; //schid: 99991,
-      this.type === 'official' ? (newData['is_practice'] = 0) : (newData['is_practice'] = 1);
+      newData['is_practice'] = this.type;
       let result = await this.postOperation({ type: 'list', data: newData });
       if (`${result.errcode}` === '0') {
         //给this=>vue的实例下在中的list属性,赋予result.data的值
@@ -91,11 +98,6 @@ export default {
       }
     },
   },
-  beforeRouteUpdate(to, from, next) {
-    this.$set(this, `type`, to.params.type);
-    this.search();
-    next();
-  },
 };
 </script>
 

+ 18 - 14
src/views/talk/list.vue

@@ -79,6 +79,7 @@
 
 <script>
 import { mapActions, mapState } from 'vuex';
+import _ from 'lodash';
 export default {
   name: 'list',
   props: {},
@@ -89,23 +90,34 @@ export default {
     currentPage: 1,
     totalRow: 0,
     list: [],
-    type: '',
   }),
   created() {
-    this.$set(this, `type`, this.$route.params.type);
-    this.$set(this.searchInfo, `date`, this.$route.query.date);
     this.search();
   },
-  computed: {},
+  computed: {
+    type() {
+      return this.$route.params.type;
+    },
+    date() {
+      return this.$route.query.date;
+    },
+  },
+  watch: {
+    type: 'search',
+    date: 'search',
+  },
   methods: {
     ...mapActions(['postTalksInfo']),
     async search(page) {
       let skip = 0;
-      if (page) {
+      if (page && _.isNumber(page)) {
         skip = (page - 1) * this.$limit;
       }
+      if (this.date) {
+        this.searchInfo['date'] = this.date;
+      }
       let newData = { skip: skip, limit: this.$limit, ...this.searchInfo };
-      this.type === 'in' ? (newData['schid'] = 999991) : '';
+      this.type === 'in' ? (newData['schid'] = this.$site) : '';
       let result = await this.postTalksInfo({ type: 'list', data: newData });
       if (`${result.errcode}` === '0') {
         //给this=>vue的实例下在中的list属性,赋予result。data的值
@@ -116,14 +128,6 @@ export default {
       }
     },
   },
-  beforeRouteUpdate(to, from, next) {
-    console.log(`to`);
-    console.log(to);
-    this.$set(this.searchInfo, `date`, to.query.date);
-    this.$set(this, `type`, to.params.type);
-    this.search();
-    next();
-  },
 };
 </script>