From 825e1665d1e56037ac997f97cf0dd735c2dd0743 Mon Sep 17 00:00:00 2001 From: ruibaby Date: Tue, 27 Aug 2019 10:49:56 +0800 Subject: [PATCH] Fixed vue data warning. --- src/views/post/PostEdit.vue | 12 +++- src/views/post/PostList.vue | 12 +++- src/views/post/components/PostSetting.vue | 68 +++++++++++++++-------- 3 files changed, 65 insertions(+), 27 deletions(-) diff --git a/src/views/post/PostEdit.vue b/src/views/post/PostEdit.vue index 0a718181..e6c99182 100644 --- a/src/views/post/PostEdit.vue +++ b/src/views/post/PostEdit.vue @@ -27,11 +27,13 @@ @@ -173,6 +175,12 @@ export default { }, onRefreshPostFromSetting(post) { this.postToStage = post + }, + onRefreshTagIdsFromSetting(tagIds) { + this.selectedTagIds = tagIds + }, + onRefreshCategoryIdsFromSetting(categoryIds) { + this.selectedCategoryIds = categoryIds } } } diff --git a/src/views/post/PostList.vue b/src/views/post/PostList.vue index b9ce8d33..7f61c958 100644 --- a/src/views/post/PostList.vue +++ b/src/views/post/PostList.vue @@ -259,8 +259,8 @@ @@ -502,6 +504,12 @@ export default { }, onRefreshPostFromSetting(post) { this.selectedPost = post + }, + onRefreshTagIdsFromSetting(tagIds) { + this.selectedTagIds = tagIds + }, + onRefreshCategoryIdsFromSetting(categoryIds) { + this.selectedCategoryIds = categoryIds } } } diff --git a/src/views/post/components/PostSetting.vue b/src/views/post/components/PostSetting.vue index 3320e39a..5dcd676a 100644 --- a/src/views/post/components/PostSetting.vue +++ b/src/views/post/components/PostSetting.vue @@ -17,13 +17,13 @@ label="文章标题:" v-if="needTitle" > - + - + @@ -38,7 +38,7 @@ 开启 @@ -121,7 +121,7 @@ @@ -136,7 +136,7 @@
{ @@ -286,11 +309,11 @@ export default { this.categoryFormVisible = !this.categoryFormVisible }, handleDraftClick() { - this.post.status = 'DRAFT' + this.selectedPost.status = 'DRAFT' this.savePost() }, handlePublishClick() { - this.post.status = 'PUBLISHED' + this.selectedPost.status = 'PUBLISHED' this.savePost() }, savePost() { @@ -302,13 +325,13 @@ export default { }, createOrUpdatePost(createSuccess, updateSuccess, autoSave) { // Set category ids - this.post.categoryIds = this.selectedCategoryIds + this.selectedPost.categoryIds = this.selectedCategoryIds // Set tag ids - this.post.tagIds = this.selectedTagIds + this.selectedPost.tagIds = this.selectedTagIds - if (this.post.id) { + if (this.selectedPost.id) { // Update the post - postApi.update(this.post.id, this.post, autoSave).then(response => { + postApi.update(this.selectedPost.id, this.selectedPost, autoSave).then(response => { this.$log.debug('Updated post', response.data.data) if (updateSuccess) { updateSuccess() @@ -316,24 +339,23 @@ export default { }) } else { // Create the post - postApi.create(this.post, autoSave).then(response => { + postApi.create(this.selectedPost, autoSave).then(response => { this.$log.debug('Created post', response.data.data) if (createSuccess) { createSuccess() } - this.post = response.data.data + this.selectedPost = response.data.data }) } - this.$emit('onRefreshPost', this.post) }, onClose() { this.$emit('close', false) }, onPostDateChange(value, dateString) { - this.post.createTime = value.valueOf() + this.selectedPost.createTime = value.valueOf() }, onPostDateOk(value) { - this.post.createTime = value.valueOf() + this.selectedPost.createTime = value.valueOf() } } }