<template>
    <a-popconfirm :title="title" ok-text="确认" cancel-text="取消" @confirm="confirm">
        <a>{{ label }}</a>
    </a-popconfirm>
</template>

<script>
import { EMPTY_FUN } from '@/utils';
import { delReq } from '@/utils';

export default {
    props: {
        url: String,
        cb: {
            type: Function,
            default: EMPTY_FUN,
        },
        title: {
            type: String,
            default: '确认是否删除',
        },
        onOk: {
            type: Function,
            default: EMPTY_FUN,
        },
        label: {
            type: String,
            default: '删除',
        },
    },
    methods: {
        async confirm() {
            if (this.url) {
                await delReq(this.url);
            }
            if (this.onOk) {
                await this.onOk();
            }
            this?.cb();
        },
    },
};
</script>
