<template><span /></template>

<script lang="ts" setup>
import { removeOutcomeFile } from '@/api/project/outcome'
import { useEmitt } from '@/logics/mitt/useEmitt'
import { Message, Modal } from '@arco-design/web-vue'
import { h } from 'vue'

const { emitter } = useEmitt()
/**
 * 删除已上传文件
 * @param id 交付物id
 * @param name 交付物名称
 */
const showRemoveModal = (id: string, name: string) => {
  const title = {
    setup() {
      return () => h('strong', '警告')
    }
  }
  const ModalContent = {
    setup() {
      return () =>
        h('span', { style: 'margin: 10px;' }, [
          h('span', `确认删除`),
          h('strong', `${name}`),
          h('span', `已上传的附件吗？`)
        ])
    }
  }
  Modal.warning({
    title: () => h(title),
    content: () => h(ModalContent),
    alignCenter: true,
    titleAlign: 'start',
    mask: true,
    maskClosable: false,
    draggable: true,
    escToClose: true,
    width: 380,
    simple: true,
    hideCancel: false,
    onOk: async () => {
      await removeOutcomeFile({ id })
      Message.success('删除成功')
      emitter.emit('get-outcome-list')
      emitter.emit('get-outcome-detail')
    }
  })
}
defineExpose({ showRemoveModal }) // 暴露子组件的方法或者数据
</script>
