2018-08-05 22:21:17 +08:00
|
|
|
<template>
|
|
|
|
|
<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
|
|
|
|
|
:table-data="table"/>
|
|
|
|
|
<demo-page-footer
|
|
|
|
|
slot="footer"
|
2018-08-07 11:38:25 +08:00
|
|
|
:current="page.current"
|
|
|
|
|
:size="page.size"
|
|
|
|
|
:total="page.total"
|
2018-08-07 11:00:20 +08:00
|
|
|
@change="handlePaginationChange"/>
|
2018-08-05 22:21:17 +08:00
|
|
|
</d2-container>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
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: [],
|
|
|
|
|
page: {
|
|
|
|
|
current: 1,
|
|
|
|
|
size: 100,
|
|
|
|
|
total: 0
|
|
|
|
|
}
|
2018-08-06 10:45:45 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
2018-08-07 11:00:20 +08:00
|
|
|
handlePaginationChange (val) {
|
|
|
|
|
this.$notify({
|
|
|
|
|
title: '分页变化',
|
|
|
|
|
message: `当前第${val.current}页 共${val.total}条 每页${val.size}条`
|
|
|
|
|
})
|
2018-08-07 11:38:25 +08:00
|
|
|
this.page = val
|
2018-08-07 11:00:20 +08:00
|
|
|
this.$nextTick(() => {
|
2018-08-07 11:38:25 +08:00
|
|
|
this.$refs.header.submitForm()
|
2018-08-07 11:00:20 +08:00
|
|
|
})
|
|
|
|
|
},
|
2018-08-06 10:45:45 +08:00
|
|
|
handleSubmit (form) {
|
2018-08-07 11:00:20 +08:00
|
|
|
this.$notify({
|
|
|
|
|
title: '开始请求表格数据'
|
2018-08-07 09:28:21 +08:00
|
|
|
})
|
2018-08-07 11:38:25 +08:00
|
|
|
this.$axios.post('/api/demo/business/table/1', {
|
|
|
|
|
...form,
|
|
|
|
|
page: this.page
|
|
|
|
|
})
|
2018-08-06 10:45:45 +08:00
|
|
|
.then(res => {
|
2018-08-07 11:38:25 +08:00
|
|
|
console.log('res', res)
|
2018-08-07 11:00:20 +08:00
|
|
|
this.$notify({
|
|
|
|
|
title: '表格数据请求完毕'
|
2018-08-07 09:28:21 +08:00
|
|
|
})
|
2018-08-06 10:45:45 +08:00
|
|
|
this.table = res.list
|
2018-08-07 11:38:25 +08:00
|
|
|
this.page = res.page
|
2018-08-06 10:45:45 +08:00
|
|
|
})
|
|
|
|
|
.catch(err => {
|
2018-08-07 11:00:20 +08:00
|
|
|
this.$notify({
|
|
|
|
|
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>
|