2cb8a6d9
梁灏
commit Table comp...
|
1
|
<template>
|
7f34c510
梁灏
update Table
|
2
3
4
5
6
7
|
<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
|
741b987a
梁灏
update Table
|
8
9
|
v-for="(index, row) in data"
:class="rowClasses(index, row._index)"
|
7f34c510
梁灏
update Table
|
10
11
12
13
14
15
16
17
18
|
@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"
|
741b987a
梁灏
update Table
|
19
20
21
|
:natural-index="index"
:index="row._index"
:checked="rowChecked(index, row._index)"></Cell>
|
7f34c510
梁灏
update Table
|
22
23
24
|
</td>
</tr>
</tbody>
|
3ef4dfb9
梁灏
update Table
|
25
|
</table>
|
2cb8a6d9
梁灏
commit Table comp...
|
26
27
|
</template>
<script>
|
7f34c510
梁灏
update Table
|
28
29
30
|
import Cell from './cell.vue';
import Mixin from './mixin';
|
2cb8a6d9
梁灏
commit Table comp...
|
31
|
export default {
|
7f34c510
梁灏
update Table
|
32
33
|
mixins: [ Mixin ],
components: { Cell },
|
2cb8a6d9
梁灏
commit Table comp...
|
34
|
props: {
|
7f34c510
梁灏
update Table
|
35
36
37
|
prefixCls: String,
style: Object,
columns: Array,
|
741b987a
梁灏
update Table
|
38
|
data: Array, // rebuildData
|
7f34c510
梁灏
update Table
|
39
|
cloneData: Array,
|
741b987a
梁灏
update Table
|
40
|
objData: Object,
|
7f34c510
梁灏
update Table
|
41
|
fixed: Boolean
|
2cb8a6d9
梁灏
commit Table comp...
|
42
43
|
},
methods: {
|
741b987a
梁灏
update Table
|
44
|
rowClasses (index, _index) {
|
c6f21c2f
jingsam
fix ie bug
|
45
46
|
return [
`${this.prefixCls}-row`,
|
741b987a
梁灏
update Table
|
47
|
this.rowClsName(_index),
|
c6f21c2f
jingsam
fix ie bug
|
48
49
50
51
|
{
[`${this.prefixCls}-row-highlight`]: this.cloneData[index] && this.cloneData[index]._isHighlight,
[`${this.prefixCls}-row-hover`]: this.cloneData[index] && this.cloneData[index]._isHover
}
|
c6f21c2f
jingsam
fix ie bug
|
52
53
|
]
},
|
741b987a
梁灏
update Table
|
54
55
56
57
58
|
rowChecked (index, _index) {
// const data = this.cloneData.filter(row => row._index === _index);
// return data && data._isChecked;
return this.objData[_index]._isChecked;
},
|
7f34c510
梁灏
update Table
|
59
60
61
62
|
setCellWidth (column, index) {
return this.$parent.setCellWidth(column, index);
},
rowClsName (index) {
|
52874e27
梁灏
update Table
|
63
|
return this.$parent.rowClassName(this.cloneData[index], index);
|
7f34c510
梁灏
update Table
|
64
65
66
67
68
69
70
71
72
73
|
},
handleMouseIn (index) {
this.$parent.handleMouseIn(index);
},
handleMouseOut (index) {
this.$parent.handleMouseOut(index);
},
highlightCurrentRow (index) {
this.$parent.highlightCurrentRow(index);
}
|
2cb8a6d9
梁灏
commit Table comp...
|
74
75
|
}
}
|
c6f21c2f
jingsam
fix ie bug
|
76
|
</script>
|