Skip to content

Commit

Permalink
feat:Article 页面增加「保存文章」按钮
Browse files Browse the repository at this point in the history
Article 页面增加「保存文章」按钮:
- Fame-admin 前端增加「保存文章」按钮】,对应方法saveArticle(原保存方法改名为 publishArticle),保存后获取文章 id,不跳转页面并更新 article 变量。
- Fame-server  文章保存后返回文章 id,而不是「保存文章成功」文字。
  • Loading branch information
bihell committed May 25, 2019
1 parent 5edd167 commit 9474701
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
40 changes: 36 additions & 4 deletions fame-admin/src/components/page/Article.vue
Expand Up @@ -65,9 +65,15 @@
</el-form-item>
<el-form-item>
<el-button-group>
<el-button type="primary" size="small" @click="onPublish"
>发布文章
</el-button>
<el-row>
<el-button type="primary" size="small" @click="onSave"
>保存文章
</el-button>

<el-button type="primary" size="small" @click="onPublish"
>发布文章
</el-button>
</el-row>
</el-button-group>
</el-form-item>
</div>
Expand Down Expand Up @@ -169,7 +175,7 @@ export default {
}
});
},
saveArticle(formName) {
publishArticle(formName) {
this.$refs[formName].validate(valid => {
if (valid) {
let params = this.article;
Expand All @@ -191,7 +197,33 @@ export default {
}
});
},
saveArticle(formName) {
this.$refs[formName].validate(valid => {
if (valid) {
let params = this.article;
params.tags = this.$util.tagsToString(this.article.tags);
this.$api.auth.saveArticle(params).then(data => {
if (data.success) {
this.$message({
message: "保存文章成功!",
type: "success"
});
this.$route.params.id = data.data;
this.getArticle();
} else {
this.$message({
message: "保存文章失败," + data.msg,
type: "error"
});
}
});
}
});
},
onPublish() {
this.publishArticle("articleForm");
},
onSave() {
this.saveArticle("articleForm");
},
init() {
Expand Down
Expand Up @@ -94,8 +94,8 @@ public RestResponse saveArticle(@RequestParam(value = "id", required = false) In
article.setStatus(status);
article.setAllowComment(allowComment);
article.setAuthorId(user.getId());
articleService.saveArticle(article);
return RestResponse.ok("保存文章成功");
Integer articleId = articleService.saveArticle(article);
return RestResponse.ok(articleId);
}

/**
Expand Down

0 comments on commit 9474701

Please sign in to comment.