From 27862d46c58dc1356f5c70381f494b6de020eadb Mon Sep 17 00:00:00 2001 From: ruibaby Date: Thu, 12 Dec 2019 14:33:44 +0800 Subject: [PATCH] feat: support update comment status in batch. --- src/api/comment.js | 14 +++++++++ src/views/comment/components/CommentTab.vue | 33 +++++---------------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/api/comment.js b/src/api/comment.js index 7a577107..98f93a81 100644 --- a/src/api/comment.js +++ b/src/api/comment.js @@ -38,6 +38,17 @@ commentApi.updateStatus = (target, commentId, status) => { }) } +commentApi.updateStatusInBatch = (target, ids, status) => { + return service({ + url: `${baseUrl}/${target}/comments/status`, + data: { + ids: ids, + status: status + }, + method: 'put' + }) +} + commentApi.delete = (target, commentId) => { return service({ url: `${baseUrl}/${target}/comments/${commentId}`, @@ -110,16 +121,19 @@ commentApi.createComment = (comment, type) => { commentApi.commentStatus = { PUBLISHED: { + value: 'PUBLISHED', color: 'green', status: 'success', text: '已发布' }, AUDITING: { + value: 'AUDITING', color: 'yellow', status: 'warning', text: '待审核' }, RECYCLE: { + value: 'RECYCLE', color: 'red', status: 'error', text: '回收站' diff --git a/src/views/comment/components/CommentTab.vue b/src/views/comment/components/CommentTab.vue index 22d4ef3e..032d78dd 100644 --- a/src/views/comment/components/CommentTab.vue +++ b/src/views/comment/components/CommentTab.vue @@ -65,7 +65,7 @@ > 通过 @@ -76,7 +76,7 @@ > 移到回收站 @@ -632,33 +632,16 @@ export default { this.handleClearRowKeys() this.handlePaginationChange(1, this.pagination.size) }, - handlePublishMore() { + handleEditStatusMore(status) { if (this.selectedRowKeys.length <= 0) { this.$message.success('请至少选择一项!') return } - for (let index = 0; index < this.selectedRowKeys.length; index++) { - const element = this.selectedRowKeys[index] - commentApi.updateStatus(this.type, element, 'PUBLISHED').then(response => { - this.$log.debug(`commentId: ${element}, status: PUBLISHED`) - this.selectedRowKeys = [] - this.loadComments() - }) - } - }, - handleRecycleMore() { - if (this.selectedRowKeys.length <= 0) { - this.$message.success('请至少选择一项!') - return - } - for (let index = 0; index < this.selectedRowKeys.length; index++) { - const element = this.selectedRowKeys[index] - commentApi.updateStatus(this.type, element, 'RECYCLE').then(response => { - this.$log.debug(`commentId: ${element}, status: RECYCLE`) - this.selectedRowKeys = [] - this.loadComments() - }) - } + commentApi.updateStatusInBatch(this.type, this.selectedRowKeys, status).then(response => { + this.$log.debug(`commentIds: ${this.selectedRowKeys}, status: ${status}`) + this.selectedRowKeys = [] + this.loadComments() + }) }, handleDeleteMore() { if (this.selectedRowKeys.length <= 0) {