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
|
<template v-else>
{{{ renderHeader(column, $index) }}}
<span :class="[prefixCls + '-sort']" v-if="column.sortable">
|
741b987a
梁灏
update Table
|
14
15
|
<i class="ivu-icon ivu-icon-arrow-up-b" :class="{on: sortType === 'asc'}" @click="handleSortAsc($index)"></i>
<i class="ivu-icon ivu-icon-arrow-down-b" :class="{on: sortType === 'desc'}" @click="handleSortDesc($index)"></i>
|
52874e27
梁灏
update Table
|
16
17
|
</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
|
},
|
741b987a
梁灏
update Table
|
39
40
41
42
43
|
data () {
return {
sortType: 'normal'
}
},
|
2cb8a6d9
梁灏
commit Table comp...
|
44
|
computed: {
|
0d136465
梁灏
update Table
|
45
46
47
|
isSelectAll () {
return !this.cloneData.some(data => !data._isChecked);
}
|
2cb8a6d9
梁灏
commit Table comp...
|
48
49
|
},
methods: {
|
c6f21c2f
jingsam
fix ie bug
|
50
51
52
53
54
55
56
57
|
cellClasses (column) {
return [
`${this.prefixCls}-cell`,
{
[`${this.prefixCls}-hidden`]: !this.fixed && column.fixed && (column.fixed === 'left' || column.fixed === 'right')
}
]
},
|
7f34c510
梁灏
update Table
|
58
59
60
|
setCellWidth (column, index) {
return this.$parent.setCellWidth(column, index);
},
|
2cb8a6d9
梁灏
commit Table comp...
|
61
62
63
64
65
66
|
renderHeader (column, $index) {
if ('renderHeader' in this.columns[$index]) {
return this.columns[$index].renderHeader(column, $index);
} else {
return column.title || '#';
}
|
744eb0af
梁灏
update Table comp...
|
67
|
},
|
0d136465
梁灏
update Table
|
68
69
|
selectAll () {
const status = !this.isSelectAll;
|
3d9e4f20
梁灏
update Table
|
70
|
this.$parent.selectAll(status);
|
52874e27
梁灏
update Table
|
71
72
|
},
handleSortAsc (index) {
|
741b987a
梁灏
update Table
|
73
74
75
76
77
78
79
|
if (this.sortType === 'asc') {
this.sortType = 'normal';
this.$parent.handleSort(index, 'normal');
} else {
this.sortType = 'asc';
this.$parent.handleSort(index, 'asc');
}
|
52874e27
梁灏
update Table
|
80
81
|
},
handleSortDesc (index) {
|
741b987a
梁灏
update Table
|
82
83
84
85
86
87
88
|
if (this.sortType === 'desc') {
this.sortType = 'normal';
this.$parent.handleSort(index, 'normal');
} else {
this.sortType = 'desc';
this.$parent.handleSort(index, 'desc');
}
|
2cb8a6d9
梁灏
commit Table comp...
|
89
90
91
|
}
}
}
|
c6f21c2f
jingsam
fix ie bug
|
92
|
</script>
|