From 35ad37642d24d1d555999fa5cd8e54fbbab5994a Mon Sep 17 00:00:00 2001 From: 梁灏 Date: Mon, 28 Nov 2016 16:53:19 +0800 Subject: [PATCH] update Table --- src/components/table/table-head.vue | 29 ++++++----------------------- src/components/table/table.vue | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------ test/routers/table.vue | 7 ++++++- 3 files changed, 77 insertions(+), 54 deletions(-) diff --git a/src/components/table/table-head.vue b/src/components/table/table-head.vue index c7646c4..1cf0484 100644 --- a/src/components/table/table-head.vue +++ b/src/components/table/table-head.vue @@ -11,8 +11,8 @@ @@ -36,11 +36,6 @@ objData: Object, fixed: Boolean }, - data () { - return { - sortType: 'normal' - } - }, computed: { isSelectAll () { let isSelectAll = true; @@ -74,23 +69,11 @@ const status = !this.isSelectAll; this.$parent.selectAll(status); }, - handleSortAsc (index) { - if (this.sortType === 'asc') { - this.sortType = 'normal'; - this.$parent.handleSort(index, 'normal'); - } else { - this.sortType = 'asc'; - this.$parent.handleSort(index, 'asc'); - } - }, - handleSortDesc (index) { - if (this.sortType === 'desc') { - this.sortType = 'normal'; - this.$parent.handleSort(index, 'normal'); - } else { - this.sortType = 'desc'; - this.$parent.handleSort(index, 'desc'); + handleSort (index, type) { + if (this.columns[index]._sortType === type) { + type = 'normal'; } + this.$parent.handleSort(index, type); } } } diff --git a/src/components/table/table.vue b/src/components/table/table.vue index 81748a7..243d660 100644 --- a/src/components/table/table.vue +++ b/src/components/table/table.vue @@ -1,5 +1,4 @@