iview/test/routers/table.vue

97 lines
3.6 KiB
Vue
Raw Normal View History

<template>
2017-02-20 09:53:10 +08:00
<i-table highlight-row border :content="self" :columns="columns7" :data="data6"></i-table>
</template>
<script>
export default {
data () {
return {
2017-01-16 12:29:03 +08:00
self: this,
columns7: [
2017-02-20 09:53:10 +08:00
{
type: 'selection',
width: 60,
align: 'center'
},
2017-01-16 12:29:03 +08:00
{
title: '姓名',
key: 'name',
render (row, column, index) {
return `<Icon type="person"></Icon> <strong>${row.name}</strong>`;
}
},
{
title: '年龄',
key: 'age',
sortable: true,
sortMethod: function (a, b, type) {
if (type === 'asc') {
return a < b ? 1 : -1;
} else if (type === 'desc') {
return a > b ? 1 : -1;
}
}
2017-01-16 12:29:03 +08:00
},
{
title: '地址',
key: 'address'
},
{
title: '操作',
key: 'action',
2017-01-16 14:25:36 +08:00
width: 150,
2017-01-16 12:29:03 +08:00
align: 'center',
render (row, column, index) {
2017-01-16 14:25:36 +08:00
// return `<i-button type="primary" size="small" @click="show(${index})">查看</i-button> <i-button type="error" size="small" @click="remove(${index})">删除</i-button>`;
return `<Poptip width="250" confirm placement="left" title="您确认删除吗?" @on-ok="deleteProject(${index})">
<i-button size="small" type="error">删除</i-button>
</Poptip>`
2017-01-16 12:29:03 +08:00
}
}
],
data6: [
{
name: '王小明',
age: 18,
2017-02-20 09:53:10 +08:00
address: '北京市朝阳区芍药居',
_highlight: true,
_checked: true,
_disabled: false
2017-01-16 12:29:03 +08:00
},
{
name: '张小刚',
age: 25,
2017-02-20 09:53:10 +08:00
address: '北京市海淀区西二旗',
_checked: false,
_disabled: true
2017-01-16 12:29:03 +08:00
},
{
name: '李小红',
age: 30,
2017-02-20 09:53:10 +08:00
address: '上海市浦东新区世纪大道',
_checked: true,
_disabled: true
2017-01-16 12:29:03 +08:00
},
{
name: '周小伟',
age: 26,
2017-02-20 09:53:10 +08:00
address: '深圳市南山区深南大道',
_checked: true,
_disabled: false
2017-01-16 12:29:03 +08:00
}
]
}
2017-01-16 14:25:36 +08:00
},
methods: {
show (index) {
this.$Modal.info({
title: '用户信息',
content: `姓名:${this.data6[index].name}<br>年龄:${this.data6[index].age}<br>地址:${this.data6[index].address}`
})
},
remove (index) {
this.data6.splice(index, 1);
}
}
}
</script>