refactor: wait for upload

This commit is contained in:
Methapon Metanipat 2024-09-16 14:47:29 +07:00
parent 66a8d0a8b9
commit 46041c3f37

View file

@ -1970,7 +1970,7 @@ const emptyCreateDialog = ref(false);
); );
if (tapIsUndefined.length > 0) { if (tapIsUndefined.length > 0) {
dialog({ return dialog({
color: 'warning', color: 'warning',
icon: 'mdi-alert', icon: 'mdi-alert',
title: t('dialog.title.incompleteDataEntry'), title: t('dialog.title.incompleteDataEntry'),
@ -1983,14 +1983,13 @@ const emptyCreateDialog = ref(false);
return; return;
}, },
}); });
} else { }
if (!customerFormData.customerBranch[idx].id) { if (!customerFormData.customerBranch[idx].id) {
await customerFormStore.submitFormCustomer( await customerFormStore.submitFormCustomer(
onCreateImageList, onCreateImageList,
); );
customerFormState.readonly = true; customerFormState.readonly = true;
notify('create', $t('general.success')); notify('create', $t('general.success'));
await fetchListCustomer();
// await customerStore.createBranch({ // await customerStore.createBranch({
// ...customerFormData.customerBranch[idx], // ...customerFormData.customerBranch[idx],
// customerId: customerFormState.editCustomerId, // customerId: customerFormState.editCustomerId,
@ -2006,7 +2005,8 @@ const emptyCreateDialog = ref(false);
); );
} }
customerFormData.customerBranch[idx].file?.forEach( const uploadResult =
customerFormData.customerBranch[idx].file?.map(
async (v) => { async (v) => {
if (!v.file) return; if (!v.file) return;
@ -2027,14 +2027,17 @@ const emptyCreateDialog = ref(false);
); );
} }
}, },
); ) || [];
for (const r of uploadResult) await r;
await customerFormStore.assignFormData( await customerFormStore.assignFormData(
customerFormState.editCustomerId, customerFormState.editCustomerId,
); );
await fetchListCustomer();
customerFormStore.resetForm(); customerFormStore.resetForm();
} }
}
" "
> >
<!-- v-if="!!customerFormState.editCustomerId" --> <!-- v-if="!!customerFormState.editCustomerId" -->