<template>
  <!-- 充值审核 确认收款-->
  <a-modal class="add-custom custom-detail"
           title="确认收款"
           centered
           v-model:visible="visible"
           :maskClosable="false"
           @cancel="cancel"
           width="890px">
    <template #footer>
      <a-button key="submit"
                type="primary"
                :loading="loading"
                @click="submit">确认</a-button>
        <a-button key="cancel"
                  type="primary"
                  :loading="loading"
                  @click="cancel">关闭</a-button>
    </template>
    <CommomDetail :selectedRow="selectedRow" />
  </a-modal>
</template>
<script lang="ts">
import { defineComponent, PropType, ref } from 'vue';
import { closeModal } from '@/common/setup/modal/index';
import { QueryCustomInfoType } from '@/services/go/ermcp/customInfo/interface';
import CommomDetail from '../common-detail/index.vue';
import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
import {t2bExchConfirmBusiness} from "@/services/proto/manager";
import {t2bExchConfirmBusinessReq} from "@/services/proto/manager/interface";
import {QhjAccountOutInApply} from "@/services/go/ermcp/qhj/interface";
import {getTimeValue} from "@/utils/time";
import {getUserId} from "@/services/bus/account";
import {getLongTypeLoginID} from "@/services/bus/login";

export default defineComponent({
    name: 'platinum_recharge_review_confirm_payment',
    components: { CommomDetail },
    props: {
        selectedRow: {
            type: Object as PropType<QhjAccountOutInApply>,
            default: {},
        },
    },
    setup(props, context) {
        const { visible, cancel } = closeModal('platinum_recharge_review_confirm_payment');
        const loading = ref<boolean>(false);
        function submit() {
            let reqParams: t2bExchConfirmBusinessReq = {
                cusbankid: props.selectedRow.cusbankid, // 托管银行编号
                AccountCode: props.selectedRow.accountcode, // 资金账户(交易所的出入金，填0)
                exchticket: props.selectedRow.exchticket, // 交易所流水号（被审核的流水）
                tradedate: props.selectedRow.tradedate, // 交易日(被审业务发生的交易日）
                extoperatorid: getTimeValue(),  // 外部操作流水号
                bankticket: props.selectedRow.bankticket, // 中心流水号
                businessconfirmstatus: 1,// 审核结果 1： 通过 2： 拒绝
                businesstype: props.selectedRow.executetype === 1 ? 2 : 1,  // 交易类型 1: 入金  2：出金 3： 签约 4： 解约
                auditid: Number(getUserId())  // 审核人
            }

            requestResultLoadingAndInfo(t2bExchConfirmBusiness, reqParams, loading, ['确认收款成功', '确认收款失败:']).then(() => {
                cancel();
                context.emit('refresh');
            });
        }
        return {
            submit,
            cancel,
            visible,
            loading,
        };
    },
});
</script>
