<template>
  <div id="followstick">
    <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="main">
        <followStcokList :debtTable="debtTable" :total="total" @pagechange="pagechange" @deleteRow="deleteRow"></followStcokList>
      </el-col>
    </el-col>
  </div>
</template>

<script>
import topInfo from '@/layout/common/topInfo.vue';
import followStcokList from '@/layout/follow/followStcokList.vue';
import { createNamespacedHelpers, mapGetters, mapState } from 'vuex';
const { mapActions: financefollow } = createNamespacedHelpers('follow');
export default {
  name: 'followstick',
  props: {},
  components: {
    topInfo, //头部导航
    followStcokList, //债权需求列表
  },
  data: () => ({
    topTitle: '授信债权需求',
    display: 'none',
    debtTable: [],
    total: '',
    jgpro: '1',
  }),
  created() {
    this.followstockList();
  },
  computed: {
    ...mapState(['user']),
  },
  methods: {
    ...financefollow(['credit', 'followstock', 'delete']),
    async followstockList({ skip = 1, limit = 10, userid = this.user.userid, finceType = this.jgpro } = {}) {
      const res = await this.followstock({ skip, limit, userid, finceType });
      this.$set(this, `debtTable`, res.res);
      this.$set(this, `total`, res.total);
    },
    // 删除
    async deleteRow(id) {
      const res = await this.delete(id);
      this.$checkRes(res, '取消关注成功', '取消关注失败');
      this.followstockList();
    },
    async pagechange(data) {
      var skip = data.skip;
      var limit = 10;
      var userid = this.user.userid;
      var finceType = this.jgpro;
      const res = await this.followstock({ skip, limit, userid, finceType });
      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>
