浏览代码

fix(table): resetCondition not effective

add nonPagination to control whether pagination is used
Casper Dai 3 年之前
父节点
当前提交
8442a0b6db

+ 1 - 0
src/components/table/GridTable/index.vue

@@ -83,6 +83,7 @@
         v-bind="$attrs"
       />
       <pagination
+        v-if="isNeedPagination"
         :total="options.totalCount"
         :page.sync="options.params.pageNum"
         :limit.sync="options.params.pageSize"

+ 1 - 0
src/components/table/Table/index.vue

@@ -91,6 +91,7 @@
       />
     </el-table>
     <slot
+      v-if="isNeedPagination"
       name="pagination"
       :options="options"
       :pagination="onPagination"

+ 9 - 5
src/components/table/mixins/table.js

@@ -8,6 +8,7 @@ const ButtonConfig = {
 
 // {
 //   keepalive?: false,
+//   nonPagination?: false,
 //   singlePage?: false,
 //   pagination?: Object,
 //   condition?: Object,
@@ -78,6 +79,9 @@ export default {
     isManualPagination () {
       return this.schema.singlePage
     },
+    isNeedPagination () {
+      return !this.schema.nonPagination
+    },
     paginationConfig () {
       return this.schema.pagination
     }
@@ -141,7 +145,7 @@ export default {
             options.loading = false
             options.error = false
             options.totalCount = totalCount || data.length
-            if (this.isManualPagination) {
+            if (this.isNeedPagination && this.isManualPagination) {
               const { pageNum, pageSize } = options.params
               data = data.slice((pageNum - 1) * pageSize, pageNum * pageSize)
             }
@@ -201,18 +205,18 @@ export default {
     resetCondition (condition) {
       const params = this.options.params
       condition && Object.keys(condition).forEach(key => {
-        const paramValue = params[key]
-        if (paramValue != null && paramValue !== '') {
+        const paramValue = params[key] ?? ''
+        if (paramValue !== '') {
           const value = condition[key]
           const filter = this.filterMap[key]
-          switch (filter?.key) {
+          switch (filter?.type) {
             case 'select':
               if (paramValue !== value) {
                 params[key] = filter.placeholder ? void 0 : value
               }
               break
             case 'search':
-              if (new RegExp(paramValue).test(value)) {
+              if (!new RegExp(paramValue).test(value)) {
                 params[key] = ''
               }
               break