<template>
  <!-- 停用客户资料-->
  <a-modal class="commonModal warehouse-disable"
           title="停用客户资料"
           v-model:visible="visible"
           centered
           :maskClosable="false"
           @cancel="cancel"
           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 { 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';

export default defineComponent({
    name: 'custom-disable',
    components: { Detail },
    props: {
        selectedRow: {
            type: Object as PropType<QueryCustomInfoType>,
            default: {},
        },
    },
    setup(props, context) {
        const { visible, cancel } = closeModal('custom_info_btn_disable');
        const maskClosableFlag = ref<boolean>(false);
        const loading = ref<boolean>(false);

        function submit() {
            Modal.confirm({
                title: '是否确认停用客户资料',
                okText: '确认停用',
                cancelText: '取消',
                onOk() {
                    let reqParams: UpdateUserAccountReq = {
                        userID: props.selectedRow.userid,
                        accountStatus: 6,
                    };
                    requestResultLoadingAndInfo(UpdateUserAccountStatus, reqParams, loading, ['停用成功', '停用失败:']).then(() => {
                        cancel();
                        context.emit('refresh');
                    });
                },
                onCancel() {},
            });
        }

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

<style lang="less">
.warehouse-disable {
}
</style>
