<template>
  <!-- 交收-->
  <div>
  </div>
</template>

<script lang="ts">
import { defineComponent, PropType, ref } from 'vue';
import Drawer from '@/common/components/drawer/index.vue';
import { WrPerformancePlan, WrPosition } from '@/services/go/wrtrade/interface';
import { ModalEnum } from '@/common/constants/modalNameEnum';
import { _closeModal } from '@/common/setup/modal/modal';
import { PerformanceActivateReq, PerformanceDelayApplyReq } from '@/services/proto/performance/interface';
import { getAccount_longType, getSelectedAccountId, getUserId } from '@/services/bus/account';
import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
import { performanceActivate, performanceContractedApply } from '@/services/proto/performance';
import { BuyOrSell } from '@/common/constants/enumCommon';
import { handlePerformancePlanStep } from '../setup';
import { Modal } from 'ant-design-vue';
import Long from "long";

export default defineComponent({
    name: ModalEnum.performance_information_buy_performance_settlement,
    components: { Drawer },
    emits: ['cancel', 'update'],
    props: {
        selectedRow: {
            type: Object as PropType<WrPerformancePlan>,
            default: {},
        },
        buyOrSell: {
            type: Number as PropType<BuyOrSell>,
            default: BuyOrSell.buy,
        },
    },
    setup(props, context) {
        const { visible, cancel } = _closeModal(context);
        const loading = ref<boolean>(false);
        const { performancePlanStep } = handlePerformancePlanStep(props.selectedRow);
        Modal.confirm({
            title: '交收',
            content: '是否确认交收！',
            onOk: submit,
            onCancel: cancel,
        });
        function submit() {
            // 激活接口 (就是交收)
            const paramReq: PerformanceActivateReq = {
                PerformancePlanID: Long.fromString(props.selectedRow.performanceplanid), // uint64 履约计划ID
                ApplyAccountID: getSelectedAccountId(), // uint64 发起方账号ID
            };
            requestResultLoadingAndInfo(performanceActivate, paramReq, loading, ['交收成功', '交收失败:']).then(() => {
                cancel(true);
            });
        }
        return {
            visible,
            cancel,
            submit,
            loading,
        };
    },
});
</script>

<style lang="less" scoped>
</style>;
