Poptip add prop popper-class, Table update

This commit is contained in:
梁灏 2018-03-21 10:59:23 +08:00
parent f13df74fef
commit 19c208d380
5 changed files with 32 additions and 88 deletions

View file

@ -1,27 +1,16 @@
<template> <template>
<div> <div>
<Table border ref="selection" :columns="columns4" :data="data1"></Table> <Table highlight-row ref="currentRowTable" :columns="columns3" :data="data1"></Table>
<Button @click="handleSetData">Set Data</Button> <Button @click="handleClearCurrentRow">Clear</Button>
<Button @click="handleClearData">Clear Data</Button>
<Button @click="handleSelectAll(true)">Set all selected</Button>
<Button @click="handleSelectAll(false)">Cancel all selected</Button>
<div style="margin:20px 0px;">
<Table :data="tableData1" :columns="tableColumns1" style="width: 100%;" stripe></Table>
<div style="margin: 10px;overflow: hidden">
<div style="float: right;">
<Page :total="100" show-sizer :current="1" @on-change="changePage"></Page>
</div>
</div>
</div>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
data () { data () {
return { return {
columns4: [ columns3: [
{ {
type: 'selection', type: 'index',
width: 60, width: 60,
align: 'center' align: 'center'
}, },
@ -39,47 +28,6 @@
} }
], ],
data1: [ data1: [
],
tableData1: [],
tableColumns1: [
{
title: 'Data1',
key: 'data1'
},
{
title: 'Data2',
key: 'data2'
},
{
title: 'Data3',
key: 'data3'
},
{
title: 'Data4',
key: 'data4'
},
{
title: 'Data5',
key: 'data5'
},
{
title: 'Data6',
key: 'data6'
},
]
}
},
mounted(){
this.refreshData();
},
methods: {
handleSelectAll (status) {
this.$refs.selection.selectAll(status);
},
handleSetData () {
this.data1 = [
{ {
name: 'John Brown', name: 'John Brown',
age: 18, age: 18,
@ -104,27 +52,12 @@
address: 'Ottawa No. 2 Lake Park', address: 'Ottawa No. 2 Lake Park',
date: '2016-10-04' date: '2016-10-04'
} }
]; ]
}, }
handleClearData () { },
this.data1 = []; methods: {
}, handleClearCurrentRow () {
refreshData(){ this.$refs.currentRowTable.clearCurrentRow();
let data = [];
for (let i = 0; i < 10; i++) {
data.push({
data1: Math.floor(Math.random () * 10000),
data2: Math.floor(Math.random () * 1000000),
data3: Math.floor(Math.random () * 100000000),
data4: Math.floor(Math.random () * Math.random () * 10000),
data5: Math.floor(Math.random () * Math.random () * 1000000),
data6: Math.floor(Math.random () * Math.random () * 100000000),
});
}
this.tableData1 = data;
},
changePage(){
this.refreshData();
} }
} }
} }

View file

@ -97,6 +97,9 @@
transfer: { transfer: {
type: Boolean, type: Boolean,
default: false default: false
},
popperClass: {
type: String
} }
}, },
data () { data () {
@ -120,7 +123,8 @@
return [ return [
`${prefixCls}-popper`, `${prefixCls}-popper`,
{ {
[`${prefixCls}-confirm`]: this.transfer && this.confirm [`${prefixCls}-confirm`]: this.transfer && this.confirm,
[`${this.popperClass}`]: !!this.popperClass
} }
]; ];
}, },

View file

@ -1,6 +1,6 @@
<template> <template>
<div :class="classes" ref="cell"> <div :class="classes" ref="cell">
<template v-if="renderType === 'index'">{{naturalIndex + 1}}</template> <template v-if="renderType === 'index'"><span>{{naturalIndex + 1}}</span></template>
<template v-if="renderType === 'selection'"> <template v-if="renderType === 'selection'">
<Checkbox :value="checked" @click.native.stop="handleClick" @on-change="toggleSelect" :disabled="disabled"></Checkbox> <Checkbox :value="checked" @click.native.stop="handleClick" @on-change="toggleSelect" :disabled="disabled"></Checkbox>
</template> </template>

View file

@ -23,6 +23,8 @@
v-if="isPopperShow(column)" v-if="isPopperShow(column)"
v-model="column._filterVisible" v-model="column._filterVisible"
placement="bottom" placement="bottom"
popper-class="ivu-table-popper"
transfer
@on-popper-hide="handleFilterHide(column._index)"> @on-popper-hide="handleFilterHide(column._index)">
<span :class="[prefixCls + '-filter']"> <span :class="[prefixCls + '-filter']">
<i class="ivu-icon ivu-icon-funnel" :class="{on: column._isFiltered}"></i> <i class="ivu-icon ivu-icon-funnel" :class="{on: column._isFiltered}"></i>

View file

@ -345,15 +345,13 @@
&-footer{ &-footer{
padding: 4px; padding: 4px;
border-top: 1px solid @border-color-split; border-top: 1px solid @border-color-split;
} overflow: hidden;
} button:first-child{
.ivu-poptip-popper{ float: left;
min-width: 0; }
text-align: left; button:last-child{
} float: right;
thead .ivu-poptip-popper{ }
.ivu-poptip-body{
padding: 0;
} }
} }
@ -371,3 +369,10 @@
visibility: hidden; visibility: hidden;
} }
} }
.ivu-table-popper{
min-width: 0;
text-align: left;
.ivu-poptip-body{
padding: 0;
}
}