|
@@ -0,0 +1,123 @@
|
|
|
+<template>
|
|
|
+ <div id="list">
|
|
|
+ <el-image style="width: 100%; height: 10rem" :src="url"></el-image>
|
|
|
+ <el-tabs v-model="activeName" style="padding:10px;" @tab-click="tabClick">
|
|
|
+ <el-tab-pane v-for="(item, index) in list" :key="index" :name="`${index}`" :label="item.title">
|
|
|
+ <item @search="toSearch" :list="item.children" :hasMore="item.hasMore" :index="item.index"></item>
|
|
|
+ </el-tab-pane>
|
|
|
+ </el-tabs>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { mapActions } from 'vuex';
|
|
|
+import item from './item.vue';
|
|
|
+export default {
|
|
|
+ metaInfo() {
|
|
|
+ return {
|
|
|
+ title: this.title ? this.title : '就业信息网',
|
|
|
+ };
|
|
|
+ },
|
|
|
+ name: 'list',
|
|
|
+ props: {},
|
|
|
+ components: {
|
|
|
+ item,
|
|
|
+ },
|
|
|
+ data: () => ({
|
|
|
+ site: {},
|
|
|
+ url: '',
|
|
|
+ list: [],
|
|
|
+ activeName: '0',
|
|
|
+ }),
|
|
|
+ created() {
|
|
|
+ this.getSite();
|
|
|
+ this.getColumn();
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ module_id() {
|
|
|
+ return this.$route.params.id;
|
|
|
+ },
|
|
|
+ title() {
|
|
|
+ return this.$route.query.title;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...mapActions(['siteOperation', 'columnOperation', 'newsOperation']),
|
|
|
+ async getSite() {
|
|
|
+ let site = sessionStorage.getItem('site');
|
|
|
+ if (!site) {
|
|
|
+ let result = await this.siteOperation({ type: 'search', data: { site: this.$site } });
|
|
|
+ if (`${result.errcode}` === `0`) {
|
|
|
+ sessionStorage.setItem('site', JSON.stringify(result.data));
|
|
|
+ this.$set(this, `site`, result.data);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.$set(this, `site`, JSON.parse(site));
|
|
|
+ }
|
|
|
+ this.$set(this, `url`, this.site.banner);
|
|
|
+ },
|
|
|
+ //根据条件获取栏目
|
|
|
+ async getColumn(data = {}) {
|
|
|
+ let res = await this.columnOperation({ type: 'list', data: { parent_id: this.module_id } });
|
|
|
+ this.$set(this, `list`, res.data);
|
|
|
+ for (const key in this.list) {
|
|
|
+ this.toSearch({ index: key });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //根据条件获取信息
|
|
|
+ async getNewsList(item, news_type, options) {
|
|
|
+ let data = { ...options, news_type: news_type };
|
|
|
+ data.parent_id = news_type === '1' ? item.id : item.content_id;
|
|
|
+ let res = await this.newsOperation({ type: 'list', data: data });
|
|
|
+ if (`${res.errcode}` === '0') {
|
|
|
+ for (const val of res.data) {
|
|
|
+ let result = await this.newsOperation({ type: 'search', data: { id: val.id } });
|
|
|
+ if (`${result.errcode}` === '0') {
|
|
|
+ val.content = result.data.content;
|
|
|
+ } else {
|
|
|
+ this.$message.error(result.errmsg ? result.errmsg : 'error');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.errmsg ? res.errmsg : 'error');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async toSearch({ index, info }) {
|
|
|
+ let target = JSON.parse(JSON.stringify(this.list[index]));
|
|
|
+ if (target.hasMore === false) return;
|
|
|
+ //分页处理
|
|
|
+ if (info === 'nextPage') {
|
|
|
+ target.page++;
|
|
|
+ target.skip = (target.page - 1) * target.limit;
|
|
|
+ } else {
|
|
|
+ target.page = 1;
|
|
|
+ target.skip = 0;
|
|
|
+ target.limit = this.$limit;
|
|
|
+ }
|
|
|
+ //数据处理
|
|
|
+ if (target.type === 'bugList' || target.type === 'column') {
|
|
|
+ let res = await this.getNewsList(target, target.news_type, { skip: target.skip, limit: target.limit });
|
|
|
+ if (`${res.errcode}` === '0') {
|
|
|
+ target.children ? target.children.concat(res.data) : (target.children = res.data);
|
|
|
+ target.hasMore = target.children.length < res.total;
|
|
|
+ }
|
|
|
+ this.$set(this.list, index, target);
|
|
|
+ } else if (target.type === 'content') {
|
|
|
+ target.path = `news.html#/${target.content_id}`;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ tabClick() {
|
|
|
+ let target = this.list[this.activeName];
|
|
|
+ console.log(target);
|
|
|
+ if (target.type === 'url') {
|
|
|
+ window.location.href = target.url;
|
|
|
+ } else if (target.type === 'content') {
|
|
|
+ window.location.href = `news.html#/${target.id}`;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped></style>
|