修改:修改分类管理

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

View File

@ -60,7 +60,7 @@
min-width="200" min-width="200"
label="标题"> label="标题">
<template slot-scope="scope"> <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> <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> </template>
</el-table-column> </el-table-column>
@ -200,6 +200,13 @@ export default {
this.newArticleDialogVisible = true this.newArticleDialogVisible = true
this.$router.push({query: {operation: 'new'}}) 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() { categoryTree() {
categoryApi.categoryTree({userId: this.$store.state.user.userId}).then(res => { categoryApi.categoryTree({userId: this.$store.state.user.userId}).then(res => {
this.categories = res.data this.categories = res.data

View File

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