2cb8a6d9
梁灏
commit Table comp...
|
1
|
<template>
|
a404bbae
梁灏
update Table #167
|
2
|
<table cellspacing="0" cellpadding="0" border="0" :style="styles">
|
7f34c510
梁灏
update Table
|
3
|
<colgroup>
|
eec3859c
huanghong
fixed table scollbar
|
4
5
|
<col v-for="(column, index) in columns" :width="setCellWidth(column)">
<col v-if="$parent.showVerticalScrollBar" :width="$parent.scrollBarWidth"/>
|
7f34c510
梁灏
update Table
|
6
7
|
</colgroup>
<thead>
|
1acabf79
梁灏
Table support mul...
|
8
9
10
11
12
13
|
<tr v-for="(cols, rowIndex) in headRows">
<th
v-for="(column, index) in cols"
:colspan="column.colSpan"
:rowspan="column.rowSpan"
:class="alignCls(column)">
|
c6f21c2f
jingsam
fix ie bug
|
14
|
<div :class="cellClasses(column)">
|
8a392d25
梁灏
Table expand supp...
|
15
16
17
18
|
<template v-if="column.type === 'expand'">
<span v-if="!column.renderHeader">{{ column.title || '' }}</span>
<render-header v-else :render="column.renderHeader" :column="column" :index="index"></render-header>
</template>
|
bb49347b
梁灏
fixed #2823
|
19
|
<template v-else-if="column.type === 'selection'"><Checkbox :value="isSelectAll" :disabled="!data.length" @on-change="selectAll"></Checkbox></template>
|
52874e27
梁灏
update Table
|
20
|
<template v-else>
|
a0f48947
梁灏
Optimize Table ch...
|
21
|
<span v-if="!column.renderHeader" :class="{[prefixCls + '-cell-sort']: column.sortable}" @click="handleSortByHead(getColumn(rowIndex, index)._index)">{{ column.title || '#' }}</span>
|
096f2bfe
梁灏
fixed #1357
|
22
|
<render-header v-else :render="column.renderHeader" :column="column" :index="index"></render-header>
|
52874e27
梁灏
update Table
|
23
|
<span :class="[prefixCls + '-sort']" v-if="column.sortable">
|
9ea47cb3
梁灏
fixed Table multi...
|
24
25
|
<i class="ivu-icon ivu-icon-arrow-up-b" :class="{on: getColumn(rowIndex, index)._sortType === 'asc'}" @click="handleSort(getColumn(rowIndex, index)._index, 'asc')"></i>
<i class="ivu-icon ivu-icon-arrow-down-b" :class="{on: getColumn(rowIndex, index)._sortType === 'desc'}" @click="handleSort(getColumn(rowIndex, index)._index, 'desc')"></i>
|
52874e27
梁灏
update Table
|
26
|
</span>
|
adaeca88
梁灏
update Table
|
27
|
<Poptip
|
5d0499ce
梁灏
update Table
|
28
|
v-if="isPopperShow(column)"
|
9ea47cb3
梁灏
fixed Table multi...
|
29
|
v-model="getColumn(rowIndex, index)._filterVisible"
|
adaeca88
梁灏
update Table
|
30
|
placement="bottom"
|
19c208d3
梁灏
Poptip add prop `...
|
31
32
|
popper-class="ivu-table-popper"
transfer
|
9ea47cb3
梁灏
fixed Table multi...
|
33
|
@on-popper-hide="handleFilterHide(getColumn(rowIndex, index)._index)">
|
642299b9
梁灏
update Table
|
34
|
<span :class="[prefixCls + '-filter']">
|
9ea47cb3
梁灏
fixed Table multi...
|
35
|
<i class="ivu-icon ivu-icon-funnel" :class="{on: getColumn(rowIndex, index)._isFiltered}"></i>
|
642299b9
梁灏
update Table
|
36
|
</span>
|
5d164b03
梁灏
fixed #3339
|
37
|
|
9ea47cb3
梁灏
fixed Table multi...
|
38
|
<div slot="content" :class="[prefixCls + '-filter-list']" v-if="getColumn(rowIndex, index)._filterMultiple">
|
99f80db0
梁灏
update Table
|
39
|
<div :class="[prefixCls + '-filter-list-item']">
|
9ea47cb3
梁灏
fixed Table multi...
|
40
|
<checkbox-group v-model="getColumn(rowIndex, index)._filterChecked">
|
ceeb9361
梁灏
fixed Table bug i...
|
41
|
<checkbox v-for="(item, index) in column.filters" :key="index" :label="item.value">{{ item.label }}</checkbox>
|
99f80db0
梁灏
update Table
|
42
43
|
</checkbox-group>
</div>
|
99f80db0
梁灏
update Table
|
44
|
<div :class="[prefixCls + '-filter-footer']">
|
9ea47cb3
梁灏
fixed Table multi...
|
45
46
|
<i-button type="text" size="small" :disabled="!getColumn(rowIndex, index)._filterChecked.length" @click.native="handleFilter(getColumn(rowIndex, index)._index)">{{ t('i.table.confirmFilter') }}</i-button>
<i-button type="text" size="small" @click.native="handleReset(getColumn(rowIndex, index)._index)">{{ t('i.table.resetFilter') }}</i-button>
|
99f80db0
梁灏
update Table
|
47
|
</div>
|
642299b9
梁灏
update Table
|
48
|
</div>
|
adaeca88
梁灏
update Table
|
49
|
<div slot="content" :class="[prefixCls + '-filter-list']" v-else>
|
d0e206c5
梁灏
Table add content...
|
50
|
<ul :class="[prefixCls + '-filter-list-single']">
|
45e7ed7e
梁灏
update Table
|
51
|
<li
|
9ea47cb3
梁灏
fixed Table multi...
|
52
53
|
:class="itemAllClasses(getColumn(rowIndex, index))"
@click="handleReset(getColumn(rowIndex, index)._index)">{{ t('i.table.clearFilter') }}</li>
|
45e7ed7e
梁灏
update Table
|
54
|
<li
|
9ea47cb3
梁灏
fixed Table multi...
|
55
|
:class="itemClasses(getColumn(rowIndex, index), item)"
|
45e7ed7e
梁灏
update Table
|
56
|
v-for="item in column.filters"
|
9ea47cb3
梁灏
fixed Table multi...
|
57
|
@click="handleSelect(getColumn(rowIndex, index)._index, item.value)">{{ item.label }}</li>
|
adaeca88
梁灏
update Table
|
58
59
|
</ul>
</div>
|
642299b9
梁灏
update Table
|
60
|
</Poptip>
|
52874e27
梁灏
update Table
|
61
|
</template>
|
7f34c510
梁灏
update Table
|
62
63
|
</div>
</th>
|
eec3859c
huanghong
fixed table scollbar
|
64
|
|
75803add
huanghong
fixed scoll bar
|
65
|
<th v-if="$parent.showVerticalScrollBar && rowIndex===0" :class='scrollBarCellClass()' :rowspan="headRows.length"></th>
|
7f34c510
梁灏
update Table
|
66
67
68
|
</tr>
</thead>
</table>
|
2cb8a6d9
梁灏
commit Table comp...
|
69
70
|
</template>
<script>
|
99f80db0
梁灏
update Table
|
71
|
import CheckboxGroup from '../checkbox/checkbox-group.vue';
|
0d136465
梁灏
update Table
|
72
|
import Checkbox from '../checkbox/checkbox.vue';
|
642299b9
梁灏
update Table
|
73
|
import Poptip from '../poptip/poptip.vue';
|
99f80db0
梁灏
update Table
|
74
|
import iButton from '../button/button.vue';
|
096f2bfe
梁灏
fixed #1357
|
75
|
import renderHeader from './header';
|
0d136465
梁灏
update Table
|
76
|
import Mixin from './mixin';
|
4ab11811
梁灏
some component su...
|
77
|
import Locale from '../../mixins/locale';
|
0d136465
梁灏
update Table
|
78
|
|
2cb8a6d9
梁灏
commit Table comp...
|
79
|
export default {
|
486d4fda
梁灏
update Table
|
80
|
name: 'TableHead',
|
4ab11811
梁灏
some component su...
|
81
|
mixins: [ Mixin, Locale ],
|
096f2bfe
梁灏
fixed #1357
|
82
|
components: { CheckboxGroup, Checkbox, Poptip, iButton, renderHeader },
|
2cb8a6d9
梁灏
commit Table comp...
|
83
84
|
props: {
prefixCls: String,
|
486d4fda
梁灏
update Table
|
85
|
styleObject: Object,
|
0d136465
梁灏
update Table
|
86
|
columns: Array,
|
d3dfdb26
梁灏
update Table
|
87
|
objData: Object,
|
6c99b9fe
梁灏
update Table
|
88
|
data: Array, // rebuildData
|
224a3ae5
梁灏
publish 0.9.9-rc-3
|
89
|
columnsWidth: Object,
|
5d0499ce
梁灏
update Table
|
90
91
92
|
fixed: {
type: [Boolean, String],
default: false
|
1acabf79
梁灏
Table support mul...
|
93
|
},
|
c1e965c3
梁灏
fixed-head
|
94
95
|
columnRows: Array,
fixedColumnRows: Array
|
2cb8a6d9
梁灏
commit Table comp...
|
96
|
},
|
2cb8a6d9
梁灏
commit Table comp...
|
97
|
computed: {
|
a404bbae
梁灏
update Table #167
|
98
|
styles () {
|
486d4fda
梁灏
update Table
|
99
|
const style = Object.assign({}, this.styleObject);
|
eec3859c
huanghong
fixed table scollbar
|
100
|
const width = parseInt(this.styleObject.width) ;
|
a404bbae
梁灏
update Table #167
|
101
102
103
|
style.width = `${width}px`;
return style;
},
|
0d136465
梁灏
update Table
|
104
|
isSelectAll () {
|
d3dfdb26
梁灏
update Table
|
105
|
let isSelectAll = true;
|
63e0444e
梁灏
fixed #142
|
106
|
if (!this.data.length) isSelectAll = false;
|
17db7df4
梁灏
fixed #1751
|
107
|
if (!this.data.find(item => !item._disabled)) isSelectAll = false; // #1751
|
6c99b9fe
梁灏
update Table
|
108
|
for (let i = 0; i < this.data.length; i++) {
|
cd85c675
leonine
修改_checked=true 时...
|
109
|
if (!this.objData[this.data[i]._index]._isChecked && !this.objData[this.data[i]._index]._isDisabled) {
|
6c99b9fe
梁灏
update Table
|
110
111
112
|
isSelectAll = false;
break;
}
|
d3dfdb26
梁灏
update Table
|
113
114
|
}
|
cd85c675
leonine
修改_checked=true 时...
|
115
|
return isSelectAll;
|
1acabf79
梁灏
Table support mul...
|
116
117
118
|
},
headRows () {
const isGroup = this.columnRows.length > 1;
|
c1e965c3
梁灏
fixed-head
|
119
120
121
122
123
|
if (isGroup) {
return this.fixed ? this.fixedColumnRows : this.columnRows;
} else {
return [this.columns];
}
|
0d136465
梁灏
update Table
|
124
|
}
|
2cb8a6d9
梁灏
commit Table comp...
|
125
126
|
},
methods: {
|
c6f21c2f
jingsam
fix ie bug
|
127
128
129
130
131
132
|
cellClasses (column) {
return [
`${this.prefixCls}-cell`,
{
[`${this.prefixCls}-hidden`]: !this.fixed && column.fixed && (column.fixed === 'left' || column.fixed === 'right')
}
|
b0893113
jingsam
add eslint
|
133
|
];
|
c6f21c2f
jingsam
fix ie bug
|
134
|
},
|
75803add
huanghong
fixed scoll bar
|
135
136
|
scrollBarCellClass(){
let hasRightFixed = false;
|
5d164b03
梁灏
fixed #3339
|
137
138
|
for(let i in this.headRows){
for(let j in this.headRows[i]){
|
75803add
huanghong
fixed scoll bar
|
139
140
141
142
143
144
145
146
147
148
149
150
151
|
if(this.headRows[i][j].fixed === 'right') {
hasRightFixed=true;
break;
}
if(hasRightFixed) break;
}
}
return [
{
[`${this.prefixCls}-hidden`]: hasRightFixed
}
];
},
|
89670198
梁灏
publish 0.9.9-rc-5
|
152
153
154
155
156
157
|
itemClasses (column, item) {
return [
`${this.prefixCls}-filter-select-item`,
{
[`${this.prefixCls}-filter-select-item-selected`]: column._filterChecked[0] === item.value
}
|
b0893113
jingsam
add eslint
|
158
|
];
|
89670198
梁灏
publish 0.9.9-rc-5
|
159
160
161
162
163
164
165
|
},
itemAllClasses (column) {
return [
`${this.prefixCls}-filter-select-item`,
{
[`${this.prefixCls}-filter-select-item-selected`]: !column._filterChecked.length
}
|
b0893113
jingsam
add eslint
|
166
|
];
|
89670198
梁灏
publish 0.9.9-rc-5
|
167
|
},
|
0d136465
梁灏
update Table
|
168
169
|
selectAll () {
const status = !this.isSelectAll;
|
3d9e4f20
梁灏
update Table
|
170
|
this.$parent.selectAll(status);
|
52874e27
梁灏
update Table
|
171
|
},
|
35ad3764
梁灏
update Table
|
172
|
handleSort (index, type) {
|
b34e09b8
梁灏
fixed #2832
|
173
174
175
176
|
const column = this.columns[index];
const _index = column._index;
if (column._sortType === type) {
|
35ad3764
梁灏
update Table
|
177
|
type = 'normal';
|
741b987a
梁灏
update Table
|
178
|
}
|
b34e09b8
梁灏
fixed #2832
|
179
|
this.$parent.handleSort(_index, type);
|
642299b9
梁灏
update Table
|
180
|
},
|
1b737fdc
梁灏
fixed #122
|
181
182
183
184
185
186
187
188
189
190
191
192
193
|
handleSortByHead (index) {
const column = this.columns[index];
if (column.sortable) {
const type = column._sortType;
if (type === 'normal') {
this.handleSort(index, 'asc');
} else if (type === 'asc') {
this.handleSort(index, 'desc');
} else {
this.handleSort(index, 'normal');
}
}
},
|
642299b9
梁灏
update Table
|
194
|
handleFilter (index) {
|
adaeca88
梁灏
update Table
|
195
|
this.$parent.handleFilter(index);
|
99f80db0
梁灏
update Table
|
196
|
},
|
45e7ed7e
梁灏
update Table
|
197
198
199
|
handleSelect (index, value) {
this.$parent.handleFilterSelect(index, value);
},
|
99f80db0
梁灏
update Table
|
200
|
handleReset (index) {
|
adaeca88
梁灏
update Table
|
201
|
this.$parent.handleFilterReset(index);
|
99f80db0
梁灏
update Table
|
202
|
},
|
adaeca88
梁灏
update Table
|
203
204
|
handleFilterHide (index) {
this.$parent.handleFilterHide(index);
|
9ea47cb3
梁灏
fixed Table multi...
|
205
206
207
208
|
},
// 因为表头嵌套不是深拷贝,所以没有 _ 开头的方法,在 isGroup 下用此列
getColumn (rowIndex, index) {
const isGroup = this.columnRows.length > 1;
|
5d164b03
梁灏
fixed #3339
|
209
210
211
212
213
214
215
|
if (isGroup) {
const id = this.headRows[rowIndex][index].__id;
return this.columns.filter(item => item.__id === id)[0];
} else {
return this.headRows[rowIndex][index];
}
|
2cb8a6d9
梁灏
commit Table comp...
|
216
217
|
}
}
|
b0893113
jingsam
add eslint
|
218
219
|
};
</script>
|