Commit 19c208d38065e17c2867b7f564ecd36c9180624b
1 parent
f13df74f
Poptip add prop `popper-class`, Table update
Showing
5 changed files
with
32 additions
and
88 deletions
Show diff stats
examples/routers/table.vue
| 1 | <template> | 1 | <template> |
| 2 | <div> | 2 | <div> |
| 3 | - <Table border ref="selection" :columns="columns4" :data="data1"></Table> | ||
| 4 | - <Button @click="handleSetData">Set Data</Button> | ||
| 5 | - <Button @click="handleClearData">Clear Data</Button> | ||
| 6 | - <Button @click="handleSelectAll(true)">Set all selected</Button> | ||
| 7 | - <Button @click="handleSelectAll(false)">Cancel all selected</Button> | ||
| 8 | - <div style="margin:20px 0px;"> | ||
| 9 | - <Table :data="tableData1" :columns="tableColumns1" style="width: 100%;" stripe></Table> | ||
| 10 | - <div style="margin: 10px;overflow: hidden"> | ||
| 11 | - <div style="float: right;"> | ||
| 12 | - <Page :total="100" show-sizer :current="1" @on-change="changePage"></Page> | ||
| 13 | - </div> | ||
| 14 | - </div> | ||
| 15 | - </div> | 3 | + <Table highlight-row ref="currentRowTable" :columns="columns3" :data="data1"></Table> |
| 4 | + <Button @click="handleClearCurrentRow">Clear</Button> | ||
| 16 | </div> | 5 | </div> |
| 17 | </template> | 6 | </template> |
| 18 | <script> | 7 | <script> |
| 19 | export default { | 8 | export default { |
| 20 | data () { | 9 | data () { |
| 21 | return { | 10 | return { |
| 22 | - columns4: [ | 11 | + columns3: [ |
| 23 | { | 12 | { |
| 24 | - type: 'selection', | 13 | + type: 'index', |
| 25 | width: 60, | 14 | width: 60, |
| 26 | align: 'center' | 15 | align: 'center' |
| 27 | }, | 16 | }, |
| @@ -39,47 +28,6 @@ | @@ -39,47 +28,6 @@ | ||
| 39 | } | 28 | } |
| 40 | ], | 29 | ], |
| 41 | data1: [ | 30 | data1: [ |
| 42 | - | ||
| 43 | - ], | ||
| 44 | - | ||
| 45 | - tableData1: [], | ||
| 46 | - tableColumns1: [ | ||
| 47 | - { | ||
| 48 | - title: 'Data1', | ||
| 49 | - key: 'data1' | ||
| 50 | - }, | ||
| 51 | - { | ||
| 52 | - title: 'Data2', | ||
| 53 | - key: 'data2' | ||
| 54 | - }, | ||
| 55 | - { | ||
| 56 | - title: 'Data3', | ||
| 57 | - key: 'data3' | ||
| 58 | - }, | ||
| 59 | - { | ||
| 60 | - title: 'Data4', | ||
| 61 | - key: 'data4' | ||
| 62 | - }, | ||
| 63 | - { | ||
| 64 | - title: 'Data5', | ||
| 65 | - key: 'data5' | ||
| 66 | - }, | ||
| 67 | - { | ||
| 68 | - title: 'Data6', | ||
| 69 | - key: 'data6' | ||
| 70 | - }, | ||
| 71 | - ] | ||
| 72 | - } | ||
| 73 | - }, | ||
| 74 | - mounted(){ | ||
| 75 | - this.refreshData(); | ||
| 76 | - }, | ||
| 77 | - methods: { | ||
| 78 | - handleSelectAll (status) { | ||
| 79 | - this.$refs.selection.selectAll(status); | ||
| 80 | - }, | ||
| 81 | - handleSetData () { | ||
| 82 | - this.data1 = [ | ||
| 83 | { | 31 | { |
| 84 | name: 'John Brown', | 32 | name: 'John Brown', |
| 85 | age: 18, | 33 | age: 18, |
| @@ -104,27 +52,12 @@ | @@ -104,27 +52,12 @@ | ||
| 104 | address: 'Ottawa No. 2 Lake Park', | 52 | address: 'Ottawa No. 2 Lake Park', |
| 105 | date: '2016-10-04' | 53 | date: '2016-10-04' |
| 106 | } | 54 | } |
| 107 | - ]; | ||
| 108 | - }, | ||
| 109 | - handleClearData () { | ||
| 110 | - this.data1 = []; | ||
| 111 | - }, | ||
| 112 | - refreshData(){ | ||
| 113 | - let data = []; | ||
| 114 | - for (let i = 0; i < 10; i++) { | ||
| 115 | - data.push({ | ||
| 116 | - data1: Math.floor(Math.random () * 10000), | ||
| 117 | - data2: Math.floor(Math.random () * 1000000), | ||
| 118 | - data3: Math.floor(Math.random () * 100000000), | ||
| 119 | - data4: Math.floor(Math.random () * Math.random () * 10000), | ||
| 120 | - data5: Math.floor(Math.random () * Math.random () * 1000000), | ||
| 121 | - data6: Math.floor(Math.random () * Math.random () * 100000000), | ||
| 122 | - }); | ||
| 123 | - } | ||
| 124 | - this.tableData1 = data; | ||
| 125 | - }, | ||
| 126 | - changePage(){ | ||
| 127 | - this.refreshData(); | 55 | + ] |
| 56 | + } | ||
| 57 | + }, | ||
| 58 | + methods: { | ||
| 59 | + handleClearCurrentRow () { | ||
| 60 | + this.$refs.currentRowTable.clearCurrentRow(); | ||
| 128 | } | 61 | } |
| 129 | } | 62 | } |
| 130 | } | 63 | } |
src/components/poptip/poptip.vue
| @@ -97,6 +97,9 @@ | @@ -97,6 +97,9 @@ | ||
| 97 | transfer: { | 97 | transfer: { |
| 98 | type: Boolean, | 98 | type: Boolean, |
| 99 | default: false | 99 | default: false |
| 100 | + }, | ||
| 101 | + popperClass: { | ||
| 102 | + type: String | ||
| 100 | } | 103 | } |
| 101 | }, | 104 | }, |
| 102 | data () { | 105 | data () { |
| @@ -120,7 +123,8 @@ | @@ -120,7 +123,8 @@ | ||
| 120 | return [ | 123 | return [ |
| 121 | `${prefixCls}-popper`, | 124 | `${prefixCls}-popper`, |
| 122 | { | 125 | { |
| 123 | - [`${prefixCls}-confirm`]: this.transfer && this.confirm | 126 | + [`${prefixCls}-confirm`]: this.transfer && this.confirm, |
| 127 | + [`${this.popperClass}`]: !!this.popperClass | ||
| 124 | } | 128 | } |
| 125 | ]; | 129 | ]; |
| 126 | }, | 130 | }, |
src/components/table/cell.vue
| 1 | <template> | 1 | <template> |
| 2 | <div :class="classes" ref="cell"> | 2 | <div :class="classes" ref="cell"> |
| 3 | - <template v-if="renderType === 'index'">{{naturalIndex + 1}}</template> | 3 | + <template v-if="renderType === 'index'"><span>{{naturalIndex + 1}}</span></template> |
| 4 | <template v-if="renderType === 'selection'"> | 4 | <template v-if="renderType === 'selection'"> |
| 5 | <Checkbox :value="checked" @click.native.stop="handleClick" @on-change="toggleSelect" :disabled="disabled"></Checkbox> | 5 | <Checkbox :value="checked" @click.native.stop="handleClick" @on-change="toggleSelect" :disabled="disabled"></Checkbox> |
| 6 | </template> | 6 | </template> |
src/components/table/table-head.vue
| @@ -23,6 +23,8 @@ | @@ -23,6 +23,8 @@ | ||
| 23 | v-if="isPopperShow(column)" | 23 | v-if="isPopperShow(column)" |
| 24 | v-model="column._filterVisible" | 24 | v-model="column._filterVisible" |
| 25 | placement="bottom" | 25 | placement="bottom" |
| 26 | + popper-class="ivu-table-popper" | ||
| 27 | + transfer | ||
| 26 | @on-popper-hide="handleFilterHide(column._index)"> | 28 | @on-popper-hide="handleFilterHide(column._index)"> |
| 27 | <span :class="[prefixCls + '-filter']"> | 29 | <span :class="[prefixCls + '-filter']"> |
| 28 | <i class="ivu-icon ivu-icon-funnel" :class="{on: column._isFiltered}"></i> | 30 | <i class="ivu-icon ivu-icon-funnel" :class="{on: column._isFiltered}"></i> |
src/styles/components/table.less
| @@ -345,15 +345,13 @@ | @@ -345,15 +345,13 @@ | ||
| 345 | &-footer{ | 345 | &-footer{ |
| 346 | padding: 4px; | 346 | padding: 4px; |
| 347 | border-top: 1px solid @border-color-split; | 347 | border-top: 1px solid @border-color-split; |
| 348 | - } | ||
| 349 | - } | ||
| 350 | - .ivu-poptip-popper{ | ||
| 351 | - min-width: 0; | ||
| 352 | - text-align: left; | ||
| 353 | - } | ||
| 354 | - thead .ivu-poptip-popper{ | ||
| 355 | - .ivu-poptip-body{ | ||
| 356 | - padding: 0; | 348 | + overflow: hidden; |
| 349 | + button:first-child{ | ||
| 350 | + float: left; | ||
| 351 | + } | ||
| 352 | + button:last-child{ | ||
| 353 | + float: right; | ||
| 354 | + } | ||
| 357 | } | 355 | } |
| 358 | } | 356 | } |
| 359 | 357 | ||
| @@ -371,3 +369,10 @@ | @@ -371,3 +369,10 @@ | ||
| 371 | visibility: hidden; | 369 | visibility: hidden; |
| 372 | } | 370 | } |
| 373 | } | 371 | } |
| 372 | +.ivu-table-popper{ | ||
| 373 | + min-width: 0; | ||
| 374 | + text-align: left; | ||
| 375 | + .ivu-poptip-body{ | ||
| 376 | + padding: 0; | ||
| 377 | + } | ||
| 378 | +} | ||
| 374 | \ No newline at end of file | 379 | \ No newline at end of file |