mirror of https://github.com/halo-dev/halo
Merge branch 'master' of https://gitlab.com/halo_dev/halo-admin
commit
5c2c9e05b4
|
@ -11,6 +11,13 @@ categoryApi.listAll = () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
categoryApi.listTree = () => {
|
||||||
|
return service({
|
||||||
|
url: `${baseUrl}/tree_view`,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
categoryApi.create = (category) => {
|
categoryApi.create = (category) => {
|
||||||
return service({
|
return service({
|
||||||
url: baseUrl,
|
url: baseUrl,
|
||||||
|
|
|
@ -17,9 +17,15 @@
|
||||||
<a-input v-model="categoryToCreate.slugNames" />
|
<a-input v-model="categoryToCreate.slugNames" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="上级目录:">
|
<a-form-item label="上级目录:">
|
||||||
<a-select>
|
<a-tree-select
|
||||||
<a-select-option value="1">上级目录</a-select-option>
|
:treeData="categoriesTree"
|
||||||
</a-select>
|
placeholder="请选择上级目录,默认为顶级目录"
|
||||||
|
treeDefaultExpandAll
|
||||||
|
v-model="categoryToCreate.parentId"
|
||||||
|
:treeDataSimpleMode="true"
|
||||||
|
:allowClear="true"
|
||||||
|
>
|
||||||
|
</a-tree-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="描述:" help="*分类描述,部分主题可显示">
|
<a-form-item label="描述:" help="*分类描述,部分主题可显示">
|
||||||
<a-input type="textarea" v-model="categoryToCreate.description" :autosize="{ minRows: 3 }" />
|
<a-input type="textarea" v-model="categoryToCreate.description" :autosize="{ minRows: 3 }" />
|
||||||
|
@ -99,6 +105,18 @@ export default {
|
||||||
created() {
|
created() {
|
||||||
this.loadCategories()
|
this.loadCategories()
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
categoriesTree() {
|
||||||
|
return this.categories.map(category => {
|
||||||
|
return {
|
||||||
|
id: category.id,
|
||||||
|
title: category.name,
|
||||||
|
value: category.id.toString(),
|
||||||
|
pId: category.parentId
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadCategories() {
|
loadCategories() {
|
||||||
categoryApi.listAll().then(response => {
|
categoryApi.listAll().then(response => {
|
||||||
|
@ -107,7 +125,9 @@ export default {
|
||||||
},
|
},
|
||||||
createCategory() {
|
createCategory() {
|
||||||
categoryApi.create(this.categoryToCreate).then(response => {
|
categoryApi.create(this.categoryToCreate).then(response => {
|
||||||
|
this.$message.success('添加成功!')
|
||||||
this.loadCategories()
|
this.loadCategories()
|
||||||
|
this.categoryToCreate = {}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
editCategory(id) {
|
editCategory(id) {
|
||||||
|
|
Loading…
Reference in New Issue