2018-08-05 22:21:17 +08:00
|
|
|
<template>
|
2019-04-27 20:08:40 +08:00
|
|
|
<d2-container>
|
2018-08-07 11:00:20 +08:00
|
|
|
<demo-page-header
|
|
|
|
|
slot="header"
|
2018-08-07 11:38:25 +08:00
|
|
|
@submit="handleSubmit"
|
|
|
|
|
ref="header"/>
|
2018-08-07 11:00:20 +08:00
|
|
|
<demo-page-main
|
2018-08-07 13:46:04 +08:00
|
|
|
:table-data="table"
|
|
|
|
|
:loading="loading"/>
|
2018-08-07 11:00:20 +08:00
|
|
|
<demo-page-footer
|
|
|
|
|
slot="footer"
|
2018-12-13 10:29:56 +08:00
|
|
|
:current="page.pageCurrent"
|
|
|
|
|
:size="page.pageSize"
|
|
|
|
|
:total="page.pageTotal"
|
2018-08-07 11:00:20 +08:00
|
|
|
@change="handlePaginationChange"/>
|
2018-08-05 22:21:17 +08:00
|
|
|
</d2-container>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2018-12-11 08:48:38 +08:00
|
|
|
import { BusinessTable1List } from '@api/demo.business.table.1'
|
2018-08-05 22:21:17 +08:00
|
|
|
export default {
|
2018-08-07 09:28:21 +08:00
|
|
|
// name 值和本页的 $route.name 一致才可以缓存页面
|
|
|
|
|
name: 'demo-business-table-1',
|
2018-08-05 22:21:17 +08:00
|
|
|
components: {
|
|
|
|
|
'DemoPageHeader': () => import('./componnets/PageHeader'),
|
|
|
|
|
'DemoPageMain': () => import('./componnets/PageMain'),
|
|
|
|
|
'DemoPageFooter': () => import('./componnets/PageFooter')
|
2018-08-06 10:45:45 +08:00
|
|
|
},
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
2018-08-07 11:38:25 +08:00
|
|
|
table: [],
|
2018-08-07 13:46:04 +08:00
|
|
|
loading: false,
|
2018-08-07 11:38:25 +08:00
|
|
|
page: {
|
2018-12-13 10:29:56 +08:00
|
|
|
pageCurrent: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
pageTotal: 0
|
2018-08-07 11:38:25 +08:00
|
|
|
}
|
2018-08-06 10:45:45 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
2020-04-21 18:19:13 +08:00
|
|
|
async handlePaginationChange (val) {
|
2018-08-07 11:00:20 +08:00
|
|
|
this.$notify({
|
|
|
|
|
title: '分页变化',
|
|
|
|
|
message: `当前第${val.current}页 共${val.total}条 每页${val.size}条`
|
|
|
|
|
})
|
2019-10-28 10:09:46 +08:00
|
|
|
this.page = {
|
|
|
|
|
pageCurrent: val.current,
|
|
|
|
|
pageSize: val.size,
|
|
|
|
|
pageTotal: val.total
|
|
|
|
|
}
|
2018-08-07 13:46:04 +08:00
|
|
|
// nextTick 只是为了优化示例中 notify 的显示
|
2020-04-21 18:19:13 +08:00
|
|
|
await this.$nextTick()
|
|
|
|
|
this.$refs.header.handleFormSubmit()
|
2018-08-07 11:00:20 +08:00
|
|
|
},
|
2018-08-06 10:45:45 +08:00
|
|
|
handleSubmit (form) {
|
2018-08-07 13:46:04 +08:00
|
|
|
this.loading = true
|
2018-08-07 11:00:20 +08:00
|
|
|
this.$notify({
|
2018-08-07 13:46:04 +08:00
|
|
|
title: '开始请求模拟表格数据'
|
2018-08-07 09:28:21 +08:00
|
|
|
})
|
2018-08-24 17:05:32 +08:00
|
|
|
BusinessTable1List({
|
2018-08-07 11:38:25 +08:00
|
|
|
...form,
|
2018-12-13 10:29:56 +08:00
|
|
|
...this.page
|
2018-08-07 11:38:25 +08:00
|
|
|
})
|
2018-08-06 10:45:45 +08:00
|
|
|
.then(res => {
|
2018-08-07 13:46:04 +08:00
|
|
|
this.loading = false
|
2018-08-07 11:00:20 +08:00
|
|
|
this.$notify({
|
2018-08-07 13:46:04 +08:00
|
|
|
title: '模拟表格数据请求完毕'
|
2018-08-07 09:28:21 +08:00
|
|
|
})
|
2018-08-06 10:45:45 +08:00
|
|
|
this.table = res.list
|
2018-12-13 10:29:56 +08:00
|
|
|
this.page.pageTotal = res.page.total
|
2018-08-06 10:45:45 +08:00
|
|
|
})
|
|
|
|
|
.catch(err => {
|
2018-08-07 13:46:04 +08:00
|
|
|
this.loading = false
|
2018-08-07 11:00:20 +08:00
|
|
|
this.$notify({
|
2018-08-07 13:46:04 +08:00
|
|
|
title: '模拟表格数据请求异常'
|
2018-08-07 09:28:21 +08:00
|
|
|
})
|
2018-08-06 10:45:45 +08:00
|
|
|
console.log('err', err)
|
|
|
|
|
})
|
|
|
|
|
}
|
2018-08-05 22:21:17 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|