Support attachment update method.

pull/9/head
ruibaby 2019-04-20 12:27:25 +08:00
parent 76af6ed35e
commit a5ee519382
3 changed files with 25 additions and 47 deletions

View File

@ -27,6 +27,14 @@ attachmentApi.delete = attachmentId => {
})
}
attachmentApi.update = (attachmentId, attachment) => {
return service({
url: `${baseUrl}/${attachmentId}`,
method: 'put',
data: attachment
})
}
attachmentApi.CancelToken = axios.CancelToken
attachmentApi.isCancel = axios.isCancel

View File

@ -41,6 +41,7 @@
</div>
</a-card>
</a-col>
<a-col
class="attachment-item"
v-for="attachment in attachments"

View File

@ -7,16 +7,9 @@
destroyOnClose
@close="onClose"
>
<a-row
type="flex"
align="middle"
>
<a-row type="flex" align="middle">
<a-col :span="24">
<a-skeleton
active
:loading="detailLoading"
:paragraph="{rows: 8}"
>
<a-skeleton active :loading="detailLoading" :paragraph="{rows: 8}">
<div class="attach-detail-img">
<img :src="attachment.path">
</div>
@ -24,33 +17,17 @@
</a-col>
<a-divider/>
<a-col :span="24">
<a-skeleton
active
:loading="detailLoading"
:paragraph="{rows: 8}"
>
<a-skeleton active :loading="detailLoading" :paragraph="{rows: 8}">
<a-list itemLayout="horizontal">
<a-list-item>
<a-list-item-meta>
<template
slot="description"
v-if="editable"
>
<a-input
v-model="attachment.name"
@blur="updateAttachment"
/>
<template slot="description" v-if="editable">
<a-input v-model="attachment.name" @blur="updateAttachment"/>
</template>
<template
slot="description"
v-else
>{{ attachment.name }}</template>
<template slot="description" v-else>{{ attachment.name }}</template>
<span slot="title">
附件名
<a-icon
type="edit"
@click="handleEditName"
/>
<a-icon type="edit" @click="handleEditName"/>
</span>
</a-list-item-meta>
</a-list-item>
@ -78,10 +55,7 @@
<a-list-item-meta :description="attachment.path">
<span slot="title">
普通链接
<a-icon
type="copy"
@click="doCopyNormalLink"
/>
<a-icon type="copy" @click="doCopyNormalLink"/>
</span>
</a-list-item-meta>
</a-list-item>
@ -90,10 +64,7 @@
<span slot="description">![{{ attachment.name }}]({{ attachment.path }})</span>
<span slot="title">
Markdown 格式
<a-icon
type="copy"
@click="doCopyMarkdownLink"
/>
<a-icon type="copy" @click="doCopyMarkdownLink"/>
</span>
</a-list-item-meta>
</a-list-item>
@ -102,12 +73,7 @@
</a-col>
</a-row>
<div class="attachment-control">
<a-popconfirm
title="你确定要删除该附件?"
@confirm="deleteAttachment"
okText="确定"
cancelText="取消"
>
<a-popconfirm title="你确定要删除该附件?" @confirm="deleteAttachment" okText="确定" cancelText="取消">
<a-button type="danger">删除</a-button>
</a-popconfirm>
</div>
@ -172,7 +138,10 @@ export default {
this.editable = !this.editable
},
updateAttachment() {
this.$message.success('修改')
attachmentApi.update(this.attachment.id, this.attachment).then(response => {
this.$log.debug('Updated attachment', response.data.data)
this.$message.success('附件修改成功')
})
this.editable = false
},
doCopyNormalLink() {