From 47909bf034cd3261bc3d91943818eb95d5a9e2e1 Mon Sep 17 00:00:00 2001 From: waruneeta Date: Fri, 21 Jul 2023 11:41:53 +0700 Subject: [PATCH] update filter tree selected --- .../components/PersonalList/OrgTree.vue | 326 +++++++++--------- 1 file changed, 170 insertions(+), 156 deletions(-) diff --git a/src/modules/05_placement/components/PersonalList/OrgTree.vue b/src/modules/05_placement/components/PersonalList/OrgTree.vue index 141f3cc5a..5d2f99365 100644 --- a/src/modules/05_placement/components/PersonalList/OrgTree.vue +++ b/src/modules/05_placement/components/PersonalList/OrgTree.vue @@ -123,8 +123,9 @@ const myFilterMethod = (node: any, filter: string) => { const filt = filter; return ( - ((node.name && node.name == null) || !node.name) && - ((node.organizationName && node.organizationName.indexOf(filt) > -1) || + // ((node.name && node.name == null) || !node.name) && + (node.name && node.name.indexOf(filt) > -1) || + (node.organizationName && node.organizationName.indexOf(filt) > -1) || (node.positionNum && node.positionNum.indexOf(filt) > -1) || (node.positionName && node.positionName.indexOf(filt) > -1) || (node.governmentCode && @@ -139,7 +140,7 @@ const myFilterMethod = (node: any, filter: string) => { (node.executivePosition && node.executivePosition.indexOf(filt) > -1) || (node.executivePositionSide && node.executivePositionSide.indexOf(filt) > -1) || - (node.positionLevel && node.positionLevel.indexOf(filt) > -1)) + (node.positionLevel && node.positionLevel.indexOf(filt) > -1) ); }; @@ -354,6 +355,7 @@ const selectedPosition = async (data: any) => { dataForm.positionTypeId = ""; } }; + const checkPosition = (val: string) => { const num = placementPosition.value.findIndex((e: string) => e === val); return num; @@ -368,179 +370,191 @@ watch(props, () => { }); console.log("personal", personal.value); } - if (personal.value.draft === false) { - const findData = dataRespone.value.find(findByPerson); - console.log(findData); - loadTreeData(); - selectedPosition(findData.children.children.children) + + // console.log("draft===>", personal.value.draft); + + if (personal.value.draft === true) { + // const findData = dataRespone.value.find(findByPerson); + let findData: any = null; + dataRespone.value.map((x: any) => { + findData = findByPerson(x); + if (findData != null) { + console.log("findData===>", findData); + selectedPosition(findData) + } + }) + // loadTreeData(); + // selectedPosition(findData.children.children.children) } }); -const findByPerson = (obj: any) => { - if ( - obj.positionLineId === personal.value.positionLineId && - obj.positionTypeId === personal.value.positionTypeId && - obj.positionNumId === personal.value.posNoId + +function findByPerson(element: any) { + // console.log("searchTree element===>", element) + if (element.positionNumId && element.positionLineId === personal.value.positionLineId && + element.positionTypeId === personal.value.positionTypeId && + element.positionNumId === personal.value.posNoId ) { - return true; + return element; + } else if (element.children) { + var i; + var result = null; + for (i = 0; result == null && i < element.children.length; i++) { + result = findByPerson(element.children[i]); + } + return result; } - if (obj.children && obj.children.length > 0) { - obj.children = obj.children.find(findByPerson); - return obj.children; - } - return false; -}; + return null; +} + + + + + +