2cb8a6d9
梁灏
commit Table comp...
|
1
|
<template>
|
7f34c510
梁灏
update Table
|
2
3
4
5
6
7
8
|
<table cellspacing="0" cellpadding="0" border="0" :style="style">
<colgroup>
<col v-for="column in columns" :width="setCellWidth(column, $index)">
</colgroup>
<thead>
<tr>
<th v-for="column in columns" :class="alignCls(column)">
|
c6f21c2f
jingsam
fix ie bug
|
9
|
<div :class="cellClasses(column)">
|
7f34c510
梁灏
update Table
|
10
|
<template v-if="column.type === 'selection'"><Checkbox :checked="isSelectAll" @on-change="selectAll"></Checkbox></template>
|
52874e27
梁灏
update Table
|
11
12
13
14
15
16
17
|
<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>
|
7f34c510
梁灏
update Table
|
18
19
20
21
22
|
</div>
</th>
</tr>
</thead>
</table>
|
2cb8a6d9
梁灏
commit Table comp...
|
23
24
|
</template>
<script>
|
0d136465
梁灏
update Table
|
25
26
27
28
|
import Checkbox from '../checkbox/checkbox.vue';
import Mixin from './mixin';
import { deepCopy } from '../../utils/assist';
|
2cb8a6d9
梁灏
commit Table comp...
|
29
|
export default {
|
0d136465
梁灏
update Table
|
30
31
|
mixins: [ Mixin ],
components: { Checkbox },
|
2cb8a6d9
梁灏
commit Table comp...
|
32
33
|
props: {
prefixCls: String,
|
7f34c510
梁灏
update Table
|
34
|
style: Object,
|
0d136465
梁灏
update Table
|
35
|
columns: Array,
|
7f34c510
梁灏
update Table
|
36
37
|
cloneData: Array,
fixed: Boolean
|
2cb8a6d9
梁灏
commit Table comp...
|
38
39
|
},
computed: {
|
0d136465
梁灏
update Table
|
40
41
42
|
isSelectAll () {
return !this.cloneData.some(data => !data._isChecked);
}
|
2cb8a6d9
梁灏
commit Table comp...
|
43
44
|
},
methods: {
|
c6f21c2f
jingsam
fix ie bug
|
45
46
47
48
49
50
51
52
|
cellClasses (column) {
return [
`${this.prefixCls}-cell`,
{
[`${this.prefixCls}-hidden`]: !this.fixed && column.fixed && (column.fixed === 'left' || column.fixed === 'right')
}
]
},
|
7f34c510
梁灏
update Table
|
53
54
55
|
setCellWidth (column, index) {
return this.$parent.setCellWidth(column, index);
},
|
2cb8a6d9
梁灏
commit Table comp...
|
56
57
58
59
60
61
|
renderHeader (column, $index) {
if ('renderHeader' in this.columns[$index]) {
return this.columns[$index].renderHeader(column, $index);
} else {
return column.title || '#';
}
|
744eb0af
梁灏
update Table comp...
|
62
|
},
|
0d136465
梁灏
update Table
|
63
64
|
selectAll () {
const status = !this.isSelectAll;
|
3d9e4f20
梁灏
update Table
|
65
|
this.$parent.selectAll(status);
|
52874e27
梁灏
update Table
|
66
67
68
69
70
71
|
},
handleSortAsc (index) {
this.$parent.handleSort(index, 'asc');
},
handleSortDesc (index) {
this.$parent.handleSort(index, 'desc');
|
2cb8a6d9
梁灏
commit Table comp...
|
72
73
74
|
}
}
}
|
c6f21c2f
jingsam
fix ie bug
|
75
|
</script>
|