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 bbe910329..59c3b5c93 100644 --- a/src/modules/02_organizationalNew/components/TreeView.vue +++ b/src/modules/02_organizationalNew/components/TreeView.vue @@ -82,7 +82,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; @@ -138,7 +139,6 @@ function getSummary() { }) .then(async (res: any) => { const data = await res.data.result; - store.getSumPosition({ totalPosition: data.totalPosition, totalPositionCurrentUse: data.totalPositionCurrentUse, @@ -161,6 +161,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 =