feat: add before close function

This commit is contained in:
Methapon2001 2024-08-06 08:56:06 +07:00
parent 97e234a225
commit 6364fbd4ab
2 changed files with 13 additions and 3 deletions

View file

@ -34,7 +34,7 @@ const props = withDefaults(
employee?: boolean;
employeeOwnerOption?: CustomerBranch[];
prefixId: string;
showBtnSave: boolean;
showBtnSave?: boolean;
}>(),
{
showBtnSave: false,

View file

@ -29,13 +29,18 @@ defineProps<{
submit?: (...args: unknown[]) => void;
close?: (...args: unknown[]) => void;
undo?: (...args: unknown[]) => void;
beforeClose?: (...args: unknown[]) => boolean;
}>();
const modal = defineModel('modal', { default: false });
const currentTab = defineModel<string>('currentTab');
</script>
<template>
<q-dialog v-model="modal" @hide="close" @before-show="show">
<q-dialog
:model-value="modal"
@update:model-value="(v) => (modal = beforeClose ? beforeClose() : v)"
@before-show="show"
>
<div
class="surface-1"
style="padding: 0; border-radius: var(--radius-2); height: 100%"
@ -129,7 +134,12 @@ const currentTab = defineModel<string>('currentTab');
padding="xs"
class="close-btn"
:class="{ dark: $q.dark.isActive }"
@click="close"
@click="
() => {
modal = beforeClose ? beforeClose() : !modal;
close?.();
}
"
/>
</div>
</div>