<template>
  <div style="padding: 2em 1em" v-loading="loading">
    <el-descriptions title="申请信息" :column="2">
      <el-descriptions-item label="提现单号">{{detail.billNo | defaultValue}}</el-descriptions-item>
      <el-descriptions-item label="状态">
        <dict-tag :value="detail.status" :options="dict.type.withdraw_status" size="small"/>
      </el-descriptions-item>
      <el-descriptions-item label="申请时间">{{detail.createTime | defaultValue}}</el-descriptions-item>
      <el-descriptions-item label="提现方式">
        <dict-tag :value="detail.channelId" :options="dict.type.channel_type" size="small"/>
      </el-descriptions-item>
      <el-descriptions-item label="提现金额">{{detail.money | money | defaultValue}} 元</el-descriptions-item>
      <el-descriptions-item label="到账金额">{{detail.arrivalAmount | money | defaultValue}} 元</el-descriptions-item>
      <el-descriptions-item label="余额">{{detail.afterBalance | money | defaultValue}} 元</el-descriptions-item>
      <el-descriptions-item label="服务费">{{detail.serviceCharge | money | defaultValue}} 元</el-descriptions-item>
    </el-descriptions>

    <el-descriptions title="审核信息" :column="2" style="margin-top: 1em;">
      <el-descriptions-item label="审核意见" :span="4">{{detail.remark | defaultValue}}</el-descriptions-item>
      <el-descriptions-item label="打款方式">
        <dict-tag :value="detail.withdrawType" :options="dict.type.withdraw_type" size="small"/>
      </el-descriptions-item>
      <el-descriptions-item label="到账时间">{{detail.payTime | defaultValue}}</el-descriptions-item>
      <el-descriptions-item label="线下支付凭证" :span="2">
        <image-preview :src="detail.payPicture" :width="32" :height="32"/>
      </el-descriptions-item>
    </el-descriptions>

  </div>
</template>

<script>
import { mchGetBill } from '@/api/mch/bill'
import { mchGetWithdraw } from '@/api/mch/withdraw'

export default {
  name: 'MchWithdrawDetail',
  dicts: ['channel_type','withdraw_status', 'withdraw_type'],
  props: {
    id: {
      type: String,
      default: null,
    }
  },
  data() {
    return {
      loading: false,
      detail: {},
      suitUsingType: ['info', 'warning', 'success', 'danger'],
      suitUsingText: ['未知', '未生效', '使用中', '已失效']
    }
  },
  watch: {
    id(nv, ov) {
      console.log("id", nv)
      if (nv == null) {
        this.detail = {}
      } else {
        this.getDetail(nv);
      }
    }
  },
  created() {
    this.getDetail(this.id);
  },
  methods: {
    getDetail(id) {
      this.loading = true;
      mchGetWithdraw(id).then(res => {
        this.detail = res.data;
      }).finally(() => {
        this.loading = false;
      })
    }
  }
}
</script>
