<template>
    <div id="manageMoneyIndex">
        <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">
                <manageMoneyIndexInfo @clickBtn="clickBtn"></manageMoneyIndexInfo>
            </el-col>
            <el-col :span="24" class="main">
                <manageMoneyList :debtTable="debtTable" :total="total" @pagechange="pagechange" ></manageMoneyList>
            </el-col>
        </el-col>
    </div>
</template>

<script>
  import topInfo from '@/layout/common/topInfoloan.vue';
  import manageMoneyIndexInfo from '@/layout/financeclaims/financeClaimInfo.vue';
  import manageMoneyList from '@/layout/financeclaims/manageMoneyList.vue';
  import { createNamespacedHelpers, mapGetters ,mapState} from 'vuex';
  const { mapActions: managemoney } = createNamespacedHelpers('managemoney');
  export default {
    name: 'manageMoneyIndex',
    props: {},
    components: {
      topInfo, //头部导航
      manageMoneyIndexInfo, //搜素
      manageMoneyList, //理财列表
    },
    data: () => ({
      topTitle: '理财产品列表',
      display: 'none',
      debtTable: [],
      total: '',
      cpname: '',
      jgname:'',
      region:'1'

    }),
    created() {
      this.managmoneyList();
    },
    computed: {
      ...mapState(['user']),
    },
    methods: {
      ...managemoney([ 'update','fetch','mmoneyList','orUpdate']),
      async managmoneyList({ skip = 1, limit = 10, uid = this.user.userid,type=0,status = this.region} = {}) {
        const res = await this.mmoneyList({ skip, limit, uid ,type,status});
        this.$set(this, `debtTable`, res.res);
        this.$set(this, `total`, res.total);
      },

      async pagechange(data) {
        var skip = data.skip;
        var limit = 10;
        var innewname=this.jgname;
        var title = this.cpname ;
        var  uid = this.user.userid ;
        var status = this.region;
        var type=0;
        const res = await this.mmoneyList({ skip, limit, uid ,type,innewname,title,status});
        this.$set(this, `debtTable`, res.res);
        this.$set(this, `total`, res.total);
      },
      //查询
      async clickBtn(data) {
        var innewname=data.innewname;//机构名称
        var title = data.name;//产品名称
        this.cpname = data.name;
        this.jgname = data.innewname;
        this.region = data.region;
        var status = data.region;
        var skip = 0;
        var limit = 10;
        var  uid = this.user.userid;
        var type=0;
        const res = await this.mmoneyList({ skip, limit, uid ,type,innewname,title,status});
        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;
    }
    .search {
        width: 97%;
        height: 35px;
        margin: 20px;
    }
</style>
