|
@@ -92,15 +92,17 @@ function handleConfirm() {
|
|
isConfirm.value = true;
|
|
isConfirm.value = true;
|
|
emits('confirm');
|
|
emits('confirm');
|
|
}
|
|
}
|
|
|
|
+
|
|
function handleCancel() {
|
|
function handleCancel() {
|
|
- open.value = false;
|
|
|
|
|
|
+ isConfirm.value = false;
|
|
}
|
|
}
|
|
|
|
+
|
|
const loading = ref(false);
|
|
const loading = ref(false);
|
|
async function handleOpenChange(val: boolean) {
|
|
async function handleOpenChange(val: boolean) {
|
|
if (!val && props.beforeClose) {
|
|
if (!val && props.beforeClose) {
|
|
loading.value = true;
|
|
loading.value = true;
|
|
try {
|
|
try {
|
|
- const res = await props.beforeClose();
|
|
|
|
|
|
+ const res = await props.beforeClose({ isConfirm: isConfirm.value });
|
|
if (res !== false) {
|
|
if (res !== false) {
|
|
open.value = false;
|
|
open.value = false;
|
|
}
|
|
}
|
|
@@ -141,6 +143,7 @@ async function handleOpenChange(val: boolean) {
|
|
size="icon"
|
|
size="icon"
|
|
class="rounded-full"
|
|
class="rounded-full"
|
|
:disabled="loading"
|
|
:disabled="loading"
|
|
|
|
+ @click="handleCancel"
|
|
>
|
|
>
|
|
<X class="text-muted-foreground size-4" />
|
|
<X class="text-muted-foreground size-4" />
|
|
</VbenButton>
|
|
</VbenButton>
|
|
@@ -154,22 +157,20 @@ async function handleOpenChange(val: boolean) {
|
|
<VbenLoading v-if="loading" :spinning="loading" />
|
|
<VbenLoading v-if="loading" :spinning="loading" />
|
|
</AlertDialogDescription>
|
|
</AlertDialogDescription>
|
|
<div class="flex justify-end gap-x-2">
|
|
<div class="flex justify-end gap-x-2">
|
|
- <AlertDialogCancel
|
|
|
|
- v-if="showCancel"
|
|
|
|
- @click="handleCancel"
|
|
|
|
- :disabled="loading"
|
|
|
|
- >
|
|
|
|
|
|
+ <AlertDialogCancel v-if="showCancel" :disabled="loading">
|
|
<component
|
|
<component
|
|
:is="components.DefaultButton || VbenButton"
|
|
:is="components.DefaultButton || VbenButton"
|
|
variant="ghost"
|
|
variant="ghost"
|
|
|
|
+ @click="handleCancel"
|
|
>
|
|
>
|
|
{{ cancelText || $t('cancel') }}
|
|
{{ cancelText || $t('cancel') }}
|
|
</component>
|
|
</component>
|
|
</AlertDialogCancel>
|
|
</AlertDialogCancel>
|
|
- <AlertDialogAction @click="handleConfirm">
|
|
|
|
|
|
+ <AlertDialogAction>
|
|
<component
|
|
<component
|
|
:is="components.PrimaryButton || VbenButton"
|
|
:is="components.PrimaryButton || VbenButton"
|
|
:loading="loading"
|
|
:loading="loading"
|
|
|
|
+ @click="handleConfirm"
|
|
>
|
|
>
|
|
{{ confirmText || $t('confirm') }}
|
|
{{ confirmText || $t('confirm') }}
|
|
</component>
|
|
</component>
|