From 41765b1a4817e71073a45fb8d6d3bd188b386c04 Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Tue, 8 Oct 2024 10:06:11 +0700 Subject: [PATCH] feat: set amount on select worker / product --- src/pages/05_quotation/QuotationForm.vue | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/pages/05_quotation/QuotationForm.vue b/src/pages/05_quotation/QuotationForm.vue index c14d7cba..8f070375 100644 --- a/src/pages/05_quotation/QuotationForm.vue +++ b/src/pages/05_quotation/QuotationForm.vue @@ -268,11 +268,26 @@ function convertToTable(nodes: Node[]) { if (v.checked) return v; return []; }; + const list = nodes.flatMap(_recursive).map((v) => v.value); + + list.forEach((v) => { + v.amount = Math.max(selectedWorker.value.length, 1); + }); + + productServiceList.value = list; + pageState.productServiceModal = false; - productServiceList.value = nodes.flatMap(_recursive).map((v) => v.value); } function convertEmployeeToTable() { + productServiceList.value.map((v) => { + if (selectedWorker.value.length === 0 && v.amount === 1) v.amount -= 1; + v.amount = Math.max( + v.amount + preSelectedWorker.value.length - selectedWorker.value.length, + 1, + ); + return v; + }); refSelectZoneEmployee.value?.assignSelect( selectedWorker.value, preSelectedWorker.value,