diff --git a/src/stores/productionTarget.ts b/src/stores/productionTarget.ts index 8515a91eef8adab580fe9273a1c44bdb82794dbb..8bee3ec218419062658a30be4e3c9f9abea2777b 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;