feat: support comment post/sheet/journal on the admin.

pull/3445/head
ruibaby 2020-01-04 22:05:07 +08:00
parent 519765a3f9
commit ad0d2c307e
1 changed files with 42 additions and 4 deletions

View File

@ -49,6 +49,13 @@
@change="handlePaginationChange" @change="handlePaginationChange"
></a-pagination> ></a-pagination>
</div> </div>
<a-divider class="divider-transparent" />
<div class="bottom-control">
<a-button
type="primary"
@click="handleComment"
>评论</a-button>
</div>
<a-modal <a-modal
v-if="selectedComment" v-if="selectedComment"
:title="'回复给:' + selectedComment.author" :title="'回复给:' + selectedComment.author"
@ -75,6 +82,31 @@
</a-form-item> </a-form-item>
</a-form> </a-form>
</a-modal> </a-modal>
<a-modal
title="评论"
v-model="commentVisible"
@close="onCommentClose"
destroyOnClose
>
<template slot="footer">
<a-button
key="submit"
type="primary"
@click="handleCreateClick"
>
回复
</a-button>
</template>
<a-form layout="vertical">
<a-form-item>
<a-input
type="textarea"
:autosize="{ minRows: 8 }"
v-model="replyComment.content"
/>
</a-form-item>
</a-form>
</a-modal>
</a-drawer> </a-drawer>
</template> </template>
<script> <script>
@ -91,6 +123,7 @@ export default {
selectedComment: {}, selectedComment: {},
replyComment: {}, replyComment: {},
replyCommentVisible: false, replyCommentVisible: false,
commentVisible: false,
pagination: { pagination: {
page: 1, page: 1,
size: 10, size: 10,
@ -160,8 +193,10 @@ export default {
this.replyCommentVisible = true this.replyCommentVisible = true
this.replyComment.parentId = comment.id this.replyComment.parentId = comment.id
this.replyComment.postId = this.id this.replyComment.postId = this.id
},
console.log('comment reply', this.replyComment) handleComment() {
this.replyComment.postId = this.id
this.commentVisible = true
}, },
handleCreateClick() { handleCreateClick() {
if (!this.replyComment.content) { if (!this.replyComment.content) {
@ -171,13 +206,12 @@ export default {
}) })
return return
} }
console.log('target:', this.target)
console.log('replyComment:', this.replyComment)
commentApi.create(this.target, this.replyComment).then(response => { commentApi.create(this.target, this.replyComment).then(response => {
this.$message.success('回复成功!') this.$message.success('回复成功!')
this.replyComment = {} this.replyComment = {}
this.selectedComment = {} this.selectedComment = {}
this.replyCommentVisible = false this.replyCommentVisible = false
this.commentVisible = false
this.loadComments() this.loadComments()
}) })
}, },
@ -198,6 +232,10 @@ export default {
this.selectedComment = {} this.selectedComment = {}
this.replyCommentVisible = false this.replyCommentVisible = false
}, },
onCommentClose() {
this.replyComment = {}
this.commentVisible = false
},
onClose() { onClose() {
this.comments = [] this.comments = []
this.pagination = { this.pagination = {