From fa788c00e132a60c5d47ab80f0ec652abd351251 Mon Sep 17 00:00:00 2001 From: Kritkhanin Anantakul <65160144@go.buu.ac.th> Date: Mon, 24 Mar 2025 16:53:32 +0700 Subject: [PATCH] fix target --- src/stores/productionTarget.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/stores/productionTarget.ts b/src/stores/productionTarget.ts index 8515a91..8bee3ec 100644 --- a/src/stores/productionTarget.ts +++ b/src/stores/productionTarget.ts @@ -53,10 +53,10 @@ export const useProductionTargetStore = defineStore('productionTarget', () => { const updated = await productionTargetService.updateProductionTarget(id, payload); const index = productionTargets.value.findIndex(p => p.ProductionTargetID === id); if (index !== -1) { - // ✅ อัปเดตค่าจริงใน local state เพื่อให้ computed re-render + // ✅ อัปเดตทั้ง ActualProduced และ Status จาก response backend productionTargets.value[index] = { ...productionTargets.value[index], - ...payload, // ใช้ payload (เช่น ActualProduced) ทับของเดิม + ...updated, // รวม ActualProduced, Status และ field อื่น ๆ ที่ backend ส่งกลับ }; } } catch (e: any) { @@ -66,6 +66,7 @@ export const useProductionTargetStore = defineStore('productionTarget', () => { } } + async function editTodayTarget(payload: { ProductionTargetID: number, ActualProduced: number }) { loading.value = true; -- GitLab