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?.();