修改:修改分类管理

This commit is contained in:
jmal 2020-11-25 18:13:14 +08:00
parent ebac28d4b6
commit 1df2851455
3 changed files with 46 additions and 38 deletions

View File

@ -45,13 +45,13 @@
<span class="instruction">本文连接:<a>{{file.slug ? articleLink+file.slug : articleLink+file.id}}</a></span>
<p class="mark-setting-label">分类:</p>
<el-cascader
v-model="categoryIds"
v-model="file.categoryIds"
class="mark-setting-input"
placeholder="不选择"
:collapse-tags="false"
:options="categories"
:show-all-levels="false"
:props="{ multiple: true, checkStrictly: true }"
:props="{ multiple: true, checkStrictly: false, emitPath: false, value: 'id', label: 'name' }"
clearable></el-cascader>
</div>
@ -154,16 +154,11 @@
selectLocationVisible: false,
moreSetting: false,
contentEditor: '',
categoryIds: [],
categories: [],
articleLink: `${window.origin}/artiles/`
}
},
created() {
console.log('created',window.origin)
},
mounted() {
console.log('mounted')
this.getMarkdown()
this.categoryTree()
const that = this
@ -171,33 +166,26 @@
that.reHeight()
}
},
destroyed() {
console.log('destroyed')
},
watch: {
file(){
console.log('filename is changed')
this.valueHasChanged()
},
filename(val){
console.log('filename is changed')
this.valueHasChanged()
this.$emit('onTitle', val)
},
categoryIds(){
console.log('categoryIds is changed')
this.valueHasChanged()
},
storageLocation(){
console.log('storageLocation is changed')
this.valueHasChanged()
}
},
methods: {
reload() {
this.getMarkdown(true)
},
valueHasChanged(){
this.$emit('update:hasChange', true)
},
getMarkdown(){
getMarkdown(isReload){
if(this.$route.query.id){
this.editStatus = true
markdownApi.getMarkdown({
@ -207,16 +195,24 @@
this.content = this.file.contentText
this.filename = this.file.name.split('.md')[0]
this.storageLocation = res.data.path
if(this.file.categoryIds){
this.file.categoryIds.forEach(categoryId => {
this.categoryIds.push(new Array(categoryId))
})
}
// 初始化编辑器
this.vditorInit(res.data.contentText)
if(isReload){
this.contentEditor.setValue(res.data.contentText)
} else {
this.vditorInit(res.data.contentText)
}
}).then(() => {
const that = this
setTimeout(function (){
that.$emit('update:hasChange', false)
}, 100)
})
} else {
this.vditorInit('')
if(isReload){
this.contentEditor.setValue('')
} else {
this.vditorInit('')
}
}
},
categoryTree() {
@ -316,13 +312,6 @@
}
return true
},
getCategoryList(){
let categoryIdList = []
this.categoryIds.forEach(categoryIds => {
categoryIdList.push(categoryIds[0])
})
return categoryIdList
},
// update
update(){
if(!this.checkParam()){
@ -338,7 +327,7 @@
filename: filename,
cover: this.file.cover,
slug: this.file.slug,
categoryIds: this.getCategoryList(),
categoryIds: this.file.categoryIds,
currentDirectory: this.storageLocation,
contentText: this.contentEditor.getValue()
}).then(() => {

View File

@ -60,7 +60,7 @@
min-width="200"
label="标题">
<template slot-scope="scope">
<router-link :title="'编辑 '+scope.row.name" :to="'/setting/website/manager-articles?operation=editor&id='+scope.row.id" target="_blank">{{scope.row.name}}<svg-icon icon-class="bianji-"></svg-icon></router-link>
<a :title="'编辑 '+scope.row.name" @click="editArticle(scope.row.id)">{{scope.row.name}}<svg-icon icon-class="bianji-"></svg-icon></a>
<router-link :title="'浏览 '+scope.row.name" :to="'/articles/article?mark='+scope.row.id" target="_blank"><svg-icon class="wailian" icon-class="wailian"></svg-icon></router-link>
</template>
</el-table-column>
@ -200,6 +200,13 @@ export default {
this.newArticleDialogVisible = true
this.$router.push({query: {operation: 'new'}})
},
editArticle(id) {
this.newArticleDialogVisible = true
this.$router.push({query: {operation: 'editor', id: id}})
if(this.$refs.editor){
this.$refs.editor.reload()
}
},
categoryTree() {
categoryApi.categoryTree({userId: this.$store.state.user.userId}).then(res => {
this.categories = res.data

View File

@ -14,7 +14,7 @@
placeholder="不选择"
:options="categories"
:show-all-levels="false"
:props="{ checkStrictly: true }"
:props="{ checkStrictly: true, value: 'id', label: 'name'}"
clearable></el-cascader>
</el-form-item>
<el-form-item label="分类描述" prop="desc">
@ -61,11 +61,10 @@
label="名称">
</el-table-column>
<el-table-column
prop="subCategorySize"
label="子分类">
<template slot-scope="scope">
<a v-if="scope.row.subCategorySize > 0"
@click="subCategoryList(scope.row.id)">{{ scope.row.subCategorySize }}个分类</a>
<a v-if="scope.row.childre && scope.row.children.length > 0"
@click="subCategoryList(scope.row.id)">{{ scope.row.children.length }}个分类</a>
<a v-else @click="add(scope.row.id)">新增</a>
</template>
</el-table-column>
@ -84,6 +83,9 @@
<el-table-column
prop="quota"
label="文章数">
<template slot-scope="scope">
<el-tag class="article-num">{{scope.row.articleNum}}</el-tag>
</template>
</el-table-column>
</el-table>
</el-card>
@ -321,5 +323,15 @@ export default {
height: 32px;
line-height: 32px;
}
.article-num {
}
.article-num:hover {
cursor: pointer;
background-color: #fbfdff;
color: #1d8cff;
}
.article-num:active {
background-color: #ecf5ff;
}
</style>