<template>
  <!-- 恢复客户资料-->
  <a-modal class="commonModal warehouse-disable"
           title="恢复客户资料"
           v-model:visible="visible"
           @cancel="cancel"
           centered
           width="890px">
    <template #footer>
      <a-button key="submit"
                class="cancelBtn"
                @click="cancel">取消
      </a-button>
      <a-button key="submit"
                type="primary"
                :loading="loading"
                @click="recover">完成
      </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, UpdateUserAccountReq } from '@/services/go/ermcp/customInfo/interface';
import { Modal } from 'ant-design-vue';
import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
import { UpdateUserAccountStatus } from '@/services/go/ermcp/customInfo';
import Detail from '../common-detail/index.vue';
import { QhjCustomer } from '@/services/go/ermcp/qhj/interface';

export default defineComponent({
    name: 'modify-custom',
    components: { Detail },
    props: {
        selectedRow: {
            type: Object as PropType<QhjCustomer>,
            default: {},
        },
    },
    setup(props, context) {
        const { visible, cancel } = closeModal('platinum_customer_info_stop_resume');
        const loading = ref<boolean>(false);
        // 恢复方法
        function recover() {
            Modal.confirm({
                title: '是否确认恢复客户资料',
                okText: '确认恢复',
                cancelText: '取消',
                onOk() {
                    let reqParams: UpdateUserAccountReq = {
                        userID: props.selectedRow.userid,
                        accountStatus: 4,
                    };
                    requestResultLoadingAndInfo(UpdateUserAccountStatus, reqParams, loading, ['恢复成功', '恢复失败:']).then(() => {
                        cancel();
                        context.emit('refresh');
                    });
                },
                onCancel() {},
            });
        }
        return {
            visible,
            cancel,
            recover,
            loading,
        };
    },
});
</script>

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