Merge branch 'nice_dev' into develop

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-02-19 13:07:07 +07:00
commit ec9cf57066
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

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