2016-11-23 16:27:17 +08:00
|
|
|
<template>
|
2017-07-14 14:52:54 +08:00
|
|
|
<div>
|
|
|
|
<div style="margin: 10px">
|
|
|
|
显示边框 <i-switch v-model="showBorder" style="margin-right: 5px"></i-switch>
|
|
|
|
显示斑马纹 <i-switch v-model="showStripe" style="margin-right: 5px"></i-switch>
|
|
|
|
显示索引 <i-switch v-model="showIndex" style="margin-right: 5px"></i-switch>
|
|
|
|
显示多选框 <i-switch v-model="showCheckbox" style="margin-right: 5px"></i-switch>
|
|
|
|
显示表头 <i-switch v-model="showHeader" style="margin-right: 5px"></i-switch>
|
|
|
|
表格滚动 <i-switch v-model="fixedHeader" style="margin-right: 5px"></i-switch>
|
|
|
|
<br>
|
|
|
|
<br>
|
|
|
|
表格尺寸
|
|
|
|
<Radio-group v-model="tableSize" type="button">
|
|
|
|
<Radio label="large">大</Radio>
|
|
|
|
<Radio label="default">中</Radio>
|
|
|
|
<Radio label="small">小</Radio>
|
|
|
|
</Radio-group>
|
|
|
|
</div>
|
|
|
|
<Table :border="showBorder" :stripe="showStripe" :show-header="showHeader" :height="fixedHeader ? 250 : ''" :size="tableSize" :data="tableData3" :columns="tableColumns3"></Table>
|
|
|
|
</div>
|
2016-11-23 16:27:17 +08:00
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data () {
|
|
|
|
return {
|
2017-07-14 14:52:54 +08:00
|
|
|
tableData3: [
|
2017-07-07 13:01:49 -05:00
|
|
|
{
|
2017-07-14 14:52:54 +08:00
|
|
|
name: '王小明',
|
|
|
|
age: 18,
|
|
|
|
address: '北京市朝阳区芍药居',
|
|
|
|
date: '2016-10-03'
|
2017-05-26 14:00:42 +08:00
|
|
|
},
|
2017-01-16 12:29:03 +08:00
|
|
|
{
|
2017-07-14 14:52:54 +08:00
|
|
|
name: '张小刚',
|
|
|
|
age: 24,
|
|
|
|
address: '北京市海淀区西二旗',
|
|
|
|
date: '2016-10-01'
|
2017-01-16 12:29:03 +08:00
|
|
|
},
|
|
|
|
{
|
2017-07-14 14:52:54 +08:00
|
|
|
name: '李小红',
|
|
|
|
age: 30,
|
|
|
|
address: '上海市浦东新区世纪大道',
|
|
|
|
date: '2016-10-02'
|
2017-03-15 15:27:04 +08:00
|
|
|
},
|
|
|
|
{
|
2017-07-14 14:52:54 +08:00
|
|
|
name: '周小伟',
|
|
|
|
age: 26,
|
|
|
|
address: '深圳市南山区深南大道',
|
|
|
|
date: '2016-10-04'
|
2017-05-27 15:13:10 +08:00
|
|
|
},
|
2017-04-05 12:49:40 +08:00
|
|
|
{
|
|
|
|
name: '王小明',
|
|
|
|
age: 18,
|
2017-06-09 16:44:24 +08:00
|
|
|
address: '北京市朝阳区芍药居',
|
|
|
|
date: '2016-10-03'
|
2017-03-09 16:03:36 +08:00
|
|
|
},
|
2017-04-05 10:35:27 +08:00
|
|
|
{
|
2017-04-05 12:49:40 +08:00
|
|
|
name: '张小刚',
|
2017-07-14 14:52:54 +08:00
|
|
|
age: 24,
|
2017-06-02 10:35:18 +08:00
|
|
|
address: '北京市海淀区西二旗',
|
2017-06-09 16:44:24 +08:00
|
|
|
date: '2016-10-01'
|
2017-05-27 15:13:10 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: '李小红',
|
|
|
|
age: 30,
|
2017-05-27 18:09:57 +08:00
|
|
|
address: '上海市浦东新区世纪大道',
|
2017-06-09 16:44:24 +08:00
|
|
|
date: '2016-10-02'
|
2017-05-27 15:13:10 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: '周小伟',
|
|
|
|
age: 26,
|
2017-06-09 16:44:24 +08:00
|
|
|
address: '深圳市南山区深南大道',
|
|
|
|
date: '2016-10-04'
|
2017-07-14 14:52:54 +08:00
|
|
|
}
|
|
|
|
],
|
|
|
|
showBorder: false,
|
|
|
|
showStripe: false,
|
|
|
|
showHeader: true,
|
|
|
|
showIndex: true,
|
|
|
|
showCheckbox: false,
|
|
|
|
fixedHeader: false,
|
|
|
|
tableSize: 'default'
|
2016-11-23 16:27:17 +08:00
|
|
|
}
|
2017-07-07 13:01:49 -05:00
|
|
|
},
|
2017-07-14 14:52:54 +08:00
|
|
|
computed: {
|
|
|
|
tableColumns3 () {
|
|
|
|
let columns = [];
|
|
|
|
if (this.showCheckbox) {
|
|
|
|
columns.push({
|
|
|
|
type: 'selection',
|
|
|
|
width: 60,
|
|
|
|
align: 'center'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if (this.showIndex) {
|
|
|
|
columns.push({
|
|
|
|
type: 'index',
|
|
|
|
width: 60,
|
|
|
|
align: 'center'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
columns.push({
|
|
|
|
title: '日期',
|
|
|
|
key: 'date',
|
|
|
|
sortable: true
|
|
|
|
});
|
|
|
|
columns.push({
|
|
|
|
title: '姓名',
|
|
|
|
key: 'name'
|
|
|
|
});
|
|
|
|
columns.push({
|
|
|
|
title: '年龄',
|
|
|
|
key: 'age',
|
|
|
|
sortable: true,
|
|
|
|
filters: [
|
|
|
|
{
|
|
|
|
label: '大于25岁',
|
|
|
|
value: 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '小于25岁',
|
|
|
|
value: 2
|
|
|
|
}
|
|
|
|
],
|
|
|
|
filterMultiple: false,
|
|
|
|
filterMethod (value, row) {
|
|
|
|
if (value === 1) {
|
|
|
|
return row.age > 25;
|
|
|
|
} else if (value === 2) {
|
|
|
|
return row.age < 25;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
columns.push({
|
|
|
|
title: '地址',
|
|
|
|
key: 'address',
|
|
|
|
filters: [
|
|
|
|
{
|
|
|
|
label: '北京',
|
|
|
|
value: '北京'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '上海',
|
|
|
|
value: '上海'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '深圳',
|
|
|
|
value: '深圳'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
filterMethod (value, row) {
|
|
|
|
return row.address.indexOf(value) > -1;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return columns;
|
2017-07-07 13:01:49 -05:00
|
|
|
}
|
2016-11-23 16:27:17 +08:00
|
|
|
}
|
|
|
|
}
|
2017-07-14 14:52:54 +08:00
|
|
|
</script>
|