โครงสร้างอัตรากำลัง => ย้ายตำแหน่งจากหน่วยงาน

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-02-19 13:06:49 +07:00
parent 31d5724c8a
commit 1b2f0c54e4
2 changed files with 17 additions and 2 deletions

View file

@ -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);

View file

@ -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 =