<!--
 Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.

 https://www.mall4j.com/

 未经允许，不可做商业用途！

 版权所有，侵权必究！
-->
<template>
  <el-dialog
    v-model="visible"
    :close-on-click-modal="false"
    :title="$t('multishop.shopWalletLog.basicInformation')"
    class="Mall4j"
  >
    <el-form
      :model="dataForm"
      label-width="140px"
      @submit.prevent
    >
      <el-form-item :label="$t('multishop.shopWalletLog.withdrawAmount')+'：'">
        <span>{{ handlerPrice(dataForm.amount) }}</span> {{ $t('shop.yuan') }}
      </el-form-item>
      <el-form-item :label="$t('multishop.shopWalletLog.bankName')+'：'">
        <span>{{ dataForm.supplierBankCard.bankName }}</span>
      </el-form-item>
      <el-form-item :label="$t('multishop.shopWalletLog.recipientName')+'：'">
        <span>{{ dataForm.supplierBankCard.recipientName }}</span>
      </el-form-item>
      <el-form-item :label="$t('multishop.shopWalletLog.cardNo')+'：'">
        <span>{{ dataForm.supplierBankCard.cardNo }}</span>
      </el-form-item>
      <el-form-item :label="$t('multishop.shopWalletLog.branch')+'：'">
        <span>{{ dataForm.supplierBankCard.bankName }}</span>
      </el-form-item>
      <el-form-item :label="$t('multishop.shopWalletLog.supplierRemarks')+'：'">
        <span style="word-break: break-word;">{{ dataForm.supplierRemarks }}</span>
      </el-form-item>
      <el-form-item
        v-if="paySettlementType !== 1"
        :label="$t('multishop.shopWalletLog.auditStatus')+'：'"
      >
        <el-tag
          v-if="dataForm.status === -1"
          type="danger"
        >
          {{ $t('multishop.shopWalletLog.fail') }}
        </el-tag>
        <el-tag
          v-if="dataForm.status === 1"
          type="success"
        >
          {{ $t('multishop.shopWalletLog.passed') }}
        </el-tag>
        <el-tag
          v-else-if="dataForm.status === 0"
        >
          {{ $t('multishop.shopWalletLog.notApproved') }}
        </el-tag>
        <el-tag
          v-else-if="dataForm.status === 2"
          type="success"
        >
          {{ $t('multishop.shopWalletLog.IssuedSuccess') }}
        </el-tag>
        <el-tag
          v-else-if="dataForm.status === 3"
          type="error"
        >
          {{ $t('multishop.shopWalletLog.IssuedFail') }}
        </el-tag>
      </el-form-item>
      <el-form-item
        v-if="dataForm.status !== 0 && dataForm.payingAccount!==null && paySettlementType !== 1"
        :label="$t('multishop.shopWalletLog.paymentAccount')+'：'"
      >
        <span>{{ dataForm.payingAccount }}</span>
      </el-form-item>
      <el-form-item
        v-if="dataForm.status !== 0 && dataForm.payingCardNo!==null && paySettlementType !== 1"
        :label="$t('multishop.shopWalletLog.paymentAccountNo')+'：'"
      >
        <span>{{ dataForm.payingCardNo }}</span>
      </el-form-item>
      <el-form-item
        v-if="dataForm.status !== 0 && dataForm.payingTime!==null && paySettlementType !== 1"
        :label="$t('multishop.shopWalletLog.paymentDate')+'：'"
      >
        <span>{{ dataForm.payingTime }}</span>
      </el-form-item>
      <el-form-item
        v-if="dataForm.status !== 0 && paySettlementType !== 1"
        :label="$t('multishop.shopWalletLog.platformRemarks')+'：'"
      >
        <span style="word-break: break-word;">{{ dataForm.remarks }}</span>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script setup>
import Big from 'big.js'
import { useAllinpayStore } from '@/stores/modules/allinpay.js'

const paySettlementType = reactive(useAllinpayStore.paySettlementType) // 是否开启通联支付 1：开启 0：关闭
const visible = ref(false)
let dataForm = {
  status: 0,
  payingAccount: '', // 付款户名
  payingCardNo: '', // 付款账号
  payingTime: '', // 付款日期
  supplierBankCard: {} // 银行的信息
}

const init = (rowData) => {
  dataForm = Object.assign({}, rowData)
  dataForm.supplierBankCard = Object.assign({}, rowData.supplierBankCardVO)
  if (dataForm.payingTime) {
    dataForm.payingTime = dataForm.payingTime.substr(0, 10)
  }
  visible.value = true
}

defineExpose({ init })
/**
 * 精度运算-过滤
 */
const handlerPrice = (val) => {
  if (val == null) {
    return ''
  }
  // (val / 100).toFixed(2)
  return new Big(val).div(100).toFixed(2)
}

</script>
