<template>
  <div id="insitionIndex">
    <el-col :span="24" class="debt">
      <el-col :span="24" class="main">
        <insitionList :debtTable="debtTable" :total="total" @tomake="tomake"></insitionList>
      </el-col>
    </el-col>
  </div>
</template>

<script>
import insitionList from '@/layout/financeclaims/insitionList.vue';
import { createNamespacedHelpers, mapGetters, mapState } from 'vuex';
const { mapActions } = createNamespacedHelpers('institution');
export default {
  name: 'insitionIndex',
  props: {},
  components: {
    insitionList,
  },
  data: () => ({
    debtTable: [],
    total: '',
  }),
  created() {
    this.financeclaimsList();
  },
  computed: {
    ...mapState(['user']),
  },
  methods: {
    ...mapActions(['query', 'delete', 'fetch', 'update']),
    async financeclaimsList({ skip = 0, limit = 10, uid = this.user.uid } = {}) {
      const res = await this.query({ skip, limit, uid });
      this.$set(this, `debtTable`, res.data);
      this.$set(this, `total`, res.total);
    },
    async tomake({ data }) {
      data.status = '1';
      console.log('data=================================' + JSON.stringify(data));
      const res = await this.update(data);
      console.log('res=================================' + JSON.stringify(res));
      console.log(res.errcode === 0);
      if (res.errcode === 0) {
        this.$message({
          message: '发布至金控审核成功',
          type: 'success',
        });
      } else {
        this.$message({
          message: '发布至金控审核失败',
          type: 'error',
        });
      }
    },
  },
};
</script>

<style lang="less" scoped>
.debt {
  padding: 20px;
}
.top {
  border-bottom: 1px solid #ccc;
}
.search {
  width: 97%;
  height: 35px;
  margin: 20px;
}
</style>
