修改:修改分类管理
This commit is contained in:
parent
1df2851455
commit
4ad88c2a7f
@ -24,8 +24,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="editor-right">
|
<div class="editor-right">
|
||||||
<div class="operation">
|
<div class="operation">
|
||||||
<el-button class="release-button" type="warning" size="small" @click="update" :loading="updating">保存草稿</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="update" :loading="updating">{{ editStatus?'发布文章':'更新文章' }}</el-button>
|
<el-button class="release-button" type="primary" size="small" @click="release" :loading="updating">{{ editStatus?'发布文章':'更新文章' }}</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div class="more-setting">
|
<div class="more-setting">
|
||||||
<p class="mark-setting-label">文章封面:</p>
|
<p class="mark-setting-label">文章封面:</p>
|
||||||
@ -42,18 +42,19 @@
|
|||||||
placeholder="缩略名"
|
placeholder="缩略名"
|
||||||
v-model="file.slug">
|
v-model="file.slug">
|
||||||
</el-input>
|
</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>
|
<p class="mark-setting-label">分类:</p>
|
||||||
<el-cascader
|
<el-cascader
|
||||||
v-model="file.categoryIds"
|
v-model="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: false, emitPath: false, value: 'id', label: 'name' }"
|
:props="{ multiple: true, checkStrictly: true, value: 'id', label: 'name' }"
|
||||||
clearable></el-cascader>
|
clearable
|
||||||
|
@change="selectCategory"
|
||||||
|
></el-cascader>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -155,6 +156,8 @@
|
|||||||
moreSetting: false,
|
moreSetting: false,
|
||||||
contentEditor: '',
|
contentEditor: '',
|
||||||
categories: [],
|
categories: [],
|
||||||
|
categoryIds: [],
|
||||||
|
draft: false,
|
||||||
articleLink: `${window.origin}/artiles/`
|
articleLink: `${window.origin}/artiles/`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -218,6 +221,24 @@
|
|||||||
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
|
||||||
|
|
||||||
|
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){
|
vditorInit(content){
|
||||||
@ -312,8 +333,28 @@
|
|||||||
}
|
}
|
||||||
return true
|
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(){
|
update(message){
|
||||||
|
let categoryIds = []
|
||||||
|
this.categoryIds.forEach(categoryIdList => {
|
||||||
|
categoryIds.push(categoryIdList[categoryIdList.length - 1])
|
||||||
|
})
|
||||||
if(!this.checkParam()){
|
if(!this.checkParam()){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -326,15 +367,16 @@
|
|||||||
username: this.$store.state.user.name,
|
username: this.$store.state.user.name,
|
||||||
filename: filename,
|
filename: filename,
|
||||||
cover: this.file.cover,
|
cover: this.file.cover,
|
||||||
slug: this.file.slug,
|
isDraft: this.draft,
|
||||||
categoryIds: this.file.categoryIds,
|
slug: this.file.slug ? this.file.slug : this.filename,
|
||||||
|
categoryIds: categoryIds,
|
||||||
currentDirectory: this.storageLocation,
|
currentDirectory: this.storageLocation,
|
||||||
contentText: this.contentEditor.getValue()
|
contentText: this.contentEditor.getValue()
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.$emit('update:hasChange', false)
|
this.$emit('update:hasChange', false)
|
||||||
this.updating = false
|
this.updating = false
|
||||||
this.$message({
|
this.$message({
|
||||||
message: "发布成功",
|
message: message ? message : "发布成功",
|
||||||
type: 'success',
|
type: 'success',
|
||||||
duration : 1000
|
duration : 1000
|
||||||
});
|
});
|
||||||
|
|||||||
@ -23,27 +23,30 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="table-top">
|
<div class="table-top">
|
||||||
<div class="table-top-left">
|
<div class="table-top-left">
|
||||||
<el-radio-group v-model="query.radioStatus" size="mini">
|
<el-radio-group v-model="query.radioStatus" size="mini" @change="getArticleList">
|
||||||
<el-radio-button label="release">可用</el-radio-button>
|
<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-button label="draft">草稿</el-radio-button>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
<span class="table-top-author">作者:</span>
|
<span class="table-top-author">作者:</span>
|
||||||
<el-radio-group v-model="query.radioUser" size="mini">
|
<el-radio-group v-model="query.radioUser" size="mini" @change="getArticleList">
|
||||||
<el-radio-button label="">所有</el-radio-button>
|
<el-radio-button label="all">所有</el-radio-button>
|
||||||
<el-radio-button :label="$store.state.userId">我的</el-radio-button>
|
<el-radio-button label="my">我的</el-radio-button>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</div>
|
</div>
|
||||||
<div class="table-top-right">
|
<div class="table-top-right">
|
||||||
<el-input v-model="query.keyword" size="mini" placeholder="请输入关键字"></el-input>
|
<el-input v-model="query.keyword" size="mini" placeholder="请输入关键字"></el-input>
|
||||||
<el-cascader
|
<el-cascader
|
||||||
v-model="query.parentCategoryId"
|
v-model="query.parentCategoryId"
|
||||||
|
class="mark-setting-input"
|
||||||
placeholder="不选择"
|
placeholder="不选择"
|
||||||
|
size="mini"
|
||||||
|
:collapse-tags="false"
|
||||||
:options="categories"
|
:options="categories"
|
||||||
:show-all-levels="false"
|
:show-all-levels="false"
|
||||||
size="mini"
|
:props="{ multiple: true, checkStrictly: false, emitPath: false, value: 'id', label: 'name' }"
|
||||||
:props="{ checkStrictly: true }"
|
|
||||||
clearable></el-cascader>
|
clearable></el-cascader>
|
||||||
<el-button type="primary" size="mini">筛选</el-button>
|
<el-button type="primary" size="mini" @click="getArticleList">筛选</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<el-table
|
<el-table
|
||||||
@ -68,7 +71,9 @@
|
|||||||
width="150"
|
width="150"
|
||||||
label="状态">
|
label="状态">
|
||||||
<template slot-scope="scope">
|
<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>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
@ -135,8 +140,8 @@ export default {
|
|||||||
},
|
},
|
||||||
categories: [],
|
categories: [],
|
||||||
query: {
|
query: {
|
||||||
radioStatus: 'release',
|
radioStatus: '',
|
||||||
radioUser: this.$store.state.userId,
|
radioUser: 'my',
|
||||||
keyword: '',
|
keyword: '',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -184,7 +189,14 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
getArticleList() {
|
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.articleList = res.data
|
||||||
this.pagination.total = res.count
|
this.pagination.total = res.count
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
@ -242,6 +254,7 @@ export default {
|
|||||||
window.onbeforeunload = null
|
window.onbeforeunload = null
|
||||||
this.pageTitle = '文章管理'
|
this.pageTitle = '文章管理'
|
||||||
this.hasChange = false
|
this.hasChange = false
|
||||||
|
this.getArticleList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,7 +63,7 @@
|
|||||||
<el-table-column
|
<el-table-column
|
||||||
label="子分类">
|
label="子分类">
|
||||||
<template slot-scope="scope">
|
<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>
|
@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>
|
||||||
@ -243,7 +243,7 @@ export default {
|
|||||||
this.multipleSelection.forEach(category => {
|
this.multipleSelection.forEach(category => {
|
||||||
categoryIds.push(category.id)
|
categoryIds.push(category.id)
|
||||||
})
|
})
|
||||||
this.$confirm('所选分类下的所有内容都将被删除, 您确认要删除吗?', '提示', {
|
this.$confirm('所选分类下的所有内容(包括文章)都将被删除,\r\n 您确认要删除吗?', '提示', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user