From 6fe81fc47cae0bfde2fc974938352defee7058ba Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Wed, 13 Nov 2024 14:36:45 +0700 Subject: [PATCH] fix: on delete worker update selected worker properly --- src/components/05_quotation/ProductItem.vue | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/05_quotation/ProductItem.vue b/src/components/05_quotation/ProductItem.vue index aae67bfa..307dd447 100644 --- a/src/components/05_quotation/ProductItem.vue +++ b/src/components/05_quotation/ProductItem.vue @@ -208,9 +208,17 @@ watch( () => props.employeeRows, (a, b) => { if (a === undefined || b === undefined) return; + + const removed = b.findIndex( + (c) => !a.find((d) => JSON.stringify(c) === JSON.stringify(d)), + ); + if (a.length < b.length) { rows.value.forEach((p) => { const maxValue = Math.max(...p.workerIndex); + if (removed !== -1) { + p.workerIndex = p.workerIndex.map((i) => (i > removed ? i - 1 : i)); + } p.workerIndex = p.workerIndex.filter((i) => i !== maxValue); }); }