update Table

update Table
This commit is contained in:
梁灏 2016-11-27 22:56:05 +08:00
parent b8a4300003
commit 52874e27e5
7 changed files with 70 additions and 13 deletions

View file

@ -5,7 +5,7 @@
</colgroup>
<tbody :class="[prefixCls + '-tbody']">
<tr
v-for="(index, row) in data"
v-for="(index, row) in cloneData"
:class="rowClasses(row, index)"
@mouseenter.stop="handleMouseIn(index)"
@mouseleave.stop="handleMouseOut(index)"
@ -34,7 +34,6 @@
prefixCls: String,
style: Object,
columns: Array,
data: Array,
cloneData: Array,
fixed: Boolean
},
@ -53,7 +52,7 @@
return this.$parent.setCellWidth(column, index);
},
rowClsName (index) {
return this.$parent.rowClassName(this.data[index], index);
return this.$parent.rowClassName(this.cloneData[index], index);
},
handleMouseIn (index) {
this.$parent.handleMouseIn(index);

View file

@ -8,7 +8,13 @@
<th v-for="column in columns" :class="alignCls(column)">
<div :class="cellClasses(column)">
<template v-if="column.type === 'selection'"><Checkbox :checked="isSelectAll" @on-change="selectAll"></Checkbox></template>
<template v-else>{{{ renderHeader(column, $index) }}}</template>
<template v-else>
{{{ renderHeader(column, $index) }}}
<span :class="[prefixCls + '-sort']" v-if="column.sortable">
<i class="ivu-icon ivu-icon-arrow-up-b" @click="handleSortAsc($index)"></i>
<i class="ivu-icon ivu-icon-arrow-down-b" @click="handleSortDesc($index)"></i>
</span>
</template>
</div>
</th>
</tr>
@ -57,6 +63,12 @@
selectAll () {
const status = !this.isSelectAll;
this.$parent.selectAll(status);
},
handleSortAsc (index) {
this.$parent.handleSort(index, 'asc');
},
handleSortDesc (index) {
this.$parent.handleSort(index, 'desc');
}
}
}

View file

@ -14,7 +14,6 @@
:prefix-cls="prefixCls"
:style="tableStyle"
:columns="cloneColumns"
:data="data"
:clone-data="cloneData"></table-body>
</div>
<div :class="[prefixCls + '-fixed']">
@ -32,7 +31,6 @@
:prefix-cls="prefixCls"
:style="fixedTableStyle"
:columns="leftFixedColumns"
:data="data"
:clone-data="cloneData"></table-body>
</div>
</div>
@ -51,7 +49,6 @@
:prefix-cls="prefixCls"
:style="fixedRightTableStyle"
:columns="rightFixedColumns"
:data="data"
:clone-data="cloneData"></table-body>
</div>
</div>
@ -269,9 +266,11 @@
});
this.cloneData = tmpData;
const selection = this.getSelection();
if (status) {
this.$emit('on-select-all', this.getSelection());
this.$emit('on-select-all', selection);
}
this.$emit('on-selection-change', selection);
},
fixedHeader () {
if (!!this.height) {
@ -315,6 +314,13 @@
} else {
$body.scrollLeft = $body.scrollLeft - 10;
}
},
handleSort (index, type) {
if (type === 'asc') {
} else if (type === 'desc') {
}
}
},
compiled () {