<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="submit">锁定</a-button>
    </template>
    <Detail :firstBtnData="firstBtnData"
            :selectedData="selectedData" />
  </a-modal>
</template>

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

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

<style lang="less">
.add-custom {
    .checkboxGroupItem {
        .ant-row {
            .ant-col.ant-col-12 {
                white-space: nowrap;
                min-width: 356px;
            }
        }
    }
}
</style
>;
