From 04ec088db6099ced334113ad88f26c33c0fdcf13 Mon Sep 17 00:00:00 2001 From: ruibaby Date: Sat, 13 Apr 2019 19:28:42 +0800 Subject: [PATCH] Attachment detail drawer. --- src/api/attachment.js | 7 ++++++ src/views/attachment/AttachmentList.vue | 31 ++++++++++++++++++++++--- src/views/post/PostEdit.vue | 12 ++++++---- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/src/api/attachment.js b/src/api/attachment.js index 43a3b7e8..2760641c 100644 --- a/src/api/attachment.js +++ b/src/api/attachment.js @@ -12,4 +12,11 @@ attachmentApi.list = pagination => { }) } +attachmentApi.get = attachmentId => { + return service({ + url: `${baseUrl}/${attachmentId}`, + method: 'get' + }) +} + export default attachmentApi diff --git a/src/views/attachment/AttachmentList.vue b/src/views/attachment/AttachmentList.vue index ae097b96..b0cce3ec 100644 --- a/src/views/attachment/AttachmentList.vue +++ b/src/views/attachment/AttachmentList.vue @@ -11,7 +11,7 @@ :sm="12" :xs="24" > - +
@@ -46,12 +46,24 @@ 图片详情 + @close="onChildClose" + > + + + +
+ +
+
+
+
+ @@ -68,6 +80,7 @@ export default { return { uploadVisible: false, drawerVisible: false, + detailImgLoading: false, selectAttachment: null, drawerWidth: '560', attachments: [], @@ -97,8 +110,13 @@ export default { this.pagination.total = response.data.data.total }) }, - showDetailDrawer() { + showDetailDrawer(attachment) { this.drawerVisible = true + this.detailImgLoading = true + this.selectAttachment = attachment + setTimeout(() => { + this.detailImgLoading = false + }, 500) }, showUploadModal() { this.uploadVisible = true @@ -113,6 +131,9 @@ export default { } else if (status === 'error') { this.$message.error(`${info.file.name} file upload failed.`) } + }, + onChildClose() { + this.drawerVisible = false } } } @@ -147,4 +168,8 @@ export default { .ant-card-meta { padding: 0.8rem; } + +.attach-detail-img img { + width: 100%; +} diff --git a/src/views/post/PostEdit.vue b/src/views/post/PostEdit.vue index 079dc068..33c1474d 100644 --- a/src/views/post/PostEdit.vue +++ b/src/views/post/PostEdit.vue @@ -103,8 +103,9 @@
@@ -161,7 +162,7 @@ export default { xs: { span: 24 } }, visible: false, - childrenDrawer: false, + childDrawerVisible: false, drawerWidth: '460', tags: [], categories: [], @@ -241,7 +242,7 @@ export default { this.visible = true }, showAttachDrawer() { - this.childrenDrawer = true + this.childDrawerVisible = true }, handlePublishClick() { this.postToStage.status = 'PUBLISHED' @@ -253,6 +254,9 @@ export default { }, onClose() { this.visible = false + }, + onChildClose() { + this.childDrawerVisible = false } } }