refactor: warningClose

This commit is contained in:
Thanaphon Frappet 2024-10-18 13:57:26 +07:00
parent e9c15d4555
commit 792d62b0ea
2 changed files with 11 additions and 4 deletions

View file

@ -3,7 +3,7 @@ import { useI18n } from 'vue-i18n';
import { storeToRefs } from 'pinia';
import { useQuasar } from 'quasar';
import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue';
import { dialogCheckData } from 'stores/utils';
import { dialogCheckData, dialogWarningClose } from 'stores/utils';
import { ProductTree, quotationProductTree } from './utils';
// NOTE: Import stores
@ -82,7 +82,7 @@ const employeeFormStore = useEmployeeForm();
const customerStore = useCustomerStore();
const quotationForm = useQuotationForm();
const optionStore = useOptionStore();
const { locale } = useI18n();
const { t, locale } = useI18n();
const ocrStore = useOcrStore();
const $q = useQuasar();
@ -216,7 +216,13 @@ function closeTab() {
if (quotationFormState.value.mode === 'edit') {
quotationForm.resetForm();
} else {
window.close();
dialogWarningClose(t, {
message: t('dialog.message.close'),
action: () => {
window.close();
},
cancel: () => {},
});
}
}

View file

@ -44,6 +44,7 @@ export function dialogCheckData(opts: {
export function dialogWarningClose(
t: ComposerTranslation,
opts: {
message?: string;
action?: (...args: unknown[]) => unknown;
cancel?: (...args: unknown[]) => unknown;
},
@ -53,7 +54,7 @@ export function dialogWarningClose(
icon: 'mdi-alert',
title: t('form.warning.title'),
actionText: t('dialog.action.ok'),
message: t('dialog.message.warningClose'),
message: opts.message || t('dialog.message.warningClose'),
action: async () => {
if (opts.action) opts.action();
},