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

<script>
import topInfo from '@/layout/public/top.vue';
import transaction from '@/layout/enterprise/transaction.vue';
import { createNamespacedHelpers, mapGetters } from 'vuex';
const { mapActions: product } = createNamespacedHelpers('marketproject');
const { mapActions: tranaudit } = createNamespacedHelpers('tranaudit');
const { mapActions: transactions } = createNamespacedHelpers('transaction');

export default {
  name: 'recruit',
  props: {},
  components: {
    topInfo,
    transaction,
  },
  data: () => ({
    topTitle: '审核信息',
    recruitInfo: [],
    total: 1,
    skip: '',
  }),
  created() {
    this.search();
  },
  computed: {},
  methods: {
    ...product(['query', 'delete', 'fetch', 'update']),
    ...tranaudit({ tranauditList: 'query', tranauditListupdate: 'update' }),
    ...transactions({ transactionsfetch: 'fetch', transactionslist: 'query', transactiondetele: 'detele' }),

    async search({ skip = 0, limit = 10, ...info } = {}) {
      skip = this.skip;
      const res = await this.transactionslist({ skip, limit, ...info });
      console.log(res);
      console.log(res.data);
      this.$set(this, `recruitInfo`, res.data);
      this.$set(this, `total`, res.total);
    },
    async deleteData(item) {
      const res = await this.transactiondetele(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 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>
