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">
|
35ad3764
梁灏
update Table
|
14
15
|
<i class="ivu-icon ivu-icon-arrow-up-b" :class="{on: column._sortType === 'asc'}" @click="handleSort($index, 'asc')"></i>
<i class="ivu-icon ivu-icon-arrow-down-b" :class="{on: column._sortType === 'desc'}" @click="handleSort($index, 'desc')"></i>
|
52874e27
梁灏
update Table
|
16
|
</span>
|
642299b9
梁灏
update Table
|
17
18
19
20
21
22
23
24
25
26
|
<Poptip v-if="column.filters" placement="bottom-end">
<span :class="[prefixCls + '-filter']">
<i class="ivu-icon ivu-icon-chevron-down" @click="handleFilter($index)"></i>
</span>
<div slot="content">
<ul>
<li v-for="item in column.filters"><Checkbox>{{ item.label }}</Checkbox></li>
</ul>
</div>
</Poptip>
|
52874e27
梁灏
update Table
|
27
|
</template>
|
7f34c510
梁灏
update Table
|
28
29
30
31
32
|
</div>
</th>
</tr>
</thead>
</table>
|
2cb8a6d9
梁灏
commit Table comp...
|
33
34
|
</template>
<script>
|
0d136465
梁灏
update Table
|
35
|
import Checkbox from '../checkbox/checkbox.vue';
|
642299b9
梁灏
update Table
|
36
|
import Poptip from '../poptip/poptip.vue';
|
0d136465
梁灏
update Table
|
37
38
39
|
import Mixin from './mixin';
import { deepCopy } from '../../utils/assist';
|
2cb8a6d9
梁灏
commit Table comp...
|
40
|
export default {
|
0d136465
梁灏
update Table
|
41
|
mixins: [ Mixin ],
|
642299b9
梁灏
update Table
|
42
|
components: { Checkbox, Poptip },
|
2cb8a6d9
梁灏
commit Table comp...
|
43
44
|
props: {
prefixCls: String,
|
7f34c510
梁灏
update Table
|
45
|
style: Object,
|
0d136465
梁灏
update Table
|
46
|
columns: Array,
|
d3dfdb26
梁灏
update Table
|
47
|
objData: Object,
|
7f34c510
梁灏
update Table
|
48
|
fixed: Boolean
|
2cb8a6d9
梁灏
commit Table comp...
|
49
|
},
|
2cb8a6d9
梁灏
commit Table comp...
|
50
|
computed: {
|
0d136465
梁灏
update Table
|
51
|
isSelectAll () {
|
d3dfdb26
梁灏
update Table
|
52
53
54
55
56
57
|
let isSelectAll = true;
for (let i in this.objData) {
if (!this.objData[i]._isChecked) isSelectAll = false;
}
return isSelectAll;
|
0d136465
梁灏
update Table
|
58
|
}
|
2cb8a6d9
梁灏
commit Table comp...
|
59
60
|
},
methods: {
|
c6f21c2f
jingsam
fix ie bug
|
61
62
63
64
65
66
67
68
|
cellClasses (column) {
return [
`${this.prefixCls}-cell`,
{
[`${this.prefixCls}-hidden`]: !this.fixed && column.fixed && (column.fixed === 'left' || column.fixed === 'right')
}
]
},
|
7f34c510
梁灏
update Table
|
69
70
71
|
setCellWidth (column, index) {
return this.$parent.setCellWidth(column, index);
},
|
2cb8a6d9
梁灏
commit Table comp...
|
72
73
74
75
76
77
|
renderHeader (column, $index) {
if ('renderHeader' in this.columns[$index]) {
return this.columns[$index].renderHeader(column, $index);
} else {
return column.title || '#';
}
|
744eb0af
梁灏
update Table comp...
|
78
|
},
|
0d136465
梁灏
update Table
|
79
80
|
selectAll () {
const status = !this.isSelectAll;
|
3d9e4f20
梁灏
update Table
|
81
|
this.$parent.selectAll(status);
|
52874e27
梁灏
update Table
|
82
|
},
|
35ad3764
梁灏
update Table
|
83
84
85
|
handleSort (index, type) {
if (this.columns[index]._sortType === type) {
type = 'normal';
|
741b987a
梁灏
update Table
|
86
|
}
|
35ad3764
梁灏
update Table
|
87
|
this.$parent.handleSort(index, type);
|
642299b9
梁灏
update Table
|
88
89
90
|
},
handleFilter (index) {
|
2cb8a6d9
梁灏
commit Table comp...
|
91
92
93
|
}
}
}
|
c6f21c2f
jingsam
fix ie bug
|
94
|
</script>
|