Commit 19c208d38065e17c2867b7f564ecd36c9180624b

Authored by 梁灏
1 parent f13df74f

Poptip add prop `popper-class`, Table update

examples/routers/table.vue
1 1 <template>
2 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 5 </div>
17 6 </template>
18 7 <script>
19 8 export default {
20 9 data () {
21 10 return {
22   - columns4: [
  11 + columns3: [
23 12 {
24   - type: 'selection',
  13 + type: 'index',
25 14 width: 60,
26 15 align: 'center'
27 16 },
... ... @@ -39,47 +28,6 @@
39 28 }
40 29 ],
41 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 32 name: 'John Brown',
85 33 age: 18,
... ... @@ -104,27 +52,12 @@
104 52 address: 'Ottawa No. 2 Lake Park',
105 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 97 transfer: {
98 98 type: Boolean,
99 99 default: false
  100 + },
  101 + popperClass: {
  102 + type: String
100 103 }
101 104 },
102 105 data () {
... ... @@ -120,7 +123,8 @@
120 123 return [
121 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 1 <template>
2 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 4 <template v-if="renderType === 'selection'">
5 5 <Checkbox :value="checked" @click.native.stop="handleClick" @on-change="toggleSelect" :disabled="disabled"></Checkbox>
6 6 </template>
... ...
src/components/table/table-head.vue
... ... @@ -23,6 +23,8 @@
23 23 v-if="isPopperShow(column)"
24 24 v-model="column._filterVisible"
25 25 placement="bottom"
  26 + popper-class="ivu-table-popper"
  27 + transfer
26 28 @on-popper-hide="handleFilterHide(column._index)">
27 29 <span :class="[prefixCls + '-filter']">
28 30 <i class="ivu-icon ivu-icon-funnel" :class="{on: column._isFiltered}"></i>
... ...
src/styles/components/table.less
... ... @@ -345,15 +345,13 @@
345 345 &-footer{
346 346 padding: 4px;
347 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 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 379 \ No newline at end of file
... ...