<template>
  <a-modal
    centered
    class="financialPaymentDetail-modal"
    :footer="null"
    :maskClosable="false"
    title="凭证"
    v-model="isShow"
    @cancel="isShow=false"
    :width="600">
    <!-- 详情 -->
    <div v-if="detailsData">
      <a-descriptions :column="1" size="default">
        <a-descriptions-item label="收款单号">{{ detailsData.settleNo || '--' }}</a-descriptions-item>
        <a-descriptions-item label="关联单号">{{ detailsData.bizNo || '--' }}</a-descriptions-item>
        <a-descriptions-item label="商户名称" v-if="detailsData.settleClientType&&detailsData.settleClientType=='CUSTOMER'">{{ detailsData.settleClientNameCurrent || '--' }}{{ detailsData.settleClientName?detailsData.settleClientName==detailsData.settleClientNameCurrent?'':'（'+detailsData.settleClientName+'）':'' }}</a-descriptions-item>
        <a-descriptions-item label="商户名称" v-else>{{ detailsData.settleClientName ||'--' }}</a-descriptions-item>
        <a-descriptions-item label="收款金额">{{ detailsData.settledAmount || detailsData.settledAmount==0 ? toThousands(detailsData.settledAmount) : '--' }}</a-descriptions-item>
        <a-descriptions-item label="收款类型">{{ detailsData.bizTypeDictValue || '--' }}</a-descriptions-item>
        <a-descriptions-item label="收款方式">{{ detailsData.settleStyleSnDictValue || '--' }}</a-descriptions-item>
        <a-descriptions-item label="收款时间">{{ detailsData.settleTime || '--' }}</a-descriptions-item>
        <a-descriptions-item label="审核时间">{{ detailsData.auditTime || '--' }}</a-descriptions-item>
        <template v-if="detailsData.refundType&&(detailsData.refundType=='WECHAT_PAY'||detailsData.refundType=='RECHARGE_BALANCE')">
          <a-descriptions-item label="退款金额">{{ detailsData.refundAmount || '--' }}</a-descriptions-item>
          <a-descriptions-item label="退款时间">{{ detailsData.refundData || '--' }}</a-descriptions-item>
          <a-descriptions-item label="退款方式">{{ detailsData.refundTypeDictValue || '--' }}{{ detailsData.refundTypeDictValue?'(1-3个工作日到账)':'' }}</a-descriptions-item>
        </template>
      </a-descriptions>
      <div class="btn-cont"><a-button id="financialPaymentDetail-modal-back" @click="isShow = false">关闭</a-button></div>
    </div>
  </a-modal>
</template>

<script>
import { commonMixin } from '@/utils/mixin'
import { findReceiptDetail } from '@/api/settleReceipt'
export default {
  name: 'FinancialPaymentDetailModal',
  mixins: [commonMixin],
  props: {
    openModal: { //  弹框显示状态
      type: Boolean,
      default: false
    },
    itemId: {// 单据id
      type: [Number, String],
      default: ''
    }
  },
  data () {
    return {
      isShow: this.openModal, //  是否打开弹框
      detailsData: null // 详情数据
    }
  },
  methods: {
    //  获取详情
    getDetail (id) {
      findReceiptDetail({ id: id }).then(res => {
        if (res.status == 200) {
          this.detailsData = res.data
        } else {
          this.detailsData = null
        }
      })
    }
  },
  watch: {
    //  父页面传过来的弹框状态
    openModal (newValue, oldValue) {
      this.isShow = newValue
    },
    //  重定义的弹框状态
    isShow (newValue, oldValue) {
      if (!newValue) {
        this.$emit('close')
        this.detailsData = null
      }
    }
  }
}
</script>

<style lang="less">
  .financialPaymentDetail-modal{
    .ant-modal-body {
      padding: 40px 40px 24px;
    }
    .btn-cont {
      text-align: center;
      margin: 35px 0 10px;
    }
  }
</style>
