| | |
| | | import { createApp, h, ref, nextTick } from 'vue' |
| | | 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' |
| | | export const ConfirmBox = (text: string, title = '确认') => { |
| | | 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 h( |
| | | return RenderProvider( |
| | | h( |
| | | BaseDialog, |
| | | { |
| | | class: styles.ConfirmBox, |
| | | modelValue: visible.value, |
| | | 'onUpdate:modelValue': (value: boolean) => { |
| | | visible.value = value |
| | | }, |
| | | title: title, |
| | | title: _t(title), |
| | | width: '379px', |
| | | onConfirm: () => { |
| | | resolve(true) |
| | |
| | | mountNode.remove() |
| | | }) |
| | | }, |
| | | ...attrs, |
| | | }, |
| | | h('div', { class: styles.deleteDialog }, text) |
| | | { |
| | | default: h('div', { class: styles.confirmDialog }, text), |
| | | footer: attrs.footer ? attrs.footer : null, |
| | | } |
| | | ) |
| | | ) |
| | | }, |
| | | }) |