refactor: wait putAttachment

This commit is contained in:
Net 2024-08-28 09:51:12 +07:00 committed by Methapon Metanipat
parent 57a32bdd04
commit 53c015ae6c

View file

@ -2684,25 +2684,32 @@ const emptyCreateDialog = ref(false);
} }
customerFormData.customerBranch[idx].file?.forEach( customerFormData.customerBranch[idx].file?.forEach(
(v) => { async (v) => {
if (!v.file) return; if (!v.file) return;
const ext = v.file.name.split('.').at(-1); const ext = v.file.name.split('.').at(-1);
let filename = v.group + '-' + new Date().getTime(); let filename = v.group + '-' + new Date().getTime();
if (ext) filename += `.${ext}`; if (ext) filename += `.${ext}`;
customerStore.putAttachment({ const res = await customerStore.putAttachment({
branchId: branchId:
customerFormData.customerBranch?.[idx].id || '', customerFormData.customerBranch?.[idx].id || '',
file: v.file, file: v.file,
filename, filename,
}); });
if (res) {
await customerFormStore.assignFormData(
customerFormState.editCustomerId,
);
}
}, },
); );
await customerFormStore.assignFormData( await customerFormStore.assignFormData(
customerFormState.editCustomerId, customerFormState.editCustomerId,
); );
customerFormStore.resetForm(); customerFormStore.resetForm();
} }
} }