<template>
  <!-- 撤销客户资料-->
  <a-modal class="commonModal custom_info_btn_cancel"
           title="撤销客户资料"
           v-model:visible="visible"
           @cancel="cancel"
           centered
           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>
    <Detail :selectedRow="selectedRow" />
  </a-modal>
</template>

<script lang="ts">
import { defineComponent, PropType, ref } from 'vue';
import { closeModal } from '@/common/setup/modal/index';
import { Modal } from 'ant-design-vue';
import { ModifyUserInfoReq, QueryCustomInfoType } from '@/services/go/ermcp/customInfo/interface';
import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
import { QueryModifyUserInfo } from '@/services/go/ermcp/customInfo';
import Detail from '../common-detail/index.vue';

export default defineComponent({
    name: 'custom_info_btn_cancel',
    components: { Detail },
    props: {
        selectedRow: {
            type: Object as PropType<QueryCustomInfoType>,
            default: {},
        },
    },
    setup(props, context) {
        const { visible, cancel } = closeModal('custom_info_btn_cancel');
        const loading = ref<boolean>(false);
        function submit() {
            loading.value = true;
            Modal.confirm({
                title: '是否确认撤销客户资料',
                content: '是否撤销',
                okText: '确认撤销',
                cancelText: '取消',
                onOk() {
                    const reqParam: ModifyUserInfoReq = {
                        userid: props.selectedRow.userid, //用户ID
                        userstate: 1, //开户状态 - 1:未提交 2: 待初审 3:初审拒绝 4:待复审 5:复审拒绝 6:测评不通过 (必填)
                    };
                    requestResultLoadingAndInfo(QueryModifyUserInfo, reqParam, loading, ['撤销成功', '撤销失败:']).then(() => {
                        cancel();
                        context.emit('refresh');
                    });
                },
                onCancel() {
                    loading.value = false;
                },
                class: 'test',
            });
        }

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

<style lang="less">
.custom_info_btn_cancel {
    .upload {
        .look {
            margin-left: 0;
        }
    }
}
</style
>;
