diff --git a/src/api/category.js b/src/api/category.js
index 398715a80..61c26f847 100644
--- a/src/api/category.js
+++ b/src/api/category.js
@@ -11,6 +11,13 @@ categoryApi.listAll = () => {
})
}
+categoryApi.listTree = () => {
+ return service({
+ url: `${baseUrl}/tree_view`,
+ method: 'get'
+ })
+}
+
categoryApi.create = (category) => {
return service({
url: baseUrl,
diff --git a/src/views/post/CategoryList.vue b/src/views/post/CategoryList.vue
index 5797c9ef2..bca99c0de 100644
--- a/src/views/post/CategoryList.vue
+++ b/src/views/post/CategoryList.vue
@@ -17,9 +17,15 @@
-
- 上级目录
-
+
+
@@ -99,6 +105,18 @@ export default {
created() {
this.loadCategories()
},
+ computed: {
+ categoriesTree() {
+ return this.categories.map(category => {
+ return {
+ id: category.id,
+ title: category.name,
+ value: category.id.toString(),
+ pId: category.parentId
+ }
+ })
+ }
+ },
methods: {
loadCategories() {
categoryApi.listAll().then(response => {
@@ -107,7 +125,9 @@ export default {
},
createCategory() {
categoryApi.create(this.categoryToCreate).then(response => {
+ this.$message.success('添加成功!')
this.loadCategories()
+ this.categoryToCreate = {}
})
},
editCategory(id) {