<template>
  <div id="applymmoneyIndex">
    <el-col :span="24" class="debt">
      <el-col :span="24" class="top">
        <topInfo :topTitle="topTitle" :display="display"></topInfo>
      </el-col>
      <el-col :span="24" class="search">
        <searchInfo @clickBtn="clickBtn"></searchInfo>
      </el-col>
      <el-col :span="24" class="main">
        <applymmLists :debtTable="debtTable" :total="total" @pagechange="pagechange"></applymmLists>
      </el-col>
    </el-col>
  </div>
</template>

<script>
import topInfo from '@/layout/common/topInfo.vue';
import searchInfo from '@/layout/common/applymmSearchInfo.vue';
import applymmLists from '@/layout/businessneed/applymmList.vue';
import { createNamespacedHelpers, mapGetters, mapState } from 'vuex';
const { mapActions: applymmoney } = createNamespacedHelpers('applymmoney');
export default {
  name: 'applymmoneyIndex',
  props: {},
  components: {
    topInfo, //头部导航
    searchInfo, //搜素
    applymmLists, //申请理财产品信息列表
  },
  data: () => ({
    topTitle: '申请理财产品信息',
    display: 'none',
    debtTable: [],
    total: '',
    region: '0',
  }),
  created() {
    this.claimList();
  },
  computed: {
    ...mapState(['user']),
  },
  methods: {
    ...applymmoney(['create', 'amlist', 'one', 'changefollow']),
    async claimList({ skip = 1, limit = 10, jg_id = this.user.userid, region = this.region } = {}) {
      const res = await this.amlist({ skip, limit, jg_id, region });
      this.$set(this, `debtTable`, res.res);
      this.$set(this, `total`, res.total);
    },

    async pagechange(data) {
      var skip = data.skip;
      var limit = 10;
      var jg_id = this.user.userid;
      let region = this.region;
      const res = await this.amlist({ skip, limit, jg_id, region });
      this.$set(this, `debtTable`, res.res);
      this.$set(this, `total`, res.total);
    },
    async clickBtn(message) {
      //查询
      this.region = message;
      var skip = 0;
      var limit = 10;
      var jg_id = this.user.userid;
      let region = this.region;
      const res = await this.amlist({ skip, limit, jg_id, region });
      this.$set(this, `debtTable`, res.res);
      this.$set(this, `total`, res.total);
    },
  },
};
</script>

<style lang="less" scoped>
.debt {
  padding: 20px;
}
.top {
  border-bottom: 1px solid #ccc;
}
</style>
