<template>
  <a-modal
    :visible="visible"
    title="确认删除"
    @ok="handleConfirm"
    @cancel="handleCancel"
    @update:visible="emit('update:visible', $event)"
    ok-text="确认"
    cancel-text="取消"
  >
    <p>{{ message }}</p>
  </a-modal>
</template>

<script setup lang="ts">
interface Props {
  visible: boolean
  message?: string
}

interface Emits {
  (e: 'update:visible', value: boolean): void
  (e: 'confirm'): void
}

const props = withDefaults(defineProps<Props>(), {
  message: '确定要删除吗？',
})

const emit = defineEmits<Emits>()

const handleConfirm = () => {
  emit('confirm')
  emit('update:visible', false)
}

const handleCancel = () => {
  emit('update:visible', false)
}
</script>
