Revert Table demo

This commit is contained in:
梁灏 2018-03-21 11:12:31 +08:00
parent 19c208d380
commit 4ad72493f6

View file

@ -1,16 +1,27 @@
<template>
<div>
<Table highlight-row ref="currentRowTable" :columns="columns3" :data="data1"></Table>
<Button @click="handleClearCurrentRow">Clear</Button>
<Table border ref="selection" :columns="columns4" :data="data1"></Table>
<Button @click="handleSetData">Set Data</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>
</template>
<script>
export default {
data () {
return {
columns3: [
columns4: [
{
type: 'index',
type: 'selection',
width: 60,
align: 'center'
},
@ -28,6 +39,47 @@
}
],
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',
age: 18,
@ -52,12 +104,27 @@
address: 'Ottawa No. 2 Lake Park',
date: '2016-10-04'
}
]
}
];
},
methods: {
handleClearCurrentRow () {
this.$refs.currentRowTable.clearCurrentRow();
handleClearData () {
this.data1 = [];
},
refreshData(){
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();
}
}
}