fix: Not enough time to assign worker to selectedWorker

This commit is contained in:
Thanaphon Frappet 2024-10-09 09:08:19 +07:00
parent 13cf2da9f9
commit bd2933f9d3

View file

@ -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;