<template>
  <a-drawer
    v-model:visible="vdata.visible"
    :title=" true ? '提现单详情' : '' "
    :body-style="{ paddingBottom: '80px' }"
    width="40%"
    @close="onClose"
  >
    <a-row justify="space-between" type="flex">
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="提现单号">
            {{ vdata.detailData.rid }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="支付接口">
            {{ vdata.detailData.ifCode }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="用户号">
            {{ vdata.detailData.mchNo }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="用户名称">
            {{ vdata.detailData.mchName }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="应用APPID">
            {{ vdata.detailData.appId }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="服务商号">
            {{ vdata.detailData.isvNo }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="提现金额">
            {{ (vdata.detailData.cashoutAmount/100).toFixed(2) }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="提现前余额">
            {{ (vdata.detailData.currentBalance/100).toFixed(2) }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="提现状态">
            {{ vdata.detailData.state == 0 ? '提现单创建' : vdata.detailData.state == 1 ? '提现中' : vdata.detailData.state == 2 ? '提现成功' : vdata.detailData.state == 3 ? '提现失败' : '未知' }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="渠道提现单ID">
            {{ vdata.detailData.channelRid }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="渠道子商户号">
            {{ vdata.detailData.channelSubMchId }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col v-if="vdata.detailData.payOrderId" :sm="12">
        <a-descriptions>
          <a-descriptions-item label="支付订单号">
            {{ vdata.detailData.payOrderId }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col v-if="vdata.detailData.successTime" :sm="12">
        <a-descriptions>
          <a-descriptions-item label="提现成功时间">
            {{ vdata.detailData.successTime }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col v-if="vdata.detailData.bankName" :sm="12">
        <a-descriptions>
          <a-descriptions-item label="提现银行名称">
            {{ vdata.detailData.bankName }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col v-if="vdata.detailData.bankAccount" :sm="12">
        <a-descriptions>
          <a-descriptions-item label="提现银行账户">
            {{ vdata.detailData.bankAccount }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col v-if="vdata.detailData.bankAccountName" :sm="12">
        <a-descriptions>
          <a-descriptions-item label="提现银行账户名称">
            {{ vdata.detailData.bankAccountName }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col v-if="vdata.detailData.createdUid" :sm="12">
        <a-descriptions>
          <a-descriptions-item label="创建者用户ID">
            {{ vdata.detailData.createdUid }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col v-if="vdata.detailData.createdBy" :sm="12">
        <a-descriptions>
          <a-descriptions-item label="创建人名称">
            {{ vdata.detailData.createdBy }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="创建时间">
            {{ vdata.detailData.createdAt }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="更新时间">
            {{ vdata.detailData.updatedAt }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col v-if="vdata.detailData.failInfo" :sm="24">
        <a-form-item label="提现失败原因">
          <a-textarea
            v-model:value="vdata.detailData.failInfo"
            disabled="disabled"
            :rows="3"
          />
        </a-form-item>
      </a-col>
    </a-row>
  </a-drawer>
</template>

<script lang="ts" setup>
import { ENT_MCH_CHANNEL_ACCOUNT, req } from '@/api/manage'
import {reactive} from 'vue'
import dateUtil from '@/utils/dateUtil.js'

const vdata:any = reactive({
  btnLoading: false,
  detailData: {}, // 数据对象
  recordId: null, // 更新对象ID
  visible: false, // 是否显示弹层/抽屉
})

function show (recordId) { // 弹层打开事件
  
  vdata.recordId = recordId
  req.getById(ENT_MCH_CHANNEL_ACCOUNT, recordId).then(res => {
    vdata.detailData = res
  })
  vdata.visible = true
}
function onClose () {
  vdata.visible = false
}

defineExpose({
  show //抛出show函数给父组件
})
</script>
