临时存档

Former-commit-id: 478135c9cddd262cc43ea3c78e3b010140a70965 [formerly 478135c9cddd262cc43ea3c78e3b010140a70965 [formerly 478135c9cddd262cc43ea3c78e3b010140a70965 [formerly 478135c9cddd262cc43ea3c78e3b010140a70965 [formerly 8655f13a475ab0b87d8da714fbd5887fe25b7c19 [formerly c0fd05438c5c159c2e3a9cedcf31814a6ba5e02b]]]]]
Former-commit-id: 7fb997158f60224f32cb323f1f3a853a5fec97cc
Former-commit-id: 80be589dcd2d3fb67ee217844c7590671fdbbd6e
Former-commit-id: 6930aaa344febf1efc9dd96488f5a8e1fdc3c00d [formerly 8109f02fa9ab2bf41a162778fdc48d638b852a6a]
Former-commit-id: e95e8233a308a067c10222e2a277106be773ca63
Former-commit-id: 7ba6a415d53a8f83684608d89a47e35dec98f930
Former-commit-id: 3540b9a82e5ef79b8dfb18753a8a7d2a013aed94
Former-commit-id: 695315892575ac385338befe856980ba21401803
Former-commit-id: 6e91b18c7175df95f5398d7798146f8f74d2b437
This commit is contained in:
liyang
2018-08-07 11:38:25 +08:00
parent 7476838461
commit cad41fd8af
4 changed files with 50 additions and 29 deletions

View File

@@ -3,8 +3,11 @@ import Mock from 'mockjs'
Mock.mock('/api/demo/business/table/1', ({ body }) => { Mock.mock('/api/demo/business/table/1', ({ body }) => {
// 这是通过 post 传来的参数 // 这是通过 post 传来的参数
body = JSON.parse(body) body = JSON.parse(body)
const { page } = body
page.total = 1000
return Mock.mock( return Mock.mock(
{ {
page,
'list|30': [{ 'list|30': [{
'key': '@guid', 'key': '@guid',
'value|1': [10, 100, 200, 500], 'value|1': [10, 100, 200, 500],

View File

@@ -1,8 +1,8 @@
<template> <template>
<el-pagination <el-pagination
:current-page="page.current" :current-page="current"
:page-size="page.size" :page-size="size"
:total="page.total" :total="total"
:page-sizes="[100, 200, 300, 400]" :page-sizes="[100, 200, 300, 400]"
layout="total, sizes, prev, pager, next, jumper" layout="total, sizes, prev, pager, next, jumper"
style="margin: -10px;" style="margin: -10px;"
@@ -15,30 +15,29 @@
export default { export default {
props: { props: {
current: { current: {
default: 1 default: 0
}, },
size: { size: {
default: 100 default: 0
}, },
total: { total: {
default: 400 default: 0
}
},
data () {
return {
page: {
current: 1,
size: 100,
total: 400
}
} }
}, },
methods: { methods: {
handleSizeChange(val) { handleSizeChange (val) {
this.$emit('change', this.page) this.$emit('change', {
current: this.current,
size: val,
total: this.total
})
}, },
handleCurrentChange(val) { handleCurrentChange (val) {
this.$emit('change', this.page) this.$emit('change', {
current: val,
size: this.size,
total: this.total
})
} }
} }
} }

View File

@@ -44,7 +44,7 @@
<el-form-item> <el-form-item>
<el-button <el-button
type="primary" type="primary"
@click="submitForm('form')"> @click="submitForm">
<d2-icon name="search"/> <d2-icon name="search"/>
查询 查询
</el-button> </el-button>
@@ -52,7 +52,7 @@
<el-form-item> <el-form-item>
<el-button <el-button
@click="resetForm('form')"> @click="resetForm">
<d2-icon name="refresh"/> <d2-icon name="refresh"/>
重置 重置
</el-button> </el-button>
@@ -78,17 +78,21 @@ export default {
} }
}, },
methods: { methods: {
submitForm (formName) { submitForm () {
this.$refs[formName].validate((valid) => { this.$refs.form.validate((valid) => {
if (valid) { if (valid) {
this.$emit('submit', this.form) this.$emit('submit', this.form)
} else { } else {
this.$notify.error({
title: '错误',
message: '表单校验失败'
})
return false return false
} }
}) })
}, },
resetForm (formName) { resetForm () {
this.$refs[formName].resetFields() this.$refs.form.resetFields()
} }
} }
} }

View File

@@ -2,11 +2,15 @@
<d2-container> <d2-container>
<demo-page-header <demo-page-header
slot="header" slot="header"
@submit="handleSubmit"/> @submit="handleSubmit"
ref="header"/>
<demo-page-main <demo-page-main
:table-data="table"/> :table-data="table"/>
<demo-page-footer <demo-page-footer
slot="footer" slot="footer"
:current="page.current"
:size="page.size"
:total="page.total"
@change="handlePaginationChange"/> @change="handlePaginationChange"/>
</d2-container> </d2-container>
</template> </template>
@@ -22,7 +26,12 @@ export default {
}, },
data () { data () {
return { return {
table: [] table: [],
page: {
current: 1,
size: 100,
total: 0
}
} }
}, },
methods: { methods: {
@@ -31,20 +40,26 @@ export default {
title: '分页变化', title: '分页变化',
message: `当前第${val.current}页 共${val.total}条 每页${val.size}` message: `当前第${val.current}页 共${val.total}条 每页${val.size}`
}) })
this.page = val
this.$nextTick(() => { this.$nextTick(() => {
this.handleSubmit({}) this.$refs.header.submitForm()
}) })
}, },
handleSubmit (form) { handleSubmit (form) {
this.$notify({ this.$notify({
title: '开始请求表格数据' title: '开始请求表格数据'
}) })
this.$axios.post('/api/demo/business/table/1', form) this.$axios.post('/api/demo/business/table/1', {
...form,
page: this.page
})
.then(res => { .then(res => {
console.log('res', res)
this.$notify({ this.$notify({
title: '表格数据请求完毕' title: '表格数据请求完毕'
}) })
this.table = res.list this.table = res.list
this.page = res.page
}) })
.catch(err => { .catch(err => {
this.$notify({ this.$notify({