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>
|
99f80db0
梁灏
update Table
|
17
|
<Poptip v-if="column.filters" :visible.sync="column._filterVisible" placement="bottom">
|
642299b9
梁灏
update Table
|
18
|
<span :class="[prefixCls + '-filter']">
|
99f80db0
梁灏
update Table
|
19
|
<i class="ivu-icon ivu-icon-funnel" :class="{on: column._isFiltered}"></i>
|
642299b9
梁灏
update Table
|
20
|
</span>
|
99f80db0
梁灏
update Table
|
21
22
23
24
25
26
|
<div slot="content" :class="[prefixCls + '-filter-list']">
<div :class="[prefixCls + '-filter-list-item']">
<checkbox-group :model.sync="column._filterChecked">
<checkbox v-for="item in column.filters" :value="item.value">{{ item.label }}</checkbox>
</checkbox-group>
</div>
|
642299b9
梁灏
update Table
|
27
|
<ul>
|
99f80db0
梁灏
update Table
|
28
29
|
<!--<li v-for="(filterIndex, item) in column.filters"><Checkbox :checked="column._filterChecked.indexOf(item.value) > -1" @on-change="handleFilterChecked(index, filterIndex)">{{ item.label }}</Checkbox></li>-->
|
642299b9
梁灏
update Table
|
30
|
</ul>
|
99f80db0
梁灏
update Table
|
31
32
33
34
|
<div :class="[prefixCls + '-filter-footer']">
<i-button type="text" size="small" @click="handleFilter($index)">筛选</i-button>
<i-button type="text" size="small" @click="handleReset($index)">重置</i-button>
</div>
|
642299b9
梁灏
update Table
|
35
36
|
</div>
</Poptip>
|
52874e27
梁灏
update Table
|
37
|
</template>
|
7f34c510
梁灏
update Table
|
38
39
40
41
42
|
</div>
</th>
</tr>
</thead>
</table>
|
2cb8a6d9
梁灏
commit Table comp...
|
43
44
|
</template>
<script>
|
99f80db0
梁灏
update Table
|
45
|
import CheckboxGroup from '../checkbox/checkbox-group.vue';
|
0d136465
梁灏
update Table
|
46
|
import Checkbox from '../checkbox/checkbox.vue';
|
642299b9
梁灏
update Table
|
47
|
import Poptip from '../poptip/poptip.vue';
|
99f80db0
梁灏
update Table
|
48
|
import iButton from '../button/button.vue';
|
0d136465
梁灏
update Table
|
49
50
51
|
import Mixin from './mixin';
import { deepCopy } from '../../utils/assist';
|
2cb8a6d9
梁灏
commit Table comp...
|
52
|
export default {
|
0d136465
梁灏
update Table
|
53
|
mixins: [ Mixin ],
|
99f80db0
梁灏
update Table
|
54
|
components: { CheckboxGroup, Checkbox, Poptip, iButton },
|
2cb8a6d9
梁灏
commit Table comp...
|
55
56
|
props: {
prefixCls: String,
|
7f34c510
梁灏
update Table
|
57
|
style: Object,
|
0d136465
梁灏
update Table
|
58
|
columns: Array,
|
d3dfdb26
梁灏
update Table
|
59
|
objData: Object,
|
7f34c510
梁灏
update Table
|
60
|
fixed: Boolean
|
2cb8a6d9
梁灏
commit Table comp...
|
61
|
},
|
2cb8a6d9
梁灏
commit Table comp...
|
62
|
computed: {
|
0d136465
梁灏
update Table
|
63
|
isSelectAll () {
|
d3dfdb26
梁灏
update Table
|
64
65
66
67
68
69
|
let isSelectAll = true;
for (let i in this.objData) {
if (!this.objData[i]._isChecked) isSelectAll = false;
}
return isSelectAll;
|
0d136465
梁灏
update Table
|
70
|
}
|
2cb8a6d9
梁灏
commit Table comp...
|
71
72
|
},
methods: {
|
c6f21c2f
jingsam
fix ie bug
|
73
74
75
76
77
78
79
80
|
cellClasses (column) {
return [
`${this.prefixCls}-cell`,
{
[`${this.prefixCls}-hidden`]: !this.fixed && column.fixed && (column.fixed === 'left' || column.fixed === 'right')
}
]
},
|
7f34c510
梁灏
update Table
|
81
82
83
|
setCellWidth (column, index) {
return this.$parent.setCellWidth(column, index);
},
|
2cb8a6d9
梁灏
commit Table comp...
|
84
85
86
87
88
89
|
renderHeader (column, $index) {
if ('renderHeader' in this.columns[$index]) {
return this.columns[$index].renderHeader(column, $index);
} else {
return column.title || '#';
}
|
744eb0af
梁灏
update Table comp...
|
90
|
},
|
0d136465
梁灏
update Table
|
91
92
|
selectAll () {
const status = !this.isSelectAll;
|
3d9e4f20
梁灏
update Table
|
93
|
this.$parent.selectAll(status);
|
52874e27
梁灏
update Table
|
94
|
},
|
35ad3764
梁灏
update Table
|
95
96
97
|
handleSort (index, type) {
if (this.columns[index]._sortType === type) {
type = 'normal';
|
741b987a
梁灏
update Table
|
98
|
}
|
35ad3764
梁灏
update Table
|
99
|
this.$parent.handleSort(index, type);
|
642299b9
梁灏
update Table
|
100
101
102
|
},
handleFilter (index) {
|
99f80db0
梁灏
update Table
|
103
104
105
106
107
108
|
},
handleReset (index) {
},
handleFilterChecked (index, filterIndex) {
|
2cb8a6d9
梁灏
commit Table comp...
|
109
110
111
|
}
}
}
|
c6f21c2f
jingsam
fix ie bug
|
112
|
</script>
|