Support journal delete.

pull/9/head
ruibaby 2019-04-26 23:09:04 +08:00
parent b7518ac23d
commit 6808e2ad3a
2 changed files with 21 additions and 1 deletions

View File

@ -28,4 +28,11 @@ journalApi.update = (journalId, journal) => {
}) })
} }
journalApi.delete = journalId => {
return service({
url: `${baseUrl}/${journalId}`,
method: 'delete'
})
}
export default journalApi export default journalApi

View File

@ -87,7 +87,14 @@
@click="handleEdit(item)" @click="handleEdit(item)"
>编辑</a> >编辑</a>
<a-divider type="vertical" /> <a-divider type="vertical" />
<a href="javascript:void(0);">删除</a> <a-popconfirm
title="你确定要删除这条日志?"
@confirm="handleDelete(item.id)"
okText="确定"
cancelText="取消"
>
<a href="javascript:void(0);">删除</a>
</a-popconfirm>
</template> </template>
<a-list-item-meta :description="item.content"> <a-list-item-meta :description="item.content">
<span slot="title">{{ item.createTime | moment }}</span> <span slot="title">{{ item.createTime | moment }}</span>
@ -193,6 +200,12 @@ export default {
this.journal = item this.journal = item
this.visible = true this.visible = true
}, },
handleDelete(id) {
journalApi.delete(id).then(response => {
this.$message.success('删除成功!')
this.loadJournals()
})
},
createOrUpdateJournal() { createOrUpdateJournal() {
if (this.journal.id) { if (this.journal.id) {
journalApi.update(this.journal.id, this.journal).then(response => { journalApi.update(this.journal.id, this.journal).then(response => {