iview/src/components/table/table-body.vue

69 lines
2.4 KiB
Vue
Raw Normal View History

<template>
2016-11-26 08:57:09 +08:00
<table cellspacing="0" cellpadding="0" border="0" :style="style">
<colgroup>
<col v-for="column in columns" :width="setCellWidth(column, $index)">
</colgroup>
<tbody :class="[prefixCls + '-tbody']">
<tr
2016-11-27 22:56:05 +08:00
v-for="(index, row) in cloneData"
2016-11-27 01:42:39 +08:00
:class="rowClasses(row, index)"
2016-11-26 08:57:09 +08:00
@mouseenter.stop="handleMouseIn(index)"
@mouseleave.stop="handleMouseOut(index)"
@click.stop="highlightCurrentRow(index)">
<td v-for="column in columns" :class="alignCls(column)">
<Cell
:fixed="fixed"
:prefix-cls="prefixCls"
:row="row"
:column="column"
:index="index"
:checked="cloneData[index] && cloneData[index]._isChecked"></Cell>
</td>
</tr>
</tbody>
2016-11-25 22:51:50 +08:00
</table>
</template>
<script>
2016-11-26 08:57:09 +08:00
import Cell from './cell.vue';
import Mixin from './mixin';
export default {
2016-11-26 08:57:09 +08:00
mixins: [ Mixin ],
components: { Cell },
props: {
2016-11-26 08:57:09 +08:00
prefixCls: String,
style: Object,
columns: Array,
cloneData: Array,
fixed: Boolean
},
methods: {
2016-11-27 01:42:39 +08:00
rowClasses (row, 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
}
]
},
2016-11-26 08:57:09 +08:00
setCellWidth (column, index) {
return this.$parent.setCellWidth(column, index);
},
rowClsName (index) {
2016-11-27 22:56:05 +08:00
return this.$parent.rowClassName(this.cloneData[index], index);
2016-11-26 08:57:09 +08:00
},
handleMouseIn (index) {
this.$parent.handleMouseIn(index);
},
handleMouseOut (index) {
this.$parent.handleMouseOut(index);
},
highlightCurrentRow (index) {
this.$parent.highlightCurrentRow(index);
}
}
}
2016-11-27 01:42:39 +08:00
</script>