diff --git a/src/pages/05_quotation/QuotationForm.vue b/src/pages/05_quotation/QuotationForm.vue index c51235f3..b3e2a856 100644 --- a/src/pages/05_quotation/QuotationForm.vue +++ b/src/pages/05_quotation/QuotationForm.vue @@ -321,12 +321,21 @@ function toggleDeleteProduct(index: number) { deleteItem(productServiceList.value, index); } async function assignWorkerToSelectedWorker() { - quotationFormData.value.worker.forEach((value, i) => { - const tempValue: Employee | undefined = workerList.value.find( - (v) => v.id === value.id, + if (quotationFormData.value.customerBranchId) { + const retEmp = await customerStore.fetchBranchEmployee( + quotationFormData.value.customerBranchId, ); - if (tempValue !== undefined) selectedWorker.value.push(tempValue); - }); + if (retEmp) { + workerList.value = retEmp.data.result; + + quotationFormData.value.worker.forEach((value) => { + const tempValue: Employee | undefined = workerList.value.find( + (v) => v.id === value.id, + ); + if (tempValue !== undefined) selectedWorker.value.push(tempValue); + }); + } + } } function convertToTable(nodes: Node[]) { @@ -463,13 +472,6 @@ onMounted(async () => { }); if (ret) productGroup.value = ret.result; - if (quotationFormData.value.customerBranchId) { - const retEmp = await customerStore.fetchBranchEmployee( - quotationFormData.value.customerBranchId, - ); - if (retEmp) workerList.value = retEmp.data.result; - } - if ( currentQuotationId.value !== undefined && quotationFormState.value.mode !== 'create' @@ -477,8 +479,10 @@ onMounted(async () => { await quotationForm.assignFormData( currentQuotationId.value, quotationFormState.value.mode, + async () => { + await assignWorkerToSelectedWorker(); + }, ); - await assignWorkerToSelectedWorker(); } pageState.isLoaded = true;