<template>
  <div id="adviserList">
    <enterprisedg-detail
      :info="info"
      @detailcm="clickDetailcm"
      :recruitData="recruitData"
      :liebiaoList="liebiaoList"
      @onsave="onsaveClick"
      :columnName="columnName"
      :total="total"
    ></enterprisedg-detail>
  </div>
</template>

<script>
import enterprisedgDetail from '@/components/enterprise/enterpisedg.vue';
import { createNamespacedHelpers, mapGetters } from 'vuex';
const { mapActions: mapSite } = createNamespacedHelpers('site');
const { mapActions: mapColumn } = createNamespacedHelpers('policiesColumn');
const { mapActions: mapRecruit } = createNamespacedHelpers('policiesjbxx');
export default {
  name: 'adviserList',
  props: {},
  components: {
    enterprisedgDetail,
  },
  data: () => ({
    info: {},
    liebiaoList: [],
    columnName: '',
    recruitData: [],
  }),
  created() {
    this.searchSite();
    this.searchColumn();
    this.searchName();
    this.searchList();
  },
  computed: {},
  methods: {
    ...mapSite(['showInfo']),
    ...mapColumn({ columnList: 'query', columnInfo: 'fetch' }),
    ...mapRecruit({ recruitList: 'query' }),
    // 查询站点信息
    async searchSite() {
      let res = await this.showInfo();
      let object = JSON.parse(JSON.stringify(res.data));
      if (object) {
        this.$set(this, `info`, res.data);
      } else {
        this.$message.error(res.errmsg ? res.errmsg : 'error');
      }
    },
    // 查询科技政务栏目
    async searchColumn({ ...info } = {}) {
      const res = await this.columnList({ ...info });
      this.$set(this, `liebiaoList`, res.data);
    },
    async onsaveClick({ id }) {
      const res = await this.columnInfo(id);
      if (res.data.name === '招聘信息') {
        this.$router.push({ path: '/personnel/recruitList', query: { id: id } });
      } else if (res.data.name === '就业指导') {
        this.$router.push({ path: '/personnel/guidanceList', query: { id: id } });
      } else if (res.data.name === '学习实践') {
        this.$router.push({ path: '/personnel/practiceList', query: { id: id } });
      } else if (res.data.name === '勤工俭学') {
        this.$router.push({ path: '/personnel/diligenceList', query: { id: id } });
      } else if (res.data.name === '工作顾问') {
        this.$router.push({ path: '/personnel/adviserList', query: { id: id } });
      }
    },
    async searchName() {
      let nameId = this.$route.query.id;
      const res = await this.columnInfo(nameId);
      this.$set(this, `columnName`, res.data.name);
    },
    async searchList({ skip = 0, limit = 10, column_id } = {}) {
      const res = await this.recruitList({ skip, limit, column_id: this.$route.query.id });
      if (this.$checkRes(res)) {
        this.$set(this, `recruitData`, res.data);
        console.log(res.data);
      }
    },
    clickDetailcm({ data }) {
      this.$router.push({ path: '/personnel/personnelcmdetail', query: { id: data.id } });
    },
  },
};
</script>

<style lang="less" scoped></style>
