修改:修改分类管理

This commit is contained in:
jmal 2020-11-26 18:03:18 +08:00
parent 1df2851455
commit 4ad88c2a7f
3 changed files with 80 additions and 25 deletions

View File

@ -24,8 +24,8 @@
</div>
<div class="editor-right">
<div class="operation">
<el-button class="release-button" type="warning" size="small" @click="update" :loading="updating">保存草稿</el-button>
<el-button class="release-button" type="primary" size="small" @click="update" :loading="updating">{{ editStatus?'发布文章':'更新文章' }}</el-button>
<el-button class="release-button" type="warning" size="small" @click="saveDraft" :loading="updating">保存草稿</el-button>
<el-button class="release-button" type="primary" size="small" @click="release" :loading="updating">{{ editStatus?'发布文章':'更新文章' }}</el-button>
</div>
<div class="more-setting">
<p class="mark-setting-label">文章封面:</p>
@ -42,18 +42,19 @@
placeholder="缩略名"
v-model="file.slug">
</el-input>
<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>
<el-cascader
v-model="file.categoryIds"
v-model="categoryIds"
class="mark-setting-input"
placeholder="不选择"
:collapse-tags="false"
:options="categories"
:show-all-levels="false"
:props="{ multiple: true, checkStrictly: false, emitPath: false, value: 'id', label: 'name' }"
clearable></el-cascader>
:props="{ multiple: true, checkStrictly: true, value: 'id', label: 'name' }"
clearable
@change="selectCategory"
></el-cascader>
</div>
</div>
</div>
@ -155,6 +156,8 @@
moreSetting: false,
contentEditor: '',
categories: [],
categoryIds: [],
draft: false,
articleLink: `${window.origin}/artiles/`
}
},
@ -218,6 +221,24 @@
categoryTree() {
categoryApi.categoryTree({userId: this.$store.state.user.userId}).then(res => {
this.categories = res.data
let ss = ["5fbf6857aff038ad2c1d686d", "5fbf685eaff038ad2c1d686e", "5fbf6863aff038ad2c1d686f", "5fbf689baff038ad2c1d6874"]
this.findCategoryIds(this.categories, ss)
console.log(this.categoryIds)
})
},
findCategoryIds(categories, ss) {
categories.forEach(category => {
let ids = []
if(category.ids){
ids = category.ids
}
ids.push(category.id)
category['ids'] = ids
if(ss.includes(category.id)){
this.categoryIds.push(ids)
}
this.findCategoryIds(categories.children)
})
},
vditorInit(content){
@ -312,8 +333,28 @@
}
return true
},
saveDraft() {
this.draft = true
this.update('保存草稿成功')
},
release() {
this.draft = false
this.update()
},
selectCategory(val){
console.log(val)
let categoryIds = []
this.categoryIds.forEach(categoryIdList => {
categoryIds.push(categoryIdList[categoryIdList.length - 1])
})
console.log(categoryIds)
},
// update
update(){
update(message){
let categoryIds = []
this.categoryIds.forEach(categoryIdList => {
categoryIds.push(categoryIdList[categoryIdList.length - 1])
})
if(!this.checkParam()){
return
}
@ -326,15 +367,16 @@
username: this.$store.state.user.name,
filename: filename,
cover: this.file.cover,
slug: this.file.slug,
categoryIds: this.file.categoryIds,
isDraft: this.draft,
slug: this.file.slug ? this.file.slug : this.filename,
categoryIds: categoryIds,
currentDirectory: this.storageLocation,
contentText: this.contentEditor.getValue()
}).then(() => {
this.$emit('update:hasChange', false)
this.updating = false
this.$message({
message: "发布成功",
message: message ? message : "发布成功",
type: 'success',
duration : 1000
});

View File

@ -23,27 +23,30 @@
<div>
<div class="table-top">
<div class="table-top-left">
<el-radio-group v-model="query.radioStatus" size="mini">
<el-radio-button label="release">可用</el-radio-button>
<el-radio-group v-model="query.radioStatus" size="mini" @change="getArticleList">
<el-radio-button label="">可用</el-radio-button>
<el-radio-button label="release">已发布</el-radio-button>
<el-radio-button label="draft">草稿</el-radio-button>
</el-radio-group>
<span class="table-top-author">作者:</span>
<el-radio-group v-model="query.radioUser" size="mini">
<el-radio-button label="">所有</el-radio-button>
<el-radio-button :label="$store.state.userId">我的</el-radio-button>
<el-radio-group v-model="query.radioUser" size="mini" @change="getArticleList">
<el-radio-button label="all">所有</el-radio-button>
<el-radio-button label="my">我的</el-radio-button>
</el-radio-group>
</div>
<div class="table-top-right">
<el-input v-model="query.keyword" size="mini" placeholder="请输入关键字"></el-input>
<el-cascader
v-model="query.parentCategoryId"
class="mark-setting-input"
placeholder="不选择"
size="mini"
:collapse-tags="false"
:options="categories"
:show-all-levels="false"
size="mini"
:props="{ checkStrictly: true }"
:props="{ multiple: true, checkStrictly: false, emitPath: false, value: 'id', label: 'name' }"
clearable></el-cascader>
<el-button type="primary" size="mini">筛选</el-button>
<el-button type="primary" size="mini" @click="getArticleList">筛选</el-button>
</div>
</div>
<el-table
@ -68,7 +71,9 @@
width="150"
label="状态">
<template slot-scope="scope">
<el-tag size="medium" type="success">{{ scope.row.release?'已发布':'未发布' }}</el-tag>
<el-tag v-if="scope.row.draft" size="medium" type="warning">草稿</el-tag>
<el-tag v-if="scope.row.release" size="medium" type="success">已发布</el-tag>
<el-tag v-if="!scope.row.release" size="medium" type="info">未发布</el-tag>
</template>
</el-table-column>
<el-table-column
@ -135,8 +140,8 @@ export default {
},
categories: [],
query: {
radioStatus: 'release',
radioUser: this.$store.state.userId,
radioStatus: '',
radioUser: 'my',
keyword: '',
},
}
@ -184,7 +189,14 @@ export default {
}
},
getArticleList() {
markdownApi.getMarkdown({pageIndex: this.pagination.pageIndex, pageSize: this.pagination.pageSize}).then((res) => {
markdownApi.getMarkdown({
pageIndex: this.pagination.pageIndex,
pageSize: this.pagination.pageSize,
userId: this.query.radioUser === 'my' ? this.$store.state.user.userId : null,
isRelease: this.query.radioStatus === 'release',
isDraft: this.query.radioStatus === 'draft',
keyword: this.query.keyword
}).then((res) => {
this.articleList = res.data
this.pagination.total = res.count
this.$nextTick(() => {
@ -242,6 +254,7 @@ export default {
window.onbeforeunload = null
this.pageTitle = '文章管理'
this.hasChange = false
this.getArticleList()
}
}
}

View File

@ -63,7 +63,7 @@
<el-table-column
label="子分类">
<template slot-scope="scope">
<a v-if="scope.row.childre && scope.row.children.length > 0"
<a v-if="scope.row.children && 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>
@ -243,7 +243,7 @@ export default {
this.multipleSelection.forEach(category => {
categoryIds.push(category.id)
})
this.$confirm('所选分类下的所有内容都将被删除, 您确认要删除吗?', '提示', {
this.$confirm('所选分类下的所有内容(包括文章)都将被删除,\r\n 您确认要删除吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'