refactor: edit map data

This commit is contained in:
Net 2024-08-27 12:55:11 +07:00 committed by Methapon Metanipat
parent 6882f95122
commit f875d11b4f

View file

@ -127,41 +127,52 @@ export const useCustomerForm = defineStore('form-customer', () => {
resetFormData.birthDate = new Date(data.birthDate); resetFormData.birthDate = new Date(data.birthDate);
resetFormData.image = null; resetFormData.image = null;
resetFormData.customerBranch = data.branch.map((v) => ({ resetFormData.customerBranch = await Promise.all(
id: v.id, data.branch.map(async (v) => ({
code: v.code || '', id: v.id,
customerCode: '', code: v.code || '',
provinceId: v.provinceId, customerCode: '',
districtId: v.districtId, provinceId: v.provinceId,
subDistrictId: v.subDistrictId, districtId: v.districtId,
wageRate: v.wageRate, subDistrictId: v.subDistrictId,
payDate: new Date(v.payDate), // Convert the string to a Date object wageRate: v.wageRate,
saleEmployee: v.saleEmployee, payDate: new Date(v.payDate), // Convert the string to a Date object
jobDescription: v.jobDescription, saleEmployee: v.saleEmployee,
jobPositionEN: v.jobPositionEN, jobDescription: v.jobDescription,
jobPosition: v.jobPosition, jobPositionEN: v.jobPositionEN,
businessTypeEN: v.businessTypeEN, jobPosition: v.jobPosition,
businessType: v.businessType, businessTypeEN: v.businessTypeEN,
employmentOffice: v.employmentOffice, businessType: v.businessType,
telephoneNo: v.telephoneNo, employmentOffice: v.employmentOffice,
email: v.email, telephoneNo: v.telephoneNo,
addressEN: v.addressEN, email: v.email,
address: v.address, addressEN: v.addressEN,
workplaceEN: v.workplaceEN, address: v.address,
workplace: v.workplace, workplaceEN: v.workplaceEN,
status: v.status, workplace: v.workplace,
customerId: v.customerId, status: v.status,
citizenId: v.citizenId || '', customerId: v.customerId,
authorizedCapital: v.authorizedCapital || '', citizenId: v.citizenId || '',
registerDate: new Date(v.registerDate), // Convert the string to a Date object authorizedCapital: v.authorizedCapital || '',
registerNameEN: v.registerNameEN || '', registerDate: new Date(v.registerDate), // Convert the string to a Date object
registerName: v.registerName || '', registerNameEN: v.registerNameEN || '',
legalPersonNo: v.legalPersonNo || '', registerName: v.registerName || '',
registerCompanyName: '', legalPersonNo: v.legalPersonNo || '',
statusSave: true, registerCompanyName: '',
contactName: v.contactName || '', statusSave: true,
file: undefined, contactName: v.contactName || '',
})); file: await customerStore.listAttachment(v.id).then(async (r) => {
if (r) {
return await Promise.all(
r.map(async (item) => ({
url: await customerStore.getAttachment(v.id, item),
})),
);
}
return [];
}),
})),
);
currentFormData.value = structuredClone(resetFormData); currentFormData.value = structuredClone(resetFormData);
} }