<template>
  <!-- 注销账户 -->
  <a-modal class="add-custom"
           title="注销账户"
           v-model:visible="visible"
           @cancel="cancel"
           centered
           :maskClosable="false"
           width="890px">
    <template #footer>
      <a-button key="submit"
                type="primary"
                :loading="loading"
                @click="cancel">取消
      </a-button>
      <a-button key="submit"
                type="primary"
                :loading="loading"
                @click="submit">注销
      </a-button>
    </template>
    <Detail :selectedData="selectedData"
            :userList="userList"
            :secondeData="secondeData" />
  </a-modal>
</template>

<script lang="ts">
import { closeModal } from '@/common/setup/modal/index';
import { defineComponent, ref, PropType } from 'vue';
import { Modal } from 'ant-design-vue';
import { TaaccountOperateReq } from '@/services/proto/accountinfo/interface';
import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
import { taAccountOperateReq } from '@/services/proto/accountinfo';
import { ErmcpLoginUserEx, ErmcpTaAccount, ErmcpTaAccountEx } from '@/services/go/ermcp/account/interface';
import { getLongTypeLoginID } from '@/services/bus/login';
import Detail from '../detail-commom-futures/index.vue';
export default defineComponent({
    name: 'account_info_futures_btn_child_cancel',
    components: { Detail },
    props: {
        selectedData: {
            type: Object as PropType<ErmcpTaAccountEx>,
            default: {},
        },
        secondeData: {
            default: {},
            type: Object as PropType<ErmcpTaAccount>,
        },
        userList: {
            type: Array as PropType<ErmcpLoginUserEx[]>,
            default: [],
        },
    },
    setup(props, context) {
        // 控制关闭弹窗
        const { visible, cancel } = closeModal('account_info_futures_btn_child_cancel');
        const loading = ref<boolean>(false);

        function submit() {
            Modal.confirm({
                title: '是否确认注销该账户',
                okText: '确认注销',
                cancelText: '取消',
                onOk() {
                    let reqParam: TaaccountOperateReq = {
                        accountid: props.secondeData.accountid, // uint64 期货账户ID
                        tradestatus: 7, // uint32 7注销
                        modifierid: Number(getLongTypeLoginID()), // uint64 修改人
                        areauserid: Number(props.secondeData.relateduserid), // uint64 机构用户ID
                    };
                    requestResultLoadingAndInfo(taAccountOperateReq, reqParam, loading, ['账户注销成功', '账户注销失败:']).then(() => {
                        cancel();
                        context.emit('refresh');
                    });
                },
                onCancel() {},
            });
        }

        return {
            visible,
            cancel,
            submit,
            loading,
        };
    },
});
</script>

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