diff --git a/src/components/table/table-body.vue b/src/components/table/table-body.vue index a472d8f5..7216a2ed 100644 --- a/src/components/table/table-body.vue +++ b/src/components/table/table-body.vue @@ -6,10 +6,10 @@ + :class="rowClasses(row._index)" + @mouseenter.stop="handleMouseIn(row._index)" + @mouseleave.stop="handleMouseOut(row._index)" + @click.stop="highlightCurrentRow(row._index)"> + :checked="rowChecked(row._index)"> @@ -36,40 +36,37 @@ style: Object, columns: Array, data: Array, // rebuildData - cloneData: Array, objData: Object, fixed: Boolean }, methods: { - rowClasses (index, _index) { + rowClasses (_index) { return [ `${this.prefixCls}-row`, this.rowClsName(_index), { - [`${this.prefixCls}-row-highlight`]: this.cloneData[index] && this.cloneData[index]._isHighlight, - [`${this.prefixCls}-row-hover`]: this.cloneData[index] && this.cloneData[index]._isHover + [`${this.prefixCls}-row-highlight`]: this.objData[_index]._isHighlight, + [`${this.prefixCls}-row-hover`]: this.objData[_index]._isHover } ] }, - rowChecked (index, _index) { -// const data = this.cloneData.filter(row => row._index === _index); -// return data && data._isChecked; + rowChecked (_index) { return this.objData[_index]._isChecked; }, setCellWidth (column, index) { return this.$parent.setCellWidth(column, index); }, - rowClsName (index) { - return this.$parent.rowClassName(this.cloneData[index], index); + rowClsName (_index) { + return this.$parent.rowClassName(this.objData[_index], _index); }, - handleMouseIn (index) { - this.$parent.handleMouseIn(index); + handleMouseIn (_index) { + this.$parent.handleMouseIn(_index); }, - handleMouseOut (index) { - this.$parent.handleMouseOut(index); + handleMouseOut (_index) { + this.$parent.handleMouseOut(_index); }, - highlightCurrentRow (index) { - this.$parent.highlightCurrentRow(index); + highlightCurrentRow (_index) { + this.$parent.highlightCurrentRow(_index); } } } diff --git a/src/components/table/table-head.vue b/src/components/table/table-head.vue index b1eb2b13..c7646c44 100644 --- a/src/components/table/table-head.vue +++ b/src/components/table/table-head.vue @@ -33,7 +33,7 @@ prefixCls: String, style: Object, columns: Array, - cloneData: Array, + objData: Object, fixed: Boolean }, data () { @@ -43,7 +43,12 @@ }, computed: { isSelectAll () { - return !this.cloneData.some(data => !data._isChecked); + let isSelectAll = true; + for (let i in this.objData) { + if (!this.objData[i]._isChecked) isSelectAll = false; + } + + return isSelectAll; } }, methods: { diff --git a/src/components/table/table.vue b/src/components/table/table.vue index 1c599b97..81748a72 100644 --- a/src/components/table/table.vue +++ b/src/components/table/table.vue @@ -1,5 +1,5 @@