From 5c06f820317ed13b1a5f5ed055fbd2b3a392d219 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Thu, 5 Jun 2025 14:45:28 +0700 Subject: [PATCH] =?UTF-8?q?fix=20Replace=20=E0=B8=82=E0=B9=89=E0=B8=AD?= =?UTF-8?q?=E0=B8=A1=E0=B8=B9=E0=B8=A5=E0=B9=83=E0=B8=99=E0=B8=95=E0=B8=B2?= =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/edit/components/Table.vue | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/modules/04_registryPerson/views/edit/components/Table.vue b/src/modules/04_registryPerson/views/edit/components/Table.vue index 776bae52c..cd6a8237a 100644 --- a/src/modules/04_registryPerson/views/edit/components/Table.vue +++ b/src/modules/04_registryPerson/views/edit/components/Table.vue @@ -611,26 +611,25 @@ async function onSave(val: any, id: string, close?: () => void) { .patch(config.API.salaryTemp + `/${salaryId.value}`, body) .then(async () => { success($q, "บันทึกข้อมูลสำเร็จ"); + const idx = rows.value.findIndex((item) => item.id === salaryId.value); + // อัปเดทข้อมูลในตาราง + if (idx !== -1) { + rows.value[idx] = { + ...rows.value[idx], + ...body, + }; + } - rows.value = rows.value.map((item) => { - if (item.id === salaryId.value) { - return { - ...item, - ...body, - }; - } - return item; - }); - - rowsMain.value = rowsMain.value.map((item) => { - if (item.id === salaryId.value) { - return { - ...item, - ...body, - }; - } - return item; - }); + // อัปเดทข้อมูลหลัก + const idxMain = rowsMain.value.findIndex( + (item) => item.id === salaryId.value + ); + if (idxMain !== -1) { + rowsMain.value[idxMain] = { + ...rowsMain.value[idxMain], + ...body, + }; + } }) .catch(async (err) => { await fetchData?.();