diff --git a/src/pages/03_customer-management/form.ts b/src/pages/03_customer-management/form.ts index 9f81132b..42382f5e 100644 --- a/src/pages/03_customer-management/form.ts +++ b/src/pages/03_customer-management/form.ts @@ -128,32 +128,36 @@ export const useCustomerForm = defineStore('form-customer', () => { resetFormData.customerBranch = data.branch.map((v) => ({ id: v.id, code: v.code, - branchNo: v.branchNo, - address: v.address, - addressEN: v.addressEN, + customerCode: '', provinceId: v.provinceId, districtId: v.districtId, subDistrictId: v.subDistrictId, - zipCode: v.zipCode, - email: v.email, - telephoneNo: v.telephoneNo, - name: v.name, - status: undefined, - taxNo: v.taxNo, - nameEN: v.nameEN, - legalPersonNo: v.legalPersonNo, - registerName: v.registerName, - registerDate: new Date(v.registerDate), - authorizedCapital: v.authorizedCapital, - employmentOffice: v.employmentOffice, - bussinessType: v.bussinessType, - bussinessTypeEN: v.bussinessTypeEN, - jobPosition: v.jobPosition, - jobPositionEN: v.jobPositionEN, - jobDescription: v.jobDescription, - saleEmployee: v.saleEmployee, - payDate: new Date(v.payDate), wageRate: v.wageRate, + payDate: new Date(v.payDate), // Convert the string to a Date object + saleEmployee: v.saleEmployee, + jobDescription: v.jobDescription, + jobPositionEN: v.jobPositionEN, + jobPosition: v.jobPosition, + businessTypeEN: v.businessTypeEN, + businessType: v.businessType, + employmentOffice: v.employmentOffice, + telephoneNo: v.telephoneNo, + email: v.email, + addressEN: v.addressEN, + address: v.address, + workplaceEN: v.workplaceEN, + workplace: v.workplace, + status: v.status, + customerId: v.customerId, + citizenId: v.citizenId, + authorizedCapital: v.authorizedCapital, + registerDate: new Date(v.registerDate), // Convert the string to a Date object + registerNameEN: v.registerNameEN, + registerName: v.registerName, + legalPersonNo: v.legalPersonNo, + registerCompanyName: '', + statusSave: true, + file: undefined, })); currentFormData.value = structuredClone(resetFormData); @@ -164,34 +168,42 @@ export const useCustomerForm = defineStore('form-customer', () => { currentFormData.value.customerBranch?.push({ id: '', - code: '', - branchNo: - (currentFormData.value.customerBranch?.at(-1)?.branchNo || 0) + 1, - address: '', - addressEN: '', + code: currentFormData.value.customerBranch?.[0].code, + customerCode: '', provinceId: '', districtId: '', subDistrictId: '', - zipCode: '', - email: '', - telephoneNo: '', - name: '', - status: 'CREATED', - taxNo: '', - nameEN: '', - legalPersonNo: '', - registerName: '', - registerDate: new Date(), - authorizedCapital: '', - employmentOffice: '', - bussinessType: '', - bussinessTypeEN: '', - jobPosition: '', - jobPositionEN: '', - jobDescription: '', - saleEmployee: '', - payDate: new Date(), wageRate: 0, + payDate: new Date(), // Convert the string to a Date object + saleEmployee: '', + jobDescription: '', + jobPositionEN: '', + jobPosition: '', + businessTypeEN: '', + businessType: '', + employmentOffice: '', + telephoneNo: '', + email: '', + addressEN: '', + address: '', + workplaceEN: '', + workplace: '', + status: 'CREATED', + customerId: '', + citizenId: + currentFormData.value.customerBranch?.[0].citizenId === null + ? '' + : currentFormData.value.customerBranch?.[0].citizenId, + authorizedCapital: '', + registerDate: new Date(), // Convert the string to a Date object + registerNameEN: '', + registerName: '', + legalPersonNo: + currentFormData.value.customerBranch?.[0].legalPersonNo === null + ? '' + : currentFormData.value.customerBranch?.[0].legalPersonNo, + registerCompanyName: '', + file: undefined, }); state.value.branchIndex = (currentFormData.value.customerBranch?.length || 0) - 1; @@ -249,40 +261,43 @@ export const useCustomerForm = defineStore('form-customer', () => { export const useCustomerBranchForm = defineStore('form-customer-branch', () => { const customerStore = useCustomerStore(); - const defaultFormData: CustomerBranchCreate = { - id: '', + const defaultFormData: CustomerBranchCreate & { id?: string } = { code: '', - branchNo: 1, - address: '', - addressEN: '', + customerCode: '', provinceId: '', districtId: '', subDistrictId: '', - zipCode: '', - email: '', - telephoneNo: '', - name: '', - status: 'CREATED', - taxNo: '', - nameEN: '', - legalPersonNo: '', - registerName: '', - registerDate: new Date(), - authorizedCapital: '', - employmentOffice: '', - bussinessType: '', - bussinessTypeEN: '', - jobPosition: '', - jobPositionEN: '', - jobDescription: '', - saleEmployee: '', - payDate: new Date(), wageRate: 0, + payDate: new Date(), // Convert the string to a Date object + saleEmployee: '', + jobDescription: '', + jobPositionEN: '', + jobPosition: '', + businessTypeEN: '', + businessType: '', + employmentOffice: '', + telephoneNo: '', + email: '', + addressEN: '', + address: '', + workplaceEN: '', + workplace: '', + status: 'CREATED', + customerId: '', + citizenId: '', + authorizedCapital: '', + registerDate: new Date(), // Convert the string to a Date object + registerNameEN: '', + registerName: '', + legalPersonNo: '', + registerCompanyName: '', + statusSave: false, + file: undefined, }; let resetFormData = structuredClone(defaultFormData); - const currentFormData = ref( + const currentFormData = ref( structuredClone(defaultFormData), ); @@ -312,34 +327,37 @@ export const useCustomerBranchForm = defineStore('form-customer-branch', () => { if (!_data) return; resetFormData = { - id: _data.id, code: _data.code, - branchNo: _data.branchNo, - address: _data.address, - addressEN: _data.addressEN, + customerCode: '', provinceId: _data.provinceId, districtId: _data.districtId, subDistrictId: _data.subDistrictId, - zipCode: _data.zipCode, - email: _data.email, - telephoneNo: _data.telephoneNo, - name: _data.name, - status: undefined, - taxNo: _data.taxNo, - nameEN: _data.nameEN, - legalPersonNo: _data.legalPersonNo, - registerName: _data.registerName, - registerDate: new Date(_data.registerDate), - authorizedCapital: _data.authorizedCapital, - employmentOffice: _data.employmentOffice, - bussinessType: _data.bussinessType, - bussinessTypeEN: _data.bussinessTypeEN, - jobPosition: _data.jobPosition, - jobPositionEN: _data.jobPositionEN, - jobDescription: _data.jobDescription, - saleEmployee: _data.saleEmployee, - payDate: new Date(_data.payDate), wageRate: _data.wageRate, + payDate: new Date(_data.payDate), // Convert the string to a Date object + saleEmployee: _data.saleEmployee, + jobDescription: _data.jobDescription, + jobPositionEN: _data.jobPositionEN, + jobPosition: _data.jobPosition, + businessTypeEN: _data.businessTypeEN, + businessType: _data.businessType, + employmentOffice: _data.employmentOffice, + telephoneNo: _data.telephoneNo, + email: _data.email, + addressEN: _data.addressEN, + address: _data.address, + workplaceEN: _data.workplaceEN, + workplace: _data.workplace, + status: 'CREATED', + customerId: _data.customerId, + citizenId: _data.citizenId, + authorizedCapital: _data.authorizedCapital, + registerDate: new Date(), // Convert the string to a Date object + registerNameEN: _data.registerNameEN, + registerName: _data.registerName, + legalPersonNo: _data.legalPersonNo, + registerCompanyName: '', + statusSave: false, + file: undefined, }; currentFormData.value = structuredClone(resetFormData);