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
| 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)
| })
| }
|
|