schangxiang@126.com
2025-04-29 27ba504441037666e787ded85b4af2f65be65c17
HIAWms/web/src/components/ConfirmBox/ConfirmBox.tsx
对比新文件
@@ -0,0 +1,41 @@
import { createApp, h, ref, nextTick } from 'vue'
import BaseDialog from '@/components/BaseDialog/index.vue'
import styles from './ConfirmBox.module.scss'
export const ConfirmBox = (text: string, title = '纭') => {
  return new Promise((resolve, reject) => {
    const mountNode = document.createElement('div')
    document.body.appendChild(mountNode)
    const visible = ref(true)
    const app = createApp({
      render() {
        return h(
          BaseDialog,
          {
            modelValue: visible.value,
            'onUpdate:modelValue': (value: boolean) => {
              visible.value = value
            },
            title: title,
            width: '379px',
            onConfirm: () => {
              resolve(true)
              nextTick(() => {
                mountNode.remove()
              })
            },
            onClose: () => {
              reject(false)
              nextTick(() => {
                mountNode.remove()
              })
            },
          },
          h('div', { class: styles.deleteDialog }, text)
        )
      },
    })
    app.mount(mountNode)
  })
}