<template>
  <div id="index">
    <trial-detail
      :info="info"
      :nativeList="nativeList"
      @onsave="nativeClick"
      :display="display"
      :userInfos="userInfos"
      :userList="userList"
      :userListTotal="userListTotal"
      :adminList="adminList"
      :adminListTotal="adminListTotal"
      :alreadyList="alreadyList"
      :alreadyListTotal="alreadyListTotal"
      :notList="notList"
      :notListTotal="notListTotal"
      :JiaoyiList="JiaoyiList"
      :JiaoyiTotal="JiaoyiTotal"
      :alreadyTwoList="alreadyTwoList"
      :alreadyTwoListTotal="alreadyTwoListTotal"
      :notTwoList="notTwoList"
      :notTwoListTotal="notTwoListTotal"
      :JiaoyiTwoList="JiaoyiTwoList"
      :JiaoyiTwoListTotal="JiaoyiTwoListTotal"
      @deletes="deleteAlready"
    ></trial-detail>
  </div>
</template>

<script>
import trialDetail from '@/components/trial/index.vue';
import { createNamespacedHelpers, mapGetters } from 'vuex';
const { mapActions: mapSite } = createNamespacedHelpers('site');
const { mapActions: mapProduct } = createNamespacedHelpers('enterpriseproject');
const { mapActions: mapMarketUser } = createNamespacedHelpers('market');
export default {
  name: 'index',
  props: {},
  components: {
    trialDetail,
  },
  data: () => ({
    info: {},
    nativeList: [
      {
        name: '基本信息',
      },
      {
        name: '用户管理',
      },
      {
        name: '我的审核',
      },
      {
        name: '统计信息',
      },
      {
        name: '注销账号',
      },
    ],
    display: 'first',
    // 基本信息
    userInfos: {
      name: '外审管理员',
      cardnumber: '220182199603257019',
      addr: '吉林省长春市朝阳区力旺广场B座16楼1608',
    },
    userList: [
      {
        name: '测试人员',
        img_path: require('@/assets/getImage.jpg'),
        role: '外审管理员',
        is_qy: '法人',
        phone: '0431-123456',
      },
      {
        name: '三条数据',
        img_path: require('@/assets/getImage.jpg'),
        role: '外审管理员',
        is_qy: '法人',
        phone: '0431-123456',
      },
    ],
    userListTotal: 1,
    adminList: [
      {
        name: '测试人员',
        img_path: require('@/assets/getImage.jpg'),
        role: '外审管理员',
        is_qy: '法人',
        phone: '0431-123456',
      },
      {
        name: '三条数据',
        img_path: require('@/assets/getImage.jpg'),
        role: '外审管理员',
        is_qy: '法人',
        phone: '0431-123456',
      },
    ],
    adminListTotal: 1,
    alreadyList: [
      {
        image: require('@/assets/getImage.jpg'),
        name: '产品名称',
        totaltype: '服务',
        price: '1000',
        priceunit: '元/台',
      },
    ],
    alreadyListTotal: 1,
    notList: [
      {
        image: require('@/assets/getImage.jpg'),
        name: '产品名称',
        totaltype: '服务',
        price: '1000',
        priceunit: '元/台',
      },
    ],
    notListTotal: 1,
    JiaoyiList: [
      {
        image: require('@/assets/getImage.jpg'),
        name: '产品名称',
        totaltype: '服务',
        price: '1000',
        priceunit: '元/台',
      },
    ],
    JiaoyiTotal: 1,
    alreadyTwoList: [
      {
        image: require('@/assets/getImage.jpg'),
        name: '产品名称',
        totaltype: '服务',
        price: '1000',
        priceunit: '元/台',
      },
    ],
    alreadyTwoListTotal: 1,
    notTwoList: [
      {
        image: require('@/assets/getImage.jpg'),
        name: '产品名称',
        totaltype: '服务',
        price: '1000',
        priceunit: '元/台',
      },
    ],
    notTwoListTotal: 1,
    JiaoyiTwoList: [
      {
        image: require('@/assets/getImage.jpg'),
        name: '我的供给',
        totaltype: '服务',
        price: '1000',
        priceunit: '元/台',
      },
    ],
    JiaoyiTwoListTotal: 1,
  }),
  created() {
    this.searchSite();
    this.searchInfo();
    this.searchUser();
  },
  computed: {},
  methods: {
    ...mapSite(['showInfo']),
    ...mapProduct({ ProductQuery: 'query', ProductFetch: 'fetch', ProductDelete: 'delete' }),
    ...mapMarketUser({ userQuery: 'query', userFetch: 'fetch', userDelete: 'delete' }),
    // 查询站点信息
    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 nativeClick({ name }) {
      // console.log(name);
      if (name === '基本信息') {
        this.display = 'first';
      } else if (name === '用户管理') {
        this.display = 'second';
      } else if (name === '我的审核') {
        this.display = 'third';
      } else if (name === '统计信息') {
        this.display = 'fourth';
      } else {
        this.display = 'fivth';
      }
    },
    async searchInfo({ skip = 0, limit = 3, ...info } = {}) {
      const res = await this.ProductQuery({ skip, limit, ...info });
      this.$set(this, `alreadyList`, res.data);
      this.$set(this, `alreadyListTotal`, res.total);
      this.$set(this, `notList`, res.data);
      this.$set(this, `notListTotal`, res.total);
      this.$set(this, `JiaoyiList`, res.data);
      this.$set(this, `JiaoyiListTotal`, res.total);
      this.$set(this, `alreadyTwoList`, res.data);
      this.$set(this, `alreadyTwoListTotal`, res.total);
      this.$set(this, `notTwoList`, res.data);
      this.$set(this, `notTwoListTotal`, res.total);
      this.$set(this, `JiaoyiTwoList`, res.data);
      this.$set(this, `JiaoyiTwoListTotal`, res.total);
    },
    async deleteAlready({ item }) {
      console.log(item);
      console.log(item.id);
      this.$message('刪除成功');
    },
    async searchUser({ skip = 0, limit = 3, ...info } = {}) {
      const res = await this.userQuery({ skip, limit, ...info });
      console.log(res);
      this.$set(this, `userList`, res.data);
      this.$set(this, `userListTotal`, res.total);
    },
  },
};
</script>

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