Browse Source

Support control more post.

pull/9/head
ruibaby 6 years ago
parent
commit
373d83b4c1
  1. 12
      src/views/comment/components/CommentTab.vue
  2. 88
      src/views/post/PostList.vue

12
src/views/comment/components/CommentTab.vue

@ -436,38 +436,44 @@ export default {
handlePublishMore() {
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()
})
}
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()
})
}
this.loadComments()
},
handleDeleteMore() {
if (this.selectedRowKeys.length <= 0) {
this.$message.success('请至少选择一项!')
return
}
for (let index = 0; index < this.selectedRowKeys.length; index++) {
const element = this.selectedRowKeys[index]
commentApi.delete(this.type, element).then(response => {
this.$log.debug(`delete: ${element}`)
this.selectedRowKeys = []
this.loadComments()
})
}
this.loadComments()
},
onReplyClose() {
this.replyComment = {}

88
src/views/post/PostList.vue

@ -82,7 +82,7 @@
>
<a
href="javascript:void(0);"
@click="handleDeleteMore"
@click="handlePublishMore"
>
<span>发布</span>
</a>
@ -229,28 +229,7 @@
<script>
import categoryApi from '@/api/category'
import postApi from '@/api/post'
export default {
name: 'PostList',
components: {},
data() {
return {
postStatus: postApi.postStatus,
pagination: {
current: 1,
pageSize: 10,
sort: null
},
queryParam: {
page: 0,
size: 10,
sort: null,
keyword: null,
categoryId: null,
status: null
},
//
columns: [
const columns = [
{
title: '标题',
dataIndex: 'title',
@ -290,7 +269,28 @@ export default {
width: '150px',
scopedSlots: { customRender: 'action' }
}
],
]
export default {
name: 'PostList',
components: {},
data() {
return {
postStatus: postApi.postStatus,
pagination: {
current: 1,
pageSize: 10,
sort: null
},
queryParam: {
page: 0,
size: 10,
sort: null,
keyword: null,
categoryId: null,
status: null
},
//
columns,
selectedRowKeys: [],
selectedRows: [],
categories: [],
@ -365,22 +365,54 @@ export default {
this.loadPosts()
})
},
handleDeleteClick(postId) {
postApi.delete(postId).then(response => {
this.$message.success('删除成功!')
this.loadPosts()
})
},
handlePublishMore() {
if (this.selectedRowKeys.length <= 0) {
this.$message.success('请至少选择一项!')
return
}
for (let index = 0; index < this.selectedRowKeys.length; index++) {
const element = this.selectedRowKeys[index]
postApi.updateStatus(element, 'PUBLISHED').then(response => {
this.$log.debug(`postId: ${element}, status: PUBLISHED`)
this.selectedRowKeys = []
this.loadPosts()
})
}
},
handleRecycleMore() {
if (this.selectedRowKeys.length <= 0) {
this.$message.success('请至少选择一项!')
return
}
for (let index = 0; index < this.selectedRowKeys.length; index++) {
const element = this.selectedRowKeys[index]
postApi.updateStatus(element, 'RECYCLE').then(response => {
this.$log.debug(`postId: ${element}, status: RECYCLE`)
this.selectedRowKeys = []
this.loadPosts()
})
}
},
handleDeleteMore() {
if (this.selectedRowKeys.length <= 0) {
this.$message.success('请至少选择一项!')
return
}
},
handleDeleteClick(postId) {
postApi.delete(postId).then(response => {
this.$message.success('删除成功!')
for (let index = 0; index < this.selectedRowKeys.length; index++) {
const element = this.selectedRowKeys[index]
postApi.delete(element).then(response => {
this.$log.debug(`delete: ${element}`)
this.selectedRowKeys = []
this.loadPosts()
})
}
}
}
}
</script>

Loading…
Cancel
Save