zs
2025-06-04 5a149d626ae8bc3fa4bddbb53f8caf40f51f6da6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { createApp, h, ref, nextTick, Component } from 'vue'
import BaseDialog from '@/components/BaseDialog/index.vue'
import { ElConfigProvider } from 'element-plus'
import styles from './ConfirmBox.module.scss'
import { _t } from '@/libs/Language/Language'
export const ConfirmBox = (
  text: string | any,
  title = '确认',
  attrs: any = {}
) => {
  return new Promise((resolve, reject) => {
    const mountNode = document.createElement('div')
    document.body.appendChild(mountNode)
 
    const visible = ref(true)
    const RenderProvider = (Widget: any) => {
      return (
        <el-config-provider namespace="cs">
          <Widget />
        </el-config-provider>
      )
    }
    const app = createApp({
      render() {
        return RenderProvider(
          h(
            BaseDialog,
            {
              class: styles.ConfirmBox,
              modelValue: visible.value,
              'onUpdate:modelValue': (value: boolean) => {
                visible.value = value
              },
              title: _t(title),
              width: '379px',
              onConfirm: () => {
                resolve(true)
                nextTick(() => {
                  mountNode.remove()
                })
              },
              onClose: () => {
                reject(false)
                nextTick(() => {
                  mountNode.remove()
                })
              },
              ...attrs,
            },
            {
              default: h('div', { class: styles.confirmDialog }, text),
              footer: attrs.footer ? attrs.footer : null,
            }
          )
        )
      },
    })
 
    app.mount(mountNode)
  })
}