Browse Source

Support control more post.

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

2
src/api/theme.js

@ -134,4 +134,4 @@ themeApi.exists = template => {
})
}
export default themeApi
export default themeApi

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 = {}

130
src/views/post/PostList.vue

@ -82,7 +82,7 @@
>
<a
href="javascript:void(0);"
@click="handleDeleteMore"
@click="handlePublishMore"
>
<span>发布</span>
</a>
@ -229,7 +229,47 @@
<script>
import categoryApi from '@/api/category'
import postApi from '@/api/post'
const columns = [
{
title: '标题',
dataIndex: 'title',
scopedSlots: { customRender: 'postTitle' }
},
{
title: '状态',
className: 'status',
dataIndex: 'statusProperty',
scopedSlots: { customRender: 'status' }
},
{
title: '分类目录',
dataIndex: 'categories',
scopedSlots: { customRender: 'categories' }
},
{
title: '标签',
dataIndex: 'tags',
scopedSlots: { customRender: 'tags' }
},
{
title: '评论量',
dataIndex: 'commentCount'
},
{
title: '访问量',
dataIndex: 'visits'
},
{
title: '更新时间',
dataIndex: 'updateTime',
scopedSlots: { customRender: 'updateTime' }
},
{
title: '操作',
width: '150px',
scopedSlots: { customRender: 'action' }
}
]
export default {
name: 'PostList',
components: {},
@ -250,47 +290,7 @@ export default {
status: null
},
//
columns: [
{
title: '标题',
dataIndex: 'title',
scopedSlots: { customRender: 'postTitle' }
},
{
title: '状态',
className: 'status',
dataIndex: 'statusProperty',
scopedSlots: { customRender: 'status' }
},
{
title: '分类目录',
dataIndex: 'categories',
scopedSlots: { customRender: 'categories' }
},
{
title: '标签',
dataIndex: 'tags',
scopedSlots: { customRender: 'tags' }
},
{
title: '评论量',
dataIndex: 'commentCount'
},
{
title: '访问量',
dataIndex: 'visits'
},
{
title: '更新时间',
dataIndex: 'updateTime',
scopedSlots: { customRender: 'updateTime' }
},
{
title: '操作',
width: '150px',
scopedSlots: { customRender: 'action' }
}
],
columns,
selectedRowKeys: [],
selectedRows: [],
categories: [],
@ -365,21 +365,53 @@ 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
}
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()
})
}
},
handleDeleteClick(postId) {
postApi.delete(postId).then(response => {
this.$message.success('删除成功!')
this.loadPosts()
})
}
}
}

Loading…
Cancel
Save