From 1b2f0c54e455b6d8647116b260cbf81205390882 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Mon, 19 Feb 2024 13:06:49 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=82=E0=B8=84=E0=B8=A3=E0=B8=87=E0=B8=AA?= =?UTF-8?q?=E0=B8=A3=E0=B9=89=E0=B8=B2=E0=B8=87=E0=B8=AD=E0=B8=B1=E0=B8=95?= =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=81=E0=B8=B3=E0=B8=A5=E0=B8=B1=E0=B8=87?= =?UTF-8?q?=20=3D>=20=E0=B8=A2=E0=B9=89=E0=B8=B2=E0=B8=A2=E0=B8=95?= =?UTF-8?q?=E0=B8=B3=E0=B9=81=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=87=E0=B8=88?= =?UTF-8?q?=E0=B8=B2=E0=B8=81=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=A7=E0=B8=A2?= =?UTF-8?q?=E0=B8=87=E0=B8=B2=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/DialogMovePos.vue | 1 + .../components/TreeView.vue | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/modules/02_organizationalNew/components/DialogMovePos.vue b/src/modules/02_organizationalNew/components/DialogMovePos.vue index d36da37e0..d4dc3b284 100644 --- a/src/modules/02_organizationalNew/components/DialogMovePos.vue +++ b/src/modules/02_organizationalNew/components/DialogMovePos.vue @@ -125,6 +125,7 @@ watch( () => { reqMaster.value.page = 1; filterTree.value = ""; + title.value = `ย้ายตำแหน่งจากหน่วยงาน/ส่วนราชการปัจจุบัน ${props.mainTree.orgName}`; if (modal.value && props.type === "SINGER") { const data = rows.value.filter((e: PosMaster2) => e.id === props.rowId); diff --git a/src/modules/02_organizationalNew/components/TreeView.vue b/src/modules/02_organizationalNew/components/TreeView.vue index da5977909..e189d7085 100644 --- a/src/modules/02_organizationalNew/components/TreeView.vue +++ b/src/modules/02_organizationalNew/components/TreeView.vue @@ -81,7 +81,8 @@ async function fetchDataTree(id: string) { * @param level levelTree */ async function fetchDataTable(id: string, level: number, action: boolean) { - mainTree.value = nodeTree.value?.find((e) => e.orgTreeId === id); + searchAndReplaceOrgName(nodeTree.value, id); + orgLevel.value = level; reqMaster.id = id; reqMaster.type = level; @@ -137,7 +138,6 @@ function getSummary() { }) .then(async (res: any) => { const data = await res.data.result; - store.getSumPosition({ totalPosition: data.totalPosition, totalPositionCurrentUse: data.totalPositionCurrentUse, @@ -160,6 +160,20 @@ async function filterKeyword() { fetchDataTable(reqMaster.id, reqMaster.type, false); } +function searchAndReplaceOrgName(data: any, targetId: string) { + for (const child of data) { + if (child.orgTreeId === targetId) { + mainTree.value = child; + + return true; // Found the targetId in this level + } + if (child.children && searchAndReplaceOrgName(child.children, targetId)) { + return true; // Found the targetId in the nested children + } + } + return false; // Not found in this branch +} + /**lifecycle Hook*/ onMounted(async () => { const id =