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