From e969db16e011bad8529152cca016e05387899e56 Mon Sep 17 00:00:00 2001 From: Thanaphon Frappet Date: Thu, 3 Oct 2024 17:35:56 +0700 Subject: [PATCH] refactor: add tab passport --- .../FormEmployeePassport.vue | 331 ++++++++++-------- src/pages/03_customer-management/MainPage.vue | 199 ++++++++++- src/pages/03_customer-management/form.ts | 122 +++++++ 3 files changed, 505 insertions(+), 147 deletions(-) diff --git a/src/components/03_customer-management/FormEmployeePassport.vue b/src/components/03_customer-management/FormEmployeePassport.vue index 4b9f4c8e..1c719756 100644 --- a/src/components/03_customer-management/FormEmployeePassport.vue +++ b/src/components/03_customer-management/FormEmployeePassport.vue @@ -32,7 +32,9 @@ defineProps<{ outlined?: boolean; readonly?: boolean; separator?: boolean; + img?: string; ocr?: boolean; + hideTitle?: boolean; prefixId: string; }>(); @@ -86,7 +88,10 @@ watch( diff --git a/src/pages/03_customer-management/MainPage.vue b/src/pages/03_customer-management/MainPage.vue index b5920259..e1093396 100644 --- a/src/pages/03_customer-management/MainPage.vue +++ b/src/pages/03_customer-management/MainPage.vue @@ -5,6 +5,7 @@ import { useQuasar } from 'quasar'; import { useRoute, useRouter } from 'vue-router'; import { getUserId, getRole } from 'src/services/keycloak'; import { baseUrl, waitAll } from 'src/stores/utils'; +import { dateFormat } from 'src/utils/datetime'; import useOcrStore from 'stores/ocr'; import useCustomerStore from 'stores/customer'; @@ -473,7 +474,7 @@ async function toggleStatusCustomer(id: string, status: boolean) { async function deleteEmployeeById(opts: { id?: string; - type?: 'healthCheck' | 'work'; + type?: 'passport' | 'healthCheck' | 'work'; }) { dialog({ color: 'negative', @@ -483,6 +484,10 @@ async function deleteEmployeeById(opts: { persistent: true, message: t('dialog.message.confirmDelete'), action: async () => { + if (opts.type === 'passport') { + await employeeFormStore.deletePassport(); + } + if (opts.type === 'healthCheck') { await employeeFormStore.deleteHealthCheck(); } @@ -1286,6 +1291,25 @@ const emptyCreateDialog = ref(false); + + {{ + locale === 'eng' + ? `${props.row.branch[0].addressEN}, ${props.row.branch[0].mooEN && `${$t('form.moo')} ${props.row.branch[0].mooEN},`} ${props.row.branch[0].soiEN && `${$t('form.soi')} ${props.row.branch[0].soiEN},`} ${props.row.branch[0].moo && `${props.row.branch[0].streetEN} Rd,`} ${props.row.branch[0].subDistrict.nameEN}, ${props.row.branch[0].district.nameEN}, ${props.row.branch[0].province.nameEN} ${props.row.branch[0].subDistrict.zipCode}` || + '-' + : `${props.row.branch[0].address}, ${props.row.branch[0].moo && `${$t('form.moo')} ${props.row.branch[0].moo},`} ${props.row.branch[0].soi && `${$t('form.soi')} ${props.row.branch[0].soi},`} ${props.row.branch[0].street && `${$t('form.road')} ${props.row.branch[0].street},`} ${props.row.branch[0].subDistrict.name}, ${props.row.branch[0].district.name}, ${props.row.branch[0].province.name} ${props.row.branch[0].subDistrict.zipCode}` || + '-' + }} + + {{ + locale === 'eng' + ? `${props.row.branch[0].addressEN}, ${props.row.branch[0].mooEN && `${$t('form.moo')} ${props.row.branch[0].mooEN},`} ${props.row.branch[0].soiEN && `${$t('form.soi')} ${props.row.branch[0].soiEN},`} ${props.row.branch[0].moo && `${props.row.branch[0].streetEN} Rd,`} ${props.row.branch[0].subDistrict.nameEN}, ${props.row.branch[0].district.nameEN}, ${props.row.branch[0].province.nameEN} ${props.row.branch[0].subDistrict.zipCode}` || + '-' + : `${props.row.branch[0].address}, ${props.row.branch[0].moo && `${$t('form.moo')} ${props.row.branch[0].moo},`} ${props.row.branch[0].soi && `${$t('form.soi')} ${props.row.branch[0].soi},`} ${props.row.branch[0].street && `${$t('form.road')} ${props.row.branch[0].street},`} ${props.row.branch[0].subDistrict.name}, ${props.row.branch[0].district.name}, ${props.row.branch[0].province.name} ${props.row.branch[0].subDistrict.zipCode}` || + '-' + }} + + + {{ props.row.branch[0]?.contactName || '-' }} @@ -3537,6 +3561,11 @@ const emptyCreateDialog = ref(false); employeeFormState.dialogType = 'info'; employeeFormState.isEmployeeEdit = false; } + + if (employeeFormState.currentTab === 'passport') { + await employeeFormStore.submitPassport(); + } + if (employeeFormState.currentTab === 'healthCheck') { await employeeFormStore.submitHealthCheck(); } @@ -3619,6 +3648,10 @@ const emptyCreateDialog = ref(false); name: 'personalInfo', label: 'customerEmployee.form.group.personalInfo', }, + { + name: 'passport', + label: 'customerEmployee.fileType.passport', + }, { name: 'healthCheck', label: 'customerEmployee.form.group.healthCheck', @@ -3669,6 +3702,31 @@ const emptyCreateDialog = ref(false); anchor: 'drawer-upload-file', tab: 'personalInfo', }, + { + name: $t('customerEmployee.form.group.passport'), + anchor: 'drawer-passport', + tab: 'passport', + useBtn: + currentFromDataEmployee.employeePassport?.filter( + (item) => { + if (item.id === undefined) { + return true; + } + return false; + }, + ).length === 0 && + employeeFormState.currentIndexPassport === -1 + ? true + : false, + }, + ...(currentFromDataEmployee.employeePassport?.map( + (v, i) => ({ + name: dateFormat(v.expireDate), + anchor: `drawer-employee-employeePassport-${i}`, + tab: 'passport', + sub: true, + }), + ) || []), ...(currentFromDataEmployee.employeeCheckup?.map( (v, i) => ({ @@ -3695,7 +3753,20 @@ const emptyCreateDialog = ref(false); foreground: 'var(--blue-6)', }" scroll-element="#drawer-employee-form-content" - /> + > + +
+ > + +