feat: support update post status in batch.

pull/59/head
ruibaby 2019-12-12 13:53:06 +08:00
parent 4296e998f0
commit 115379bcb9
2 changed files with 16 additions and 8 deletions

View File

@ -58,6 +58,17 @@ postApi.updateStatus = (postId, status) => {
}) })
} }
postApi.updateStatusInBatch = (ids, status) => {
return service({
url: `${baseUrl}/status`,
data: {
ids: ids,
status: status
},
method: 'put'
})
}
postApi.delete = postId => { postApi.delete = postId => {
return service({ return service({
url: `${baseUrl}/${postId}`, url: `${baseUrl}/${postId}`,

View File

@ -727,14 +727,11 @@ export default {
this.$message.success('请至少选择一项!') this.$message.success('请至少选择一项!')
return return
} }
for (let index = 0; index < this.selectedRowKeys.length; index++) { postApi.updateStatusInBatch(this.selectedRowKeys, status).then(response => {
const element = this.selectedRowKeys[index] this.$log.debug(`postId: ${this.selectedRowKeys}, status: ${status}`)
postApi.updateStatus(element, status).then(response => { this.selectedRowKeys = []
this.$log.debug(`postId: ${element}, status: ${status}`) this.loadPosts()
this.selectedRowKeys = [] })
this.loadPosts()
})
}
}, },
handleDeleteMore() { handleDeleteMore() {
if (this.selectedRowKeys.length <= 0) { if (this.selectedRowKeys.length <= 0) {