<template>
  <div id="recruit">
    <el-row>
      <el-col :span="24" class="top">
        <topInfo :topTitle="topTitle"></topInfo>
      </el-col>
      <el-col :span="24" class="main">
        <enterpriseProduct
          :recruitInfo="recruitInfo"
          :total="total"
          @handleCurrentChange="handleCurrentChange"
          @delete="deleteData"
          @edit="edit"
          @shibai="shibai"
        ></enterpriseProduct>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import topInfo from '@/layout/public/top.vue';
import enterpriseProduct from '@/layout/enterpriseProduct/enterpriseProduct.vue';
import { createNamespacedHelpers, mapGetters } from 'vuex';
const { mapActions: product } = createNamespacedHelpers('market');
export default {
  name: 'recruit',
  props: {},
  components: {
    topInfo,
    enterpriseProduct,
  },
  data: () => ({
    topTitle: '审核信息',
    recruitInfo: [],
    total: 1,
    skip: '',
  }),
  created() {
    this.search();
  },
  computed: {},
  methods: {
    ...product(['query', 'delete', 'fetch', 'update']),
    async search({ skip = 0, limit = 10, ...info } = {}) {
      skip = this.skip;
      const res = await this.query({ skip, limit, ...info });
      let newData = res.data.filter(i => i.status != '3');
      this.$set(this, `recruitInfo`, newData);
      this.$set(this, `total`, newData.length);
    },
    async deleteData(item) {
      const res = await this.delete(item.id);
      this.$checkRes(res, '删除成功', '删除失败');
      this.search();
    },

    async edit({ data }) {
      console.log('a');
      data.status = '1';
      let res = await this.update(data);
      this.$checkRes(res, '审核成功', '审核失败');
      console.log(data);
    },

    async shibai({ data }) {
      console.log('a');
      data.status = '2';
      let res = await this.update(data);
      this.$checkRes(res, '审核成功', '审核失败');
      console.log(data);
    },

    async handleCurrentChange({ skip, limit, currentPage }) {
      this.$set(this, `skip`, skip);
      this.search();
    },
  },
};
</script>

<style lang="less" scoped>
.main {
  padding: 20px;
  margin: 10px 20px;
  border: 1px solid #ccc;
  width: 96%;
}
</style>
