<template>
  <!-- 审核客户资料-->
  <a-modal class="commonModal custom_info_btn_check"
           title="审核客户资料"
           v-model:visible="visible"
           centered
           :maskClosable="false"
           @cancel="cancel"
           width="890px">
    <template #footer>
      <a-button key="submit"
                class="cancelBtn"
                @click="cancel">取消
      </a-button>
      <a-button key="submit"
                type="primary"
                :loading="loading"
                @click="submit">审核通过
      </a-button>
      <a-button key="submit"
                type="primary"
                :loading="loading"
                @click="refuseSubmit">审核拒绝
      </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 { QueryCustomInfoType } from '@/services/go/ermcp/customInfo/interface';
import { AuditWskhUserInfoReq, UserInfoCheckMangeReq } from '@/services/proto/accountinfo/interface';
import { getUserId } from '@/services/bus/account';
import { Modal } from 'ant-design-vue';
import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
import { auditWskhUserInfo, userInfoCheck } from '@/services/proto/accountinfo';
import Detail from '../common-detail/index.vue';
import { getLongTypeLoginID } from '@/services/bus/login';
import { QhjCustomer } from '@/services/go/ermcp/qhj/interface';

export default defineComponent({
    name: 'custom_info_btn_check',
    components: { Detail },
    props: {
        selectedRow: {
            type: Object as PropType<QhjCustomer>,
            default: {},
        },
    },
    setup(props, context) {
        const loading = ref<boolean>(false);
        const { visible, cancel } = closeModal('platinum_customer_info_unsubmit_check');
        // 审核通过
        function submit() {
            Modal.confirm({
                title: '是否确认审核通过',
                okText: '确认通过',
                cancelText: '取消',
                onOk() {
                    let reqParam: AuditWskhUserInfoReq = {
                        UserID: props.selectedRow.userid,
                        UserState: 4,
                        AuditedBy: Number(getLongTypeLoginID()),
                        AuditRemark: ""
                    };
                    requestResultLoadingAndInfo(auditWskhUserInfo, reqParam, loading, ['审核成功', '审核失败:']).then(() => {
                        cancel();
                        context.emit('refresh');
                    });
                },
                onCancel() {},
            });
        }

        // 审核拒绝
        function refuseSubmit() {
            Modal.confirm({
                title: '是否确认审核拒绝',
                okText: '审核拒绝',
                cancelText: '取消',
                onOk() {
                    let reqParam: AuditWskhUserInfoReq = {
                        UserID: props.selectedRow.userid,
                        UserState: 5,
                        AuditedBy: Number(getLongTypeLoginID()),
                        AuditRemark: ""
                    };
                    requestResultLoadingAndInfo(auditWskhUserInfo, reqParam, loading, ['审核拒绝成功', '审核拒绝失败:']).then(() => {
                        cancel();
                        context.emit('refresh');
                    });
                },
                onCancel() {},
            });
        }

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

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