2018-11-28 16:49:46 +08:00
|
|
|
<template>
|
2019-04-27 20:08:40 +08:00
|
|
|
<d2-container type="card">
|
2018-11-28 16:49:46 +08:00
|
|
|
<d2-crud
|
|
|
|
|
v-bind="crud"
|
2018-11-29 10:14:44 +08:00
|
|
|
@edit="({ index, row }) => goToEditPage('demo-business-issues-142-edit', row.id)"
|
|
|
|
|
@edit-cache-db="({ index, row }) => goToEditPage('demo-business-issues-142-edit-cache-db', row.id)"
|
2018-11-28 16:49:46 +08:00
|
|
|
style="margin: -15px 0;"/>
|
|
|
|
|
<template slot="footer">
|
|
|
|
|
<d2-link-btn
|
|
|
|
|
title="issue #142"
|
|
|
|
|
link="https://github.com/d2-projects/d2-admin/issues/142"/>
|
|
|
|
|
</template>
|
|
|
|
|
</d2-container>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2018-12-14 10:42:43 +08:00
|
|
|
// API
|
|
|
|
|
import {
|
|
|
|
|
fetch
|
|
|
|
|
} from '@/api/demo.business.issues.142'
|
|
|
|
|
|
2018-11-28 16:49:46 +08:00
|
|
|
export default {
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
crud: {
|
|
|
|
|
columns: [
|
2018-12-14 10:42:43 +08:00
|
|
|
{ title: '姓名', key: 'name', width: 100 },
|
2018-11-28 16:49:46 +08:00
|
|
|
{ title: '地址', key: 'address' }
|
|
|
|
|
],
|
2018-12-14 10:42:43 +08:00
|
|
|
data: [],
|
2018-11-28 16:49:46 +08:00
|
|
|
options: {
|
|
|
|
|
border: true,
|
|
|
|
|
size: 'mini'
|
|
|
|
|
},
|
|
|
|
|
rowHandle: {
|
|
|
|
|
align: 'center',
|
2018-12-14 10:42:43 +08:00
|
|
|
width: 240,
|
2018-11-28 16:49:46 +08:00
|
|
|
custom: [
|
|
|
|
|
{
|
2018-11-28 19:43:04 +08:00
|
|
|
text: '无缓存编辑',
|
2018-11-28 16:49:46 +08:00
|
|
|
size: 'mini',
|
|
|
|
|
emit: 'edit'
|
2018-11-29 10:14:44 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text: '带缓存编辑 DB',
|
|
|
|
|
size: 'mini',
|
|
|
|
|
emit: 'edit-cache-db'
|
2018-11-28 16:49:46 +08:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2018-12-14 10:42:43 +08:00
|
|
|
created () {
|
|
|
|
|
this.getTableData()
|
|
|
|
|
},
|
2018-11-28 16:49:46 +08:00
|
|
|
methods: {
|
2018-12-14 10:42:43 +08:00
|
|
|
// 请求表格数据
|
|
|
|
|
getTableData () {
|
|
|
|
|
fetch()
|
2018-12-15 09:40:54 +08:00
|
|
|
.then(res => {
|
|
|
|
|
this.crud.data = res.list
|
|
|
|
|
})
|
2018-12-14 10:42:43 +08:00
|
|
|
.catch(err => console.log(err))
|
|
|
|
|
},
|
|
|
|
|
// 跳转到编辑页面
|
2018-11-29 10:14:44 +08:00
|
|
|
goToEditPage (name, id) {
|
2018-11-28 16:49:46 +08:00
|
|
|
this.$router.push({
|
2018-11-29 10:14:44 +08:00
|
|
|
name,
|
2018-11-28 16:49:46 +08:00
|
|
|
params: {
|
2018-11-29 10:14:44 +08:00
|
|
|
id
|
2018-11-28 16:49:46 +08:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|