Refactor HeaderComment.vue.

pull/9/head
ruibaby 2019-05-03 14:59:49 +08:00
parent 08b7283d49
commit f179a4242f
3 changed files with 42 additions and 5 deletions

View File

@ -11,6 +11,16 @@ commentApi.listLatest = () => {
}) })
} }
commentApi.listLatestByStatus = (top) => {
return service({
url: `${baseUrl}/latest/AUDITING`,
params: {
top: top
},
method: 'get'
})
}
commentApi.query = params => { commentApi.query = params => {
return service({ return service({
url: baseUrl, url: baseUrl,
@ -59,4 +69,4 @@ commentApi.commentStatus = {
} }
} }
export default commentApi export default commentApi

View File

@ -21,7 +21,7 @@
size="large" size="large"
/> />
<template slot="title"> <template slot="title">
<a :href="item.authorUrl" target="_blank">{{ item.author }}</a>{{ item.content }} <a :href="item.authorUrl" target="_blank">{{ item.author }}</a><span v-html="item.content"></span>
</template> </template>
<template slot="description"> <template slot="description">
{{ item.createTime | timeAgo }} {{ item.createTime | timeAgo }}
@ -32,7 +32,10 @@
</a-spin> </a-spin>
</template> </template>
<span @click="fetchComment" class="header-comment"> <span @click="fetchComment" class="header-comment">
<a-badge dot> <a-badge dot v-if="comments.length>0">
<a-icon type="bell" />
</a-badge>
<a-badge v-else>
<a-icon type="bell" /> <a-icon type="bell" />
</a-badge> </a-badge>
</span> </span>
@ -50,6 +53,9 @@ export default {
comments: [] comments: []
} }
}, },
created() {
this.getComment()
},
methods: { methods: {
fetchComment() { fetchComment() {
if (!this.visible) { if (!this.visible) {
@ -61,7 +67,7 @@ export default {
this.visible = !this.visible this.visible = !this.visible
}, },
getComment() { getComment() {
commentApi.listLatest().then(response => { commentApi.listLatestByStatus(5).then(response => {
this.comments = response.data.data this.comments = response.data.data
this.loadding = false this.loadding = false
}) })

View File

@ -53,7 +53,13 @@
<a-dropdown> <a-dropdown>
<a-menu slot="overlay"> <a-menu slot="overlay">
<a-menu-item key="1"> <a-menu-item key="1">
<a-icon type="delete" />回收站 <a-icon type="check" />通过
</a-menu-item>
<a-menu-item key="2">
<a-icon type="delete" />移到回收站
</a-menu-item>
<a-menu-item key="3">
<a-icon type="delete" />永久删除
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
<a-button> <a-button>
@ -65,6 +71,10 @@
<div style="margin-top:15px"> <div style="margin-top:15px">
<a-table <a-table
:rowKey="comment => comment.id" :rowKey="comment => comment.id"
:rowSelection="{
onChange: onSelectionChange,
getCheckboxProps: getCheckboxProps
}"
:columns="columns" :columns="columns"
:dataSource="formattedComments" :dataSource="formattedComments"
:loading="commentsLoading" :loading="commentsLoading"
@ -344,6 +354,17 @@ export default {
this.replyComment = {} this.replyComment = {}
this.selectComment = {} this.selectComment = {}
this.replyCommentVisible = false this.replyCommentVisible = false
},
onSelectionChange(selectedRowKeys) {
this.$log.debug(`SelectedRowKeys: ${selectedRowKeys}`)
},
getCheckboxProps(comment) {
return {
props: {
disabled: comment.status === 'RECYCLE',
name: comment.author
}
}
} }
} }
} }