Commit 99f80db0be9c41b10eb1dc1ca530d1cddcca3d50
1 parent
642299b9
update Table
update Table
Showing
4 changed files
with
66 additions
and
12 deletions
Show diff stats
src/components/table/table-head.vue
... | ... | @@ -14,14 +14,24 @@ |
14 | 14 | <i class="ivu-icon ivu-icon-arrow-up-b" :class="{on: column._sortType === 'asc'}" @click="handleSort($index, 'asc')"></i> |
15 | 15 | <i class="ivu-icon ivu-icon-arrow-down-b" :class="{on: column._sortType === 'desc'}" @click="handleSort($index, 'desc')"></i> |
16 | 16 | </span> |
17 | - <Poptip v-if="column.filters" placement="bottom-end"> | |
17 | + <Poptip v-if="column.filters" :visible.sync="column._filterVisible" placement="bottom"> | |
18 | 18 | <span :class="[prefixCls + '-filter']"> |
19 | - <i class="ivu-icon ivu-icon-chevron-down" @click="handleFilter($index)"></i> | |
19 | + <i class="ivu-icon ivu-icon-funnel" :class="{on: column._isFiltered}"></i> | |
20 | 20 | </span> |
21 | - <div slot="content"> | |
21 | + <div slot="content" :class="[prefixCls + '-filter-list']"> | |
22 | + <div :class="[prefixCls + '-filter-list-item']"> | |
23 | + <checkbox-group :model.sync="column._filterChecked"> | |
24 | + <checkbox v-for="item in column.filters" :value="item.value">{{ item.label }}</checkbox> | |
25 | + </checkbox-group> | |
26 | + </div> | |
22 | 27 | <ul> |
23 | - <li v-for="item in column.filters"><Checkbox>{{ item.label }}</Checkbox></li> | |
28 | + <!--<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>--> | |
29 | + | |
24 | 30 | </ul> |
31 | + <div :class="[prefixCls + '-filter-footer']"> | |
32 | + <i-button type="text" size="small" @click="handleFilter($index)">筛选</i-button> | |
33 | + <i-button type="text" size="small" @click="handleReset($index)">重置</i-button> | |
34 | + </div> | |
25 | 35 | </div> |
26 | 36 | </Poptip> |
27 | 37 | </template> |
... | ... | @@ -32,14 +42,16 @@ |
32 | 42 | </table> |
33 | 43 | </template> |
34 | 44 | <script> |
45 | + import CheckboxGroup from '../checkbox/checkbox-group.vue'; | |
35 | 46 | import Checkbox from '../checkbox/checkbox.vue'; |
36 | 47 | import Poptip from '../poptip/poptip.vue'; |
48 | + import iButton from '../button/button.vue'; | |
37 | 49 | import Mixin from './mixin'; |
38 | 50 | import { deepCopy } from '../../utils/assist'; |
39 | 51 | |
40 | 52 | export default { |
41 | 53 | mixins: [ Mixin ], |
42 | - components: { Checkbox, Poptip }, | |
54 | + components: { CheckboxGroup, Checkbox, Poptip, iButton }, | |
43 | 55 | props: { |
44 | 56 | prefixCls: String, |
45 | 57 | style: Object, |
... | ... | @@ -88,6 +100,12 @@ |
88 | 100 | }, |
89 | 101 | handleFilter (index) { |
90 | 102 | |
103 | + }, | |
104 | + handleReset (index) { | |
105 | + | |
106 | + }, | |
107 | + handleFilterChecked (index, filterIndex) { | |
108 | + | |
91 | 109 | } |
92 | 110 | } |
93 | 111 | } | ... | ... |
src/components/table/table.vue
... | ... | @@ -291,10 +291,14 @@ |
291 | 291 | }) |
292 | 292 | } |
293 | 293 | }, |
294 | + hideColumnFilter () { | |
295 | + this.cloneColumns.forEach((col) => col._filterVisible = false); | |
296 | + }, | |
294 | 297 | handleBodyScroll (event) { |
295 | 298 | if (this.showHeader) this.$els.header.scrollLeft = event.target.scrollLeft; |
296 | 299 | if (this.leftFixedColumns.length) this.$els.fixedBody.scrollTop = event.target.scrollTop; |
297 | 300 | if (this.rightFixedColumns.length) this.$els.fixedRightBody.scrollTop = event.target.scrollTop; |
301 | + this.hideColumnFilter(); | |
298 | 302 | }, |
299 | 303 | handleMouseWheel (event) { |
300 | 304 | const deltaX = event.deltaX; |
... | ... | @@ -363,8 +367,11 @@ |
363 | 367 | let center = []; |
364 | 368 | |
365 | 369 | columns.forEach((column, index) => { |
366 | - column._sortType = 'normal'; | |
367 | 370 | column._index = index; |
371 | + column._sortType = 'normal'; | |
372 | + column._filterVisible = false; | |
373 | + column._isFiltered = false; | |
374 | + column._filterChecked = []; | |
368 | 375 | |
369 | 376 | if (column.fixed && column.fixed === 'left') { |
370 | 377 | left.push(column); | ... | ... |
src/styles/components/table.less
... | ... | @@ -197,7 +197,7 @@ |
197 | 197 | top: 0; |
198 | 198 | left: 0; |
199 | 199 | box-shadow: @shadow-right; |
200 | - overflow-x: hidden; | |
200 | + //overflow-x: hidden; | |
201 | 201 | |
202 | 202 | &::before { |
203 | 203 | content: ''; |
... | ... | @@ -241,10 +241,39 @@ |
241 | 241 | &:hover{ |
242 | 242 | color: inherit; |
243 | 243 | } |
244 | + &.on{ | |
245 | + color: @primary-color; | |
246 | + } | |
247 | + } | |
248 | + &-list{ | |
249 | + padding: 8px 0 0; | |
250 | + &-item{ | |
251 | + padding: 0 12px 8px; | |
252 | + | |
253 | + .ivu-checkbox-wrapper + .ivu-checkbox-wrapper{ | |
254 | + margin: 0; | |
255 | + } | |
256 | + label { | |
257 | + display: block; | |
258 | + margin-bottom: 4px; | |
259 | + | |
260 | + & > span{ | |
261 | + margin-right: 4px; | |
262 | + } | |
263 | + } | |
264 | + } | |
265 | + } | |
266 | + &-footer{ | |
267 | + padding: 4px; | |
268 | + border-top: 1px solid @border-color-split; | |
244 | 269 | } |
245 | 270 | } |
246 | 271 | .ivu-poptip-popper{ |
247 | 272 | min-width: 0; |
248 | 273 | text-align: left; |
274 | + | |
275 | + .ivu-poptip-body{ | |
276 | + padding: 0; | |
277 | + } | |
249 | 278 | } |
250 | 279 | } |
251 | 280 | \ No newline at end of file | ... | ... |
test/routers/table.vue
... | ... | @@ -79,7 +79,7 @@ |
79 | 79 | } |
80 | 80 | ], |
81 | 81 | render (row) { |
82 | - const type = `${row.tag}` === 'home' ? 'green' : 'red'; | |
82 | + const type = `${row.tag}` === '家' ? 'green' : 'red'; | |
83 | 83 | return `<tag color="${type}">${row.tag}</tag>`; |
84 | 84 | } |
85 | 85 | }, |
... | ... | @@ -135,28 +135,28 @@ |
135 | 135 | age: 25, |
136 | 136 | address: '北京市朝阳区', |
137 | 137 | edit: false, |
138 | - tag: 'home' | |
138 | + tag: '家' | |
139 | 139 | }, |
140 | 140 | { |
141 | 141 | name: '段模', |
142 | 142 | age: 21, |
143 | 143 | address: '北京市海淀区', |
144 | 144 | edit: false, |
145 | - tag: 'company' | |
145 | + tag: '公司' | |
146 | 146 | }, |
147 | 147 | { |
148 | 148 | name: '刘天娇', |
149 | 149 | age: 27, |
150 | 150 | address: '北京市东城区', |
151 | 151 | edit: false, |
152 | - tag: 'company' | |
152 | + tag: '公司' | |
153 | 153 | }, |
154 | 154 | { |
155 | 155 | name: '胡国伟', |
156 | 156 | age: 22, |
157 | 157 | address: '北京市西城区', |
158 | 158 | edit: false, |
159 | - tag: 'home' | |
159 | + tag: '家' | |
160 | 160 | } |
161 | 161 | ], |
162 | 162 | height: 200 | ... | ... |