<template>
  <!-- 删除现货合同--->
  <a-modal class="recover-custom commonModal addSpotVariety"
           title="删除现货合同"
           v-model:visible="visible"
           centered
           :maskClosable="false"
           @cancel="cancel"
           width="890px">
    <template #footer>
      <a-button key="submit"
                class="cancelBtn"
                :loading="loading"
                :disabled="loading"
                @click="cancel">取消</a-button>
      <a-button key="submit"
                type="primary"
                :loading="loading"
                :disabled="loading"
                @click="submit">确认删除</a-button>
    </template>
    <InfoDetail :selectedRow="selectedRow" />

  </a-modal>
</template>

<script lang="ts">
import { defineComponent, PropType, ref } from 'vue';
import { Ermcp3ContractRsp } from '@/services/go/ermcp/spot-contract/interface';
import { Modal } from 'ant-design-vue';
import { orderContractControl } from '@/views/information/spot-contract/components/setup';
import { GldErmcpSpotContractOperateReq } from '@/services/proto/spotcontract/interface';
import InfoDetail from '../infoDetail/index.vue';
import { _closeModal } from '@/common/setup/modal/modal';

export default defineComponent({
    name: 'delete-spot-contract',
    components: {
        InfoDetail,
    },
    emits: ['cancel', 'update'],
    props: {
        selectedRow: {
            type: Object as PropType<Ermcp3ContractRsp>,
            default: {},
        },
    },
    setup(props, context) {
        const { visible, cancel } = _closeModal(context);
        const loading = ref<boolean>(false);
        const maskClosableFlag = ref<boolean>(false);
        // 获取 业务账户
        function submit() {
            Modal.confirm({
                title: '是否确认删除',
                okText: '确认删除',
                cancelText: '取消',
                onOk() {
                    let params: GldErmcpSpotContractOperateReq = {
                        SpotContractID: props.selectedRow.spotcontractid,
                        OperateType: 3,
                        Remark: '',
                    };
                    // 删除客户资料
                    orderContractControl(params, loading)
                        .then((res) => {
                            // 通知上层  刷新数据
                            cancel(true);
                        })
                        .catch((err) => {});
                },
                onCancel() {},
            });
        }
        return {
            visible,
            cancel,
            submit,
            loading,
            maskClosableFlag,
        };
    },
});
</script>

<style lang="less">
.recover-custom {
}
</style
>;
