<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="selectedRow" />
  </a-modal>
</template>

<script lang="ts">
import { defineComponent, ref, PropType } from 'vue';
import { Modal } from 'ant-design-vue';
import { LoginaccountOperateReq } from '@/services/proto/accountinfo/interface';
import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
import { loginAccountOperate } from '@/services/proto/accountinfo';
import { ErmcpLoginUser } from '@/services/go/ermcp/account/interface';
import Detail from '../detail-commom-business/index.vue';
import { _closeModal } from '@/common/setup/modal/modal';

export default defineComponent({
    name: 'account_info_business_btn_cancel',
    components: { Detail },
    emits: ['cancel', 'update'],
    props: {
        selectedRow: {
            default: {},
            type: Object as PropType<ErmcpLoginUser>,
        },
    },
    setup(props, context) {
        // 控制关闭弹窗
        const { visible, cancel } = _closeModal(context);
        const loading = ref<boolean>(false);
        function submit() {
            Modal.confirm({
                title: '是否确认注销该账户',
                okText: '确认注销',
                cancelText: '取消',
                onOk() {
                    let reqParam: LoginaccountOperateReq = {
                        userid: props.selectedRow.userid,
                        loginid: props.selectedRow.loginid,
                        operatetype: 7, // 5: 锁定 6：解锁
                        logintaaccounts: [],
                    };
                    requestResultLoadingAndInfo(loginAccountOperate, reqParam, loading, ['账户注销成功', '账户注销失败:']).then(() => {
                        cancel(true);
                    });
                },
                onCancel() {},
            });
        }

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

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