Browse Source

条件查询

lrf402788946 4 years ago
parent
commit
e272eee644
1 changed files with 9 additions and 4 deletions
  1. 9 4
      src/components/list/list-page.vue

+ 9 - 4
src/components/list/list-page.vue

@@ -50,7 +50,7 @@ export default {
     displayList: { type: Array, default: () => [] },
     dropList: { type: Array, default: () => [] },
     list: { type: Array, default: () => [] },
-    searchModel: { type: String, default: 'title' },
+    searchModel: { type: String, default: 'name' },
     title: { type: String },
     total: { type: Number, default: 0 },
     pageSize: { type: Number, default: 5 },
@@ -59,7 +59,7 @@ export default {
   components: { tabs, search },
   data: function() {
     return {
-      searchInfo: '',
+      searchInfo: undefined,
       currentPage: 1,
       condition: {},
     };
@@ -71,18 +71,23 @@ export default {
       const skip = (this.currentPage - 1) * this.pageSize;
       let condition = { skip, limit: this.pageSize, ...this.condition };
       if (this.searchInfo && this.searchInfo !== '') condition[this.searchModel] = this.searchInfo;
+      console.log(condition);
       this.$emit('toSearch', condition);
     },
     toSearch(condition) {
-      if (condition && condition !== '') {
+      if (condition) {
         this.$set(this, `searchInfo`, condition);
+      } else {
+        this.$set(this, `searchInfo`, undefined);
       }
       this.currentPage = 1;
       this.search();
     },
     change(condition) {
       this.$set(this, `condition`, condition);
-      this.$emit('toChangeTab', condition);
+      this.currentPage = 1;
+      this.search();
+      // this.$emit('toChangeTab', condition);
     },
   },
   computed: {