<template>
  <div class="page-com">
    <div class="tables">
      <!-- <block-header :title="title"></block-header> -->
      <el-table
          border
          size="mini"
          :highlight-current-row="true"
          :header-row-class-name="headerStyle"
          :data="data"
          stripe
          style="width: 100%;">
        <el-table-column align="center" prop="loanNo" label="借款编号"></el-table-column>
        <el-table-column align="center" prop="refundAmt" label="退款金额"></el-table-column>
        <el-table-column align="center" prop="refundStatusDesc" label="退款单状态"></el-table-column>
        <el-table-column align="center" prop="creator" label="创建人"></el-table-column>
        <el-table-column align="center" prop="gmtCreated" label="创建时间" :formatter="transDateFormat"></el-table-column>
        <el-table-column align="center" prop="gmtModified" label="更新时间" :formatter="transDateFormat"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" align="center" prop="customerMemo" label="退款说明"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" align="center" prop="memo" label="退款方式"></el-table-column>
      </el-table>
    </div>
    <div class="pages">
      <el-pagination
          background
          @current-change="handleCurrentChange"
          @size-change="handleSizeChange"
          :current-page.sync="form.current"
          :page-sizes="[10, 20, 50, 100]"
          :page-size="form.size"
          layout="total, sizes, prev, pager, next, jumper"
          :total="form.total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
import BlockHeader from "@/components/byh/componments/blockHeader";
import * as moment from "moment";

export default {
  name: 'RiskInfo',
  components: {
    BlockHeader
  },
  props: {
    title: {
      type: String,
      required: false,
    },
    params: {
      type: Object,
      required: true
    },
  },
  data() {
    return {
      tableStatus: [
          {text: '成功', value: "SUCCESS"},
          {text: '审核中', value: "SUBMITED"},
          {text: '失败', value: "FAIL"}
      ],
      form: {
        total: 1,
        current: 1,
        size: 10,
        // result:''
      },
      updateQueDialog: {
        visible: false,
        feedNo: '',
        feedType: '',
        feedStatus: '',
        feedContent: '',
        clientNo: '',
        creater: '',
        finishContent: '',
      },
      data: [],
      backValue:null
    }
  },
  async created() {
    if(this.params){
      const params = this.params;
      // console.log(params,'params');
      this.form.loanNo = params.loanNo;
      this.form.clientNo = params.clientNo;
      await this.init()
    }

  },
  methods: {
    headerStyle() {
      return "tableHeaderStyle";
    },
    async init() {
      const parB={
        loanNo: this.form.loanNo,
        current: this.form.current,
        size: this.form.size,
        total: this.form.total,
        clientNo:this.form.clientNo
      }
      const res = await this.$$post('/refund/selectRefund',parB);
      const {success, result} = res.data;
      // console.log(res.data,'返回的结果');
      if (success && result !== null) {
        this.data = result.records;
        this.form.total = result.total;
      }
    },
    // 合并日期
    dateCompare: function (row, column) {
      let date = row[column.property]
      if (date === undefined) {
        return ''
      }
      return moment(date).format("YYYY-MM-DD ") + row.backedTime
    },
    /*日期*/
    dateFormats: function (row, column) {
      let date = row[column.property]
      if (date === undefined) {
        return ''
      }
      return moment(date).format("YYYY-MM-DD")
    },
    handleClose() {
      this.$emit("handleClose");
    },
    //客服状态
    serviceFormat: function (row, column) {
      let status = row['feedStatus'];
      return this.$enumUtils.toMsg('FeedStatus', status);
    },
    handleCurrentChange(e) {
      this.form.current = e;
      this.init();
    },
    handleSizeChange(e) {
      this.form.size = e
      this.form.current = 1;
      this.init();
    },

  }
}
</script>

<style>
.tables{
  margin-bottom: 20px;
}
.pages {
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>
