From 7fcae06d4d02903bd7ef19789549e08aaec4d740 Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Thu, 26 Sep 2024 10:09:53 +0700 Subject: [PATCH] feat: auto pull data from headoffice --- src/pages/03_customer-management/form.ts | 76 ++++++++++++++---------- 1 file changed, 46 insertions(+), 30 deletions(-) diff --git a/src/pages/03_customer-management/form.ts b/src/pages/03_customer-management/form.ts index 9335728d..31d44d9e 100644 --- a/src/pages/03_customer-management/form.ts +++ b/src/pages/03_customer-management/form.ts @@ -249,25 +249,33 @@ export const useCustomerForm = defineStore('form-customer', () => { ? '' : currentFormData.value.customerBranch?.[0].citizenId : '', - namePrefix: '', - firstName: '', - lastName: '', - firstNameEN: '', - lastNameEN: '', - telephoneNo: '', - gender: '', - birthDate: '', + namePrefix: currentFormData.value.customerBranch?.at(0)?.namePrefix || '', + firstName: currentFormData.value.customerBranch?.at(0)?.firstName || '', + lastName: currentFormData.value.customerBranch?.at(0)?.lastName || '', + firstNameEN: + currentFormData.value.customerBranch?.at(0)?.firstNameEN || '', + lastNameEN: currentFormData.value.customerBranch?.at(0)?.lastNameEN || '', + telephoneNo: + currentFormData.value.customerBranch?.at(0)?.telephoneNo || '', + gender: currentFormData.value.customerBranch?.at(0)?.gender || '', + birthDate: currentFormData.value.customerBranch?.at(0)?.birthDate || '', - businessType: '', - jobPosition: '', - jobDescription: '', - payDate: '', - payDateEN: '', - wageRate: 0, - wageRateText: '', - homeCode: '', - employmentOffice: '', - employmentOfficeEN: '', + businessType: + currentFormData.value.customerBranch?.at(0)?.businessType || '', + jobPosition: + currentFormData.value.customerBranch?.at(0)?.jobPosition || '', + jobDescription: + currentFormData.value.customerBranch?.at(0)?.jobDescription || '', + payDate: currentFormData.value.customerBranch?.at(0)?.payDate || '', + payDateEN: currentFormData.value.customerBranch?.at(0)?.payDateEN || '', + wageRate: currentFormData.value.customerBranch?.at(0)?.wageRate || 0, + wageRateText: + currentFormData.value.customerBranch?.at(0)?.wageRateText || '', + homeCode: currentFormData.value.customerBranch?.at(0)?.homeCode || '', + employmentOffice: + currentFormData.value.customerBranch?.at(0)?.employmentOffice || '', + employmentOfficeEN: + currentFormData.value.customerBranch?.at(0)?.employmentOfficeEN || '', address: '', addressEN: '', @@ -281,20 +289,28 @@ export const useCustomerForm = defineStore('form-customer', () => { districtId: '', subDistrictId: '', - contactName: '', - email: '', - contactTel: '', - officeTel: '', - agent: '', + contactName: + currentFormData.value.customerBranch?.at(0)?.contactTel || '', + email: currentFormData.value.customerBranch?.at(0)?.email || '', + contactTel: currentFormData.value.customerBranch?.at(0)?.contactTel || '', + officeTel: currentFormData.value.customerBranch?.at(0)?.officeTel || '', + agent: currentFormData.value.customerBranch?.at(0)?.agent || '', status: 'CREATED', - customerName: '', - registerName: '', - registerNameEN: '', - registerDate: null, - authorizedCapital: '', - authorizedName: '', - authorizedNameEN: '', + customerName: + currentFormData.value.customerBranch?.at(0)?.customerName || '', + registerName: + currentFormData.value.customerBranch?.at(0)?.registerName || '', + registerNameEN: + currentFormData.value.customerBranch?.at(0)?.registerNameEN || '', + registerDate: + currentFormData.value.customerBranch?.at(0)?.registerDate || null, + authorizedCapital: + currentFormData.value.customerBranch?.at(0)?.authorizedCapital || '', + authorizedName: + currentFormData.value.customerBranch?.at(0)?.authorizedName || '', + authorizedNameEN: + currentFormData.value.customerBranch?.at(0)?.authorizedNameEN || '', file: [], }); state.value.branchIndex =