<template>
  <div id="resume" style="padding-bottom:1.25rem">
    <list-tab :tab="tabsTitle">
      <template v-slot:title>
        <back-bar to="/manager/jobs/index" title="职位管理"></back-bar>
      </template>
      <template v-slot:main1>
        <resume-tem type="1" :list="list" :info="info" @search="search" @searchInfo="searchInfo" @changeStatus="changeStatus"></resume-tem>
      </template>
      <!-- <template v-slot:main2>
        <resume-tem type="2"></resume-tem>
      </template> -->
      <template v-slot:main2>
        <resume-tem type="3" :list="list" :info="info" @search="search" @searchInfo="searchInfo" @changeStatus="changeStatus"></resume-tem>
      </template>
    </list-tab>
  </div>
</template>

<script>
import listTab from '@/layout/list-tab.vue';
import backBar from '@/components/back-bar.vue';
import resumeTem from './resume/resume-tem.vue';
import { mapActions, mapState } from 'vuex';
export default {
  name: 'resume',
  props: {},
  components: {
    resumeTem,
    listTab,
    backBar,
  },
  data: () => ({
    tabsTitle: ['简历夹', '录用夹'],
    list: [],
    info: {},
  }),
  created() {
    this.search({ status: '0' });
    this.search({ status: '1' });
  },
  computed: {},
  methods: {
    ...mapActions(['lettersOperation']),
    async search({ status, studname }) {
      let result = await this.lettersOperation({ type: 'list', data: { post_id: this.$route.query.id, status: status, studname: studname } });
      if (`${result.errcode}` === '0') {
        this.$set(this, `list`, result.data);
      }
    },
    async searchInfo(id) {
      let result = await this.lettersOperation({ type: 'search', data: { id: id } });
      if (`${result.errcode}` === '0') {
        this.$set(this, `info`, result.data);
      }
    },
    async changeStatus({ id, status }) {
      let result = await this.lettersOperation({ type: 'update', data: { id: id, status: status } });
      if (`${result.errcode}` === '0') {
        this.$message.success('操作成功');
      } else {
        this.$message.error(result.errmsg || 'error');
      }
    },
  },
};
</script>

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