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 +14,24 @@ | ||
| 14 | <i class="ivu-icon ivu-icon-arrow-up-b" :class="{on: column._sortType === 'asc'}" @click="handleSort($index, 'asc')"></i> | 14 | <i class="ivu-icon ivu-icon-arrow-up-b" :class="{on: column._sortType === 'asc'}" @click="handleSort($index, 'asc')"></i> |
| 15 | <i class="ivu-icon ivu-icon-arrow-down-b" :class="{on: column._sortType === 'desc'}" @click="handleSort($index, 'desc')"></i> | 15 | <i class="ivu-icon ivu-icon-arrow-down-b" :class="{on: column._sortType === 'desc'}" @click="handleSort($index, 'desc')"></i> |
| 16 | </span> | 16 | </span> |
| 17 | - <Poptip v-if="column.filters" placement="bottom-end"> | 17 | + <Poptip v-if="column.filters" :visible.sync="column._filterVisible" placement="bottom"> |
| 18 | <span :class="[prefixCls + '-filter']"> | 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 | </span> | 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 | <ul> | 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 | </ul> | 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 | </div> | 35 | </div> |
| 26 | </Poptip> | 36 | </Poptip> |
| 27 | </template> | 37 | </template> |
| @@ -32,14 +42,16 @@ | @@ -32,14 +42,16 @@ | ||
| 32 | </table> | 42 | </table> |
| 33 | </template> | 43 | </template> |
| 34 | <script> | 44 | <script> |
| 45 | + import CheckboxGroup from '../checkbox/checkbox-group.vue'; | ||
| 35 | import Checkbox from '../checkbox/checkbox.vue'; | 46 | import Checkbox from '../checkbox/checkbox.vue'; |
| 36 | import Poptip from '../poptip/poptip.vue'; | 47 | import Poptip from '../poptip/poptip.vue'; |
| 48 | + import iButton from '../button/button.vue'; | ||
| 37 | import Mixin from './mixin'; | 49 | import Mixin from './mixin'; |
| 38 | import { deepCopy } from '../../utils/assist'; | 50 | import { deepCopy } from '../../utils/assist'; |
| 39 | 51 | ||
| 40 | export default { | 52 | export default { |
| 41 | mixins: [ Mixin ], | 53 | mixins: [ Mixin ], |
| 42 | - components: { Checkbox, Poptip }, | 54 | + components: { CheckboxGroup, Checkbox, Poptip, iButton }, |
| 43 | props: { | 55 | props: { |
| 44 | prefixCls: String, | 56 | prefixCls: String, |
| 45 | style: Object, | 57 | style: Object, |
| @@ -88,6 +100,12 @@ | @@ -88,6 +100,12 @@ | ||
| 88 | }, | 100 | }, |
| 89 | handleFilter (index) { | 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,10 +291,14 @@ | ||
| 291 | }) | 291 | }) |
| 292 | } | 292 | } |
| 293 | }, | 293 | }, |
| 294 | + hideColumnFilter () { | ||
| 295 | + this.cloneColumns.forEach((col) => col._filterVisible = false); | ||
| 296 | + }, | ||
| 294 | handleBodyScroll (event) { | 297 | handleBodyScroll (event) { |
| 295 | if (this.showHeader) this.$els.header.scrollLeft = event.target.scrollLeft; | 298 | if (this.showHeader) this.$els.header.scrollLeft = event.target.scrollLeft; |
| 296 | if (this.leftFixedColumns.length) this.$els.fixedBody.scrollTop = event.target.scrollTop; | 299 | if (this.leftFixedColumns.length) this.$els.fixedBody.scrollTop = event.target.scrollTop; |
| 297 | if (this.rightFixedColumns.length) this.$els.fixedRightBody.scrollTop = event.target.scrollTop; | 300 | if (this.rightFixedColumns.length) this.$els.fixedRightBody.scrollTop = event.target.scrollTop; |
| 301 | + this.hideColumnFilter(); | ||
| 298 | }, | 302 | }, |
| 299 | handleMouseWheel (event) { | 303 | handleMouseWheel (event) { |
| 300 | const deltaX = event.deltaX; | 304 | const deltaX = event.deltaX; |
| @@ -363,8 +367,11 @@ | @@ -363,8 +367,11 @@ | ||
| 363 | let center = []; | 367 | let center = []; |
| 364 | 368 | ||
| 365 | columns.forEach((column, index) => { | 369 | columns.forEach((column, index) => { |
| 366 | - column._sortType = 'normal'; | ||
| 367 | column._index = index; | 370 | column._index = index; |
| 371 | + column._sortType = 'normal'; | ||
| 372 | + column._filterVisible = false; | ||
| 373 | + column._isFiltered = false; | ||
| 374 | + column._filterChecked = []; | ||
| 368 | 375 | ||
| 369 | if (column.fixed && column.fixed === 'left') { | 376 | if (column.fixed && column.fixed === 'left') { |
| 370 | left.push(column); | 377 | left.push(column); |
src/styles/components/table.less
| @@ -197,7 +197,7 @@ | @@ -197,7 +197,7 @@ | ||
| 197 | top: 0; | 197 | top: 0; |
| 198 | left: 0; | 198 | left: 0; |
| 199 | box-shadow: @shadow-right; | 199 | box-shadow: @shadow-right; |
| 200 | - overflow-x: hidden; | 200 | + //overflow-x: hidden; |
| 201 | 201 | ||
| 202 | &::before { | 202 | &::before { |
| 203 | content: ''; | 203 | content: ''; |
| @@ -241,10 +241,39 @@ | @@ -241,10 +241,39 @@ | ||
| 241 | &:hover{ | 241 | &:hover{ |
| 242 | color: inherit; | 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 | .ivu-poptip-popper{ | 271 | .ivu-poptip-popper{ |
| 247 | min-width: 0; | 272 | min-width: 0; |
| 248 | text-align: left; | 273 | text-align: left; |
| 274 | + | ||
| 275 | + .ivu-poptip-body{ | ||
| 276 | + padding: 0; | ||
| 277 | + } | ||
| 249 | } | 278 | } |
| 250 | } | 279 | } |
| 251 | \ No newline at end of file | 280 | \ No newline at end of file |
test/routers/table.vue
| @@ -79,7 +79,7 @@ | @@ -79,7 +79,7 @@ | ||
| 79 | } | 79 | } |
| 80 | ], | 80 | ], |
| 81 | render (row) { | 81 | render (row) { |
| 82 | - const type = `${row.tag}` === 'home' ? 'green' : 'red'; | 82 | + const type = `${row.tag}` === '家' ? 'green' : 'red'; |
| 83 | return `<tag color="${type}">${row.tag}</tag>`; | 83 | return `<tag color="${type}">${row.tag}</tag>`; |
| 84 | } | 84 | } |
| 85 | }, | 85 | }, |
| @@ -135,28 +135,28 @@ | @@ -135,28 +135,28 @@ | ||
| 135 | age: 25, | 135 | age: 25, |
| 136 | address: '北京市朝阳区', | 136 | address: '北京市朝阳区', |
| 137 | edit: false, | 137 | edit: false, |
| 138 | - tag: 'home' | 138 | + tag: '家' |
| 139 | }, | 139 | }, |
| 140 | { | 140 | { |
| 141 | name: '段模', | 141 | name: '段模', |
| 142 | age: 21, | 142 | age: 21, |
| 143 | address: '北京市海淀区', | 143 | address: '北京市海淀区', |
| 144 | edit: false, | 144 | edit: false, |
| 145 | - tag: 'company' | 145 | + tag: '公司' |
| 146 | }, | 146 | }, |
| 147 | { | 147 | { |
| 148 | name: '刘天娇', | 148 | name: '刘天娇', |
| 149 | age: 27, | 149 | age: 27, |
| 150 | address: '北京市东城区', | 150 | address: '北京市东城区', |
| 151 | edit: false, | 151 | edit: false, |
| 152 | - tag: 'company' | 152 | + tag: '公司' |
| 153 | }, | 153 | }, |
| 154 | { | 154 | { |
| 155 | name: '胡国伟', | 155 | name: '胡国伟', |
| 156 | age: 22, | 156 | age: 22, |
| 157 | address: '北京市西城区', | 157 | address: '北京市西城区', |
| 158 | edit: false, | 158 | edit: false, |
| 159 | - tag: 'home' | 159 | + tag: '家' |
| 160 | } | 160 | } |
| 161 | ], | 161 | ], |
| 162 | height: 200 | 162 | height: 200 |