<template>
  <div id="adviserList">
    <enterprisefabu-detail
      :liebiaoList="liebiaoList"
      :recruitData="recruitData"
      @delete="deleteData"
      @onsave="onsaveClick"
      :successlist="successlist"
      :shenheList="shenheList"
      :Transactionlist="Transactionlist"
      :total="total"
      :total4="total4"
      :total5="total5"
      :total6="total6"
      :tatalstatus1="tatalstatus1"
      :tatalstatus2="tatalstatus2"
      @handleCurrentChange="handleCurrentChange"
      @handleCurrentChange1="handleCurrentChange1"
      @handleCurrentChange2="handleCurrentChange2"
      :jiaoyilist="jiaoyilist"
      :jiaoyilist1="jiaoyilist1"
      @deteles="deteles"
      @handleDelete="handleDelete"
      @shibai="shibai"
      @success="success"
      @jiaoyisuccess="jiaoyisuccess"
      :faqilist="faqilist"
      :totalfaqi="totalfaqi"
      @handleCurrentChangefaqi="handleCurrentChangefaqi"
      @handleCurrentChange4="handleCurrentChange4"
      @handleCurrentChange5="handleCurrentChange5"
      @handleCurrentChange6="handleCurrentChange6"
      :tatalcaogao="tatalcaogao"
      :caogao="caogao"
      @handleCurrentcaogao="handleCurrentcaogao"
      @submitcaogao="submitcaogao"
    ></enterprisefabu-detail>
  </div>
</template>

<script>
import enterprisefabuDetail from '@/components/enterprise/enterprisefabu.vue';
import { createNamespacedHelpers, mapGetters, mapState } from 'vuex';
const { mapActions: mapSite } = createNamespacedHelpers('site');
const { mapActions: mapRecruit } = createNamespacedHelpers('market');
const { mapActions: marketproduct } = createNamespacedHelpers('marketproduct');
const { mapActions: transaction } = createNamespacedHelpers('transaction');
const { mapActions: login } = createNamespacedHelpers('login');

export default {
  name: 'adviserList',
  props: {},
  components: {
    enterprisefabuDetail,
  },
  data: () => ({
    shenheList: [],
    successlist: [],
    info: {},
    liebiaoList: [
      { name: '基本信息' },
      { name: '消息管理' },
      { name: '我的发布' },
      { name: '事项管理' },
      { name: '展会管理' },
      // { name: '返回首页' },
      { name: '修改密码' },
      { name: '注销账号' },
    ],
    recruitData: [],
    gonggeiData: [],
    Transactionlist: [],
    jiaoyilist: [],
    jiaoyilist1: [],
    total: 1,
    total4: 1,
    total5: 1,
    total6: 1,
    tatalstatus1: 1,
    tatalstatus2: 1,
    skip: '',
    faqilist: [],
    totalfaqi: 1,
    tatalcaogao: 1,
    caogao: [],
  }),
  created() {
    this.searchInfo();
    this.searchstatus1();
    this.searchstaus2();

    this.caogaolist();
  },
  computed: {
    ...mapState(['user']),
  },
  methods: {
    ...mapRecruit({ columnList: 'query', columnInfo: 'fetch' }),
    ...marketproduct({ productList: 'query', columnInfo: 'fetch', marketcerate: 'create', productdeltet: 'delete', upup: 'update' }),
    ...transaction({ list: 'query', columnInfo: 'fetch', marketcerate: 'create', delete: 'delete', shenheupdate: 'update' }),
    ...login({ logout: 'logout', transactiondtetle: 'delete' }),
    // 查询列表
    async searchInfo({ skip = 0, limit = 3, ...info } = {}) {
      skip = this.skip;
      let status = 1;
      let userid = this.user.uid;
      const res = await this.productList({ skip, limit, status, userid, ...info });
      if (this.$checkRes(res)) {
        this.$set(this, `recruitData`, res.data);
        this.$set(this, `total`, res.total);
      }
    },
    async searchstatus1({ skip, limit = 3, ...info } = {}) {
      let status = 0;
      skip = this.skip;
      let userid = this.user.uid;
      const res = await this.productList({ skip, limit, status, userid, ...info });
      if (this.$checkRes(res)) {
        this.$set(this, `shenheList`, res.data);
        this.$set(this, `tatalstatus1`, res.total);
      }
    },
    async searchstaus2({ skip = 0, limit = 3, ...info } = {}) {
      let status = 2;
      skip = this.skip;
      let userid = this.user.uid;
      console.log();
      const res = await this.productList({ skip, limit, status, userid, ...info });
      console.log(res);
      if (this.$checkRes(res)) {
        this.$set(this, `successlist`, res.data);
        this.$set(this, `tatalstatus2`, res.total);
      }
    },

    async caogaolist({ skip = 0, limit = 3, ...info } = {}) {
      let status = '3';
      skip = this.skip;
      const res = await this.productList({ skip, limit, status, ...info });
      console.log(res.total);
      if (this.$checkRes(res)) {
        this.$set(this, `caogao`, res.data);
        this.$set(this, `tatalcaogao`, res.total);
      }
    },

    //分页
    async handleCurrentChangefaqi({ skip, limit, currentPage }) {
      this.$set(this, `skip`, skip);
      this.faqijiaoyi();
    },

    async handleCurrentChange({ skip, limit, currentPage }) {
      this.$set(this, `skip`, skip);
      this.searchInfo();
    },
    async handleCurrentChange1({ skip, limit, currentPage }) {
      this.$set(this, `skip`, skip);
      console.log(skip);
      this.searchstatus1();
    },

    async handleCurrentcaogao({ skip, limit, currentPage }) {
      this.$set(this, `skip`, skip);
      console.log(skip);
      this.caogaolist();
    },

    async handleCurrentChange2({ skip, limit, currentPage }) {
      this.$set(this, `skip`, skip);
      this.searchstaus2();
    },
    async handleCurrentChange4({ skip, limit, currentPage }) {
      this.$set(this, `skip`, skip);
      this.jiaoyi1();
    },
    async handleCurrentChange5({ skip, limit, currentPage }) {
      this.$set(this, `skip`, skip);
      this.jiaoyi2();
    },
    async handleCurrentChange6({ skip, limit, currentPage }) {
      this.$set(this, `skip`, skip);
      this.jiaoyi3();
    },
    // 删除信息
    async deleteData({ item }) {
      const res = await this.productdeltet(item.id);
      this.$checkRes(res, '删除成功', '删除失败');
    },
    async deteles({ item }) {
      const res = await this.delete(item.id);
      this.$checkRes(res, '删除成功', '删除失败');
    },

    async handleDelete({ item }) {
      const res = await this.productdeltet(item.id);
      this.$checkRes(res, '删除成功', '删除失败');
    },
    //审核

    async submitcaogao({ item }) {
      item.status = '0';
      let res = await this.upup(item);
      this.$checkRes(res, '发布成功', '审核失败');
      this.searchInfo();
      this.caogaolist();
    },

    async jiaoyisuccess({ item }) {},
    async shibai({ item }) {},
    async success({ item }) {},

    async onsaveClick({ id }) {
      console.log(id);

      if (id === '基本信息') {
        this.$router.push({ path: '/enterprise/enterprisejb' });
      } else if (id === '消息管理') {
        this.$router.push({ path: '/enterprise/enterprisexx' });
      } else if (id === '我的发布') {
        this.$router.push({ path: '/enterprise/enterprisefabu' });
      } else if (id === '事项管理') {
        this.$router.push({ path: '/enterprise/enterprisedg' });
      } else if (id === '展会管理') {
        this.$router.push({ path: '/enterprise/appointment' });
      } else if (id === '修改密码') {
        this.$router.push({ path: '/enterprise/xiugai' });
      } else if (id === '返回首页') {
        this.$router.push({ path: '/' });
      } else if (id === '注销账号') {
        this.logout();
        this.$message({
          message: '注销成功',
          type: 'success',
        });
        this.toLogin();
      }
    },
    async toLogin() {
      this.$router.push({ path: '/platlive' });
    },
  },
};
</script>

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