Refactor query methods

pull/9/head
johnniang 2019-04-30 11:23:22 +08:00
parent a835758b7f
commit 2158c12bff
2 changed files with 12 additions and 10 deletions

View File

@ -56,7 +56,7 @@
<span class="table-page-search-submitButtons">
<a-button
type="primary"
@click="loadAttachments(true)"
@click="handleQuery"
>查询</a-button>
<a-button
style="margin-left: 8px;"
@ -196,13 +196,10 @@ export default {
this.loadMediaTypes()
},
methods: {
loadAttachments(isSearch) {
loadAttachments() {
this.queryParam.page = this.pagination.page - 1
this.queryParam.size = this.pagination.size
this.queryParam.sort = this.pagination.sort
if (isSearch) {
this.queryParam.page = 0
}
this.listLoading = true
attachmentApi.query(this.queryParam).then(response => {
this.attachments = response.data.data.content
@ -238,6 +235,10 @@ export default {
this.queryParam.attachmentType = null
this.loadAttachments()
},
handleQuery() {
this.queryParam.page = 0
this.loadAttachments()
},
handleDelete(attachment) {
this.loadAttachments()
}

View File

@ -53,7 +53,7 @@
<span class="table-page-search-submitButtons">
<a-button
type="primary"
@click="loadPosts(true)"
@click="handleQuery"
>查询</a-button>
<a-button
style="margin-left: 8px;"
@ -275,15 +275,12 @@ export default {
this.loadPosts()
},
methods: {
loadPosts(isSearch) {
loadPosts() {
this.postsLoading = true
// Set from pagination
this.queryParam.page = this.pagination.current - 1
this.queryParam.size = this.pagination.pageSize
this.queryParam.sort = this.pagination.sort
if (isSearch) {
this.queryParam.page = 0
}
postApi.query(this.queryParam).then(response => {
this.posts = response.data.data.content
this.pagination.total = response.data.data.total
@ -321,6 +318,10 @@ export default {
this.queryParam.status = null
this.loadPosts()
},
handleQuery() {
this.queryParam.page = 0
this.loadPosts()
},
handleEditStatusClick(postId, status) {
postApi.updateStatus(postId, status).then(response => {
this.$message.success('操作成功!')