2020-08-02 19:23:32 +08:00
|
|
|
<template>
|
|
|
|
<el-row>
|
|
|
|
<el-col>
|
2022-07-25 06:45:33 +08:00
|
|
|
<el-table :data="articles.list" style="width: 100%">
|
2020-08-02 19:23:32 +08:00
|
|
|
<el-table-column
|
|
|
|
label="#"
|
|
|
|
width="40"
|
|
|
|
prop="idArticle">
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column
|
|
|
|
label="文章标题">
|
|
|
|
<template slot-scope="scope">
|
2020-08-12 11:28:37 +08:00
|
|
|
<el-link rel="nofollow" type="primary" @click.native="onRouter('article', scope.row.idArticle)" :underline="false">{{
|
2020-08-02 19:23:32 +08:00
|
|
|
scope.row.articleTitle }}
|
|
|
|
</el-link>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column
|
|
|
|
label="排序(回车更新)"
|
|
|
|
width="200">
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<el-input-number v-model="scope.row.sortNo" @keyup.enter.native="updateArticleSortNo(scope.row)"
|
|
|
|
:min="1"></el-input-number>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column
|
|
|
|
label="操作"
|
|
|
|
width="200">
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<el-button @click="deletePortFolioArticle(scope.row.idArticle)">取消绑定</el-button>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
</el-table>
|
|
|
|
</el-col>
|
|
|
|
<el-col>
|
2021-04-27 21:40:22 +08:00
|
|
|
<div class="vertical-container text-center" style="padding-top: 10px;">
|
2022-07-25 06:45:33 +08:00
|
|
|
<el-pagination :hide-on-single-page="true"
|
2020-08-02 19:23:32 +08:00
|
|
|
layout="prev, pager, next"
|
2022-07-25 06:45:33 +08:00
|
|
|
:current-page="articles.pageNum"
|
|
|
|
:total="articles.total"
|
2021-04-27 21:40:22 +08:00
|
|
|
prev-text="上一页"
|
|
|
|
next-text="下一页"
|
2020-08-02 19:23:32 +08:00
|
|
|
@current-change="currentChange">
|
|
|
|
</el-pagination>
|
|
|
|
</div>
|
|
|
|
</el-col>
|
|
|
|
</el-row>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import {mapState} from 'vuex';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "PortfolioManagerList",
|
|
|
|
props: {
|
|
|
|
idPortfolio: {
|
|
|
|
type: Number
|
|
|
|
}
|
|
|
|
},
|
|
|
|
validate({params, store}) {
|
|
|
|
return !isNaN(Number(this.idPortfolio))
|
|
|
|
},
|
|
|
|
fetch({store, params, error}) {
|
|
|
|
return Promise.all([
|
|
|
|
store
|
|
|
|
.dispatch('portfolio/fetchArticleList', {
|
|
|
|
portfolio_id: this.idPortfolio
|
|
|
|
})
|
|
|
|
.catch(err => error({statusCode: 404}))
|
|
|
|
])
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
articles: {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
currentChange(page) {
|
|
|
|
this.getArticleData(page);
|
|
|
|
},
|
|
|
|
async getArticleData(page){
|
|
|
|
let _ts = this;
|
|
|
|
const responseTopData = await this.$axios.$get('/api/console/portfolio/' + _ts.idPortfolio + '/articles?page='+page);
|
|
|
|
if (responseTopData) {
|
2022-07-25 06:45:33 +08:00
|
|
|
responseTopData.pageNum = page;
|
2020-08-02 19:23:32 +08:00
|
|
|
_ts.$set(_ts, 'articles', responseTopData);
|
|
|
|
window.scrollTo(0, 0);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
updateArticleSortNo(article) {
|
|
|
|
let _ts = this;
|
|
|
|
if (article.sortNo) {
|
|
|
|
_ts.$axios.$put('/api/portfolio/update-article-sort-no',{
|
|
|
|
idArticle: article.idArticle,
|
|
|
|
idPortfolio: _ts.idPortfolio,
|
|
|
|
sortNo: article.sortNo
|
|
|
|
}).then(function (res) {
|
|
|
|
if (res) {
|
2022-08-27 16:05:43 +08:00
|
|
|
_ts.$message("更新成功!");
|
2020-08-02 19:23:32 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
_ts.$message("排序号不能为空");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
deletePortFolioArticle(idArticle) {
|
|
|
|
let _ts = this;
|
|
|
|
_ts.$confirm('确定取消绑定吗?', '提示', {
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
type: 'warning'
|
|
|
|
}).then(() => {
|
|
|
|
_ts.$axios.$delete('/api/portfolio/unbind-article', {
|
|
|
|
params: {
|
|
|
|
idArticle: idArticle,
|
|
|
|
idPortfolio: _ts.idPortfolio
|
|
|
|
}
|
|
|
|
}).then(function (res) {
|
|
|
|
if (res) {
|
2022-08-27 16:05:43 +08:00
|
|
|
_ts.$message('操作成功!');
|
2022-07-25 06:45:33 +08:00
|
|
|
_ts.currentChange(_ts.articles.pageNum);
|
2020-08-02 19:23:32 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}).catch(() => {
|
|
|
|
_ts.$message({
|
|
|
|
type: 'info',
|
|
|
|
message: '已取消'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onRouter (name, data) {
|
|
|
|
if (name === 'article') {
|
|
|
|
this.$router.push({
|
|
|
|
path: `/article/${data}`
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.getArticleData(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
</style>
|