|
|
|
@ -9,7 +9,7 @@ |
|
|
|
|
<el-button v-auth="'内容管理:新增文章'" class="action-btn" type="primary" @click="addArticle">新增文章</el-button> |
|
|
|
|
</div> |
|
|
|
|
<div class="page-content" style="padding-top: 24px"> |
|
|
|
|
<el-table ref="table" :data="listData" class="table" stripe header-align="center" @selection-change="handleSelectionChange" row-key="id"> |
|
|
|
|
<el-table ref="table" :data="list" class="table" stripe header-align="center" @selection-change="handleSelectionChange" row-key="id"> |
|
|
|
|
<el-table-column type="selection" width="80" align="center" :reserve-selection="true"></el-table-column> |
|
|
|
|
<el-table-column type="index" width="60" label="序号" align="center"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
@ -70,11 +70,12 @@ export default { |
|
|
|
|
tabs: { |
|
|
|
|
first: "栏目内容管理" |
|
|
|
|
}, |
|
|
|
|
listData: [], |
|
|
|
|
list: [], |
|
|
|
|
multipleSelection: [], |
|
|
|
|
pageNo: +this.$route.query.page || 1, |
|
|
|
|
pageSize: 10, |
|
|
|
|
totals: 0 |
|
|
|
|
totals: 0, |
|
|
|
|
originSort: [] |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
props: { |
|
|
|
@ -93,10 +94,11 @@ export default { |
|
|
|
|
let data = { |
|
|
|
|
columnId: this.columnId |
|
|
|
|
}; |
|
|
|
|
this.$get(`${this.api.queryArticleByCondition}/${this.pageNo}/${this.pageSize}`, data).then(res => { |
|
|
|
|
this.listData = res.articleList; |
|
|
|
|
this.totals = res.total; |
|
|
|
|
if (!this.listData.length && this.totals) { |
|
|
|
|
this.$get(`${this.api.queryArticleByCondition}/${this.pageNo}/${this.pageSize}`, data).then(({ articleList, total }) => { |
|
|
|
|
this.list = articleList; |
|
|
|
|
this.totals = total; |
|
|
|
|
if (JSON.stringify(this.originSort) !== '{}') this.originSort = JSON.parse(JSON.stringify(articleList)) |
|
|
|
|
if (!this.list.length && this.totals) { |
|
|
|
|
this.pageNo--; |
|
|
|
|
this.getData(); |
|
|
|
|
} |
|
|
|
@ -112,7 +114,7 @@ export default { |
|
|
|
|
this.getData(); |
|
|
|
|
}, |
|
|
|
|
addArticle() { |
|
|
|
|
this.$router.push(`/addArticle?columnId=${this.columnId}&sort=${this.listData.length + 1}`); |
|
|
|
|
this.$router.push(`/addArticle?columnId=${this.columnId}&sort=${this.list.length + 1}`); |
|
|
|
|
}, |
|
|
|
|
editArticle(scope) { |
|
|
|
|
this.$router.push(`/addArticle?columnId=${this.columnId}&id=${scope.row.id}&sort=${scope.$index + 1}`); |
|
|
|
@ -155,7 +157,7 @@ export default { |
|
|
|
|
this.getData(); |
|
|
|
|
}).catch(res => { |
|
|
|
|
}); |
|
|
|
|
if(this.multipleSelection.length === this.listData.length && this.pageNo>1) { |
|
|
|
|
if(this.multipleSelection.length === this.list.length && this.pageNo>1) { |
|
|
|
|
this.handleCurrentChange(this.pageNo - 1) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
@ -174,12 +176,12 @@ export default { |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
sortSubmit() { |
|
|
|
|
if (this.listData.length) { |
|
|
|
|
if (this.listData.find(n => n.sort < 1)) return util.errorMsg("排序值最小为1"); |
|
|
|
|
let data = { articleList: this.listData }; |
|
|
|
|
if (this.list.length) { |
|
|
|
|
if (this.list.find(n => n.sort < 1)) return util.errorMsg("排序值最小为1"); |
|
|
|
|
let data = { articleList: this.list }; |
|
|
|
|
this.$post(this.api.articleSort, data).then(res => { |
|
|
|
|
util.successMsg("保存成功"); |
|
|
|
|
this.getContent(this.columnId); |
|
|
|
|
this.getData() |
|
|
|
|
}) |
|
|
|
|
.catch(err => { |
|
|
|
|
}); |
|
|
|
|