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