From f4ac6859e3192e61ec2772379c563b29295a6a36 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Wed, 17 Sep 2025 14:07:07 +0700 Subject: [PATCH] fix: drawer before close and employee edit state --- .../03_customer-management/DrawerEmployee.vue | 1 + src/components/DrawerInfo.vue | 8 ++++++-- src/pages/03_customer-management/MainPage.vue | 6 ++++-- src/pages/03_customer-management/form.ts | 10 ++++------ 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/components/03_customer-management/DrawerEmployee.vue b/src/components/03_customer-management/DrawerEmployee.vue index c7155931..5cbdde66 100644 --- a/src/components/03_customer-management/DrawerEmployee.vue +++ b/src/components/03_customer-management/DrawerEmployee.vue @@ -1649,6 +1649,7 @@ defineEmits<{ currentFromDataEmployee.employeeOtherInfo?.statusSave === false ) { + employeeFormStore.resetFormDataEmployee(); currentFromDataEmployee.employeeOtherInfo.statusSave = true; } } diff --git a/src/components/DrawerInfo.vue b/src/components/DrawerInfo.vue index 0ce76c7b..defcb6d5 100644 --- a/src/components/DrawerInfo.vue +++ b/src/components/DrawerInfo.vue @@ -8,7 +8,7 @@ import { UndoButton, } from 'components/button'; -withDefaults( +const props = withDefaults( defineProps<{ title: string; category?: string; @@ -42,6 +42,11 @@ const drawerOpen = defineModel('drawerOpen', { const myForm = ref(); function reset() { + if (props.beforeClose) { + drawerOpen.value = props.beforeClose + ? props.beforeClose() + : !drawerOpen.value; + } if (myForm.value) { myForm.value.resetValidation(); } @@ -62,7 +67,6 @@ async function onValidationError(ref: any) { @show="show" @before-hide="reset" @hide="close" - @update:model-value="(v) => (drawerOpen = beforeClose ? beforeClose() : v)" :width="$q.screen.gt.xs ? windowSize * 0.85 : windowSize" v-model="drawerOpen" behavior="mobile" diff --git a/src/pages/03_customer-management/MainPage.vue b/src/pages/03_customer-management/MainPage.vue index af617bd4..40213880 100644 --- a/src/pages/03_customer-management/MainPage.vue +++ b/src/pages/03_customer-management/MainPage.vue @@ -288,8 +288,10 @@ async function init() { refTabCustomer.value?.openSpecificCustomer(route.query.id as string); } else if (route.query.tab === 'employee') { currentTab.value = 'employee'; - if (route.query.id) - refTabEmployee.value?.openSpecificEmployee(route.query.id as string); + setTimeout(async () => { + if (route.query.id) + refTabEmployee.value?.openSpecificEmployee(route.query.id as string); + }, 150); } if ( diff --git a/src/pages/03_customer-management/form.ts b/src/pages/03_customer-management/form.ts index e91bec85..f2ce762d 100644 --- a/src/pages/03_customer-management/form.ts +++ b/src/pages/03_customer-management/form.ts @@ -1393,12 +1393,10 @@ export const useEmployeeForm = defineStore('form-employee', () => { statusSave: true, })), ), - employeeOtherInfo: structuredClone( - { - ...payload.employeeOtherInfo, - statusSave: !!payload.employeeOtherInfo?.id ? true : false, - } || {}, - ), + employeeOtherInfo: structuredClone({ + ...(payload.employeeOtherInfo ?? {}), + statusSave: true, + }), employeeWork: structuredClone( payload.employeeWork?.length === 0 ? state.value.dialogModal