nebula/pages/portfolio/manager/bind/_portfolio_id.vue

88 lines
2.4 KiB
Vue
Raw Normal View History

2020-08-02 19:23:32 +08:00
<template>
<el-row class="wrapper">
<el-col style="margin-bottom: 1rem;">
<el-breadcrumb separator-class="el-icon-arrow-right">
<el-breadcrumb-item :to="{ path: '/portfolio/manager/' + idPortfolio }">返回上一级</el-breadcrumb-item>
<el-breadcrumb-item>关联文章</el-breadcrumb-item>
</el-breadcrumb>
</el-col>
<el-col>
<el-divider><i class="el-icon-loading"></i></el-divider>
</el-col>
<el-col>
<el-input v-model="searchText" @input="searchUnbindArticle" placeholder="输入帖子标题,回车检索"></el-input>
</el-col>
<el-col>
<portfolio-manager-bind-list :idPortfolio="idPortfolio" :articles="articles"
@currentChange="currentChangeArticle"></portfolio-manager-bind-list>
</el-col>
</el-row>
</template>
<script>
import {mapState} from 'vuex';
import PortfolioManagerBindList from "~/components/common/portfolio/manager/bind/list";
export default {
name: "PortfolioManagerBind",
components: {
PortfolioManagerBindList
},
validate({params, store}) {
return params.portfolio_id && !isNaN(Number(params.portfolio_id))
},
fetch({store, params, error}) {
return Promise.all([
store
.dispatch('portfolio/fetchUnBindArticleList', params)
.catch(err => error({statusCode: 404}))
])
},
computed: {
...mapState({
articles: state => state.portfolio.unbindArticles,
}),
idPortfolio() {
return Number(this.$route.params.portfolio_id)
}
},
data() {
return {
searchText: ''
}
},
methods: {
currentChangeArticle(page) {
this.$store.dispatch('portfolio/fetchUnBindArticleList', {
page: page,
portfolio_id: this.$route.params.portfolio_id
})
},
searchUnbindArticle() {
this.$store.dispatch('portfolio/fetchUnBindArticleList', {
page: 1,
portfolio_id: this.$route.params.portfolio_id,
searchText: this.searchText
})
},
onRouter(name, data) {
if (name === 'article') {
this.$router.push({
path: data
})
} else {
this.$router.push(
{
path: '/portfolio/post/' + data
}
)
}
}
}
}
</script>
<style scoped>
</style>