From 701355ed5705f86bfea66d7b0c705443d381add7 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Fri, 21 Jul 2023 14:25:01 +0700 Subject: [PATCH] expanded tree --- .../components/PersonalList/OrgTree.vue | 325 +++++++++--------- .../components/PersonalList/Table.vue | 5 +- 2 files changed, 173 insertions(+), 157 deletions(-) diff --git a/src/modules/05_placement/components/PersonalList/OrgTree.vue b/src/modules/05_placement/components/PersonalList/OrgTree.vue index 5d2f99365..a2f2055b1 100644 --- a/src/modules/05_placement/components/PersonalList/OrgTree.vue +++ b/src/modules/05_placement/components/PersonalList/OrgTree.vue @@ -58,6 +58,7 @@ const fetchPublishFile = async () => { // โหลดข้อมูลโครงสร้างจาก json const treeData = ref>([]); const loadTreeData = async () => { + expanded.value = []; await http .get(`${config.s3ClusterUrl}${selectedFile.value}`) .then((res: any) => { @@ -126,20 +127,20 @@ const myFilterMethod = (node: any, filter: string) => { // ((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 && - node.governmentCode.toString().indexOf(filt) > -1) || - (node.agency && node.agency.indexOf(filt) > -1) || - (node.government && node.government.indexOf(filt) > -1) || - (node.department && node.department.indexOf(filt) > -1) || - (node.pile && node.pile.indexOf(filt) > -1) || - (node.organizationShortName && - node.organizationShortName.indexOf(filt) > -1) || - (node.positionSideName && node.positionSideName.indexOf(filt) > -1) || - (node.executivePosition && node.executivePosition.indexOf(filt) > -1) || - (node.executivePositionSide && - node.executivePositionSide.indexOf(filt) > -1) || + (node.positionNum && node.positionNum.indexOf(filt) > -1) || + (node.positionName && node.positionName.indexOf(filt) > -1) || + (node.governmentCode && + node.governmentCode.toString().indexOf(filt) > -1) || + (node.agency && node.agency.indexOf(filt) > -1) || + (node.government && node.government.indexOf(filt) > -1) || + (node.department && node.department.indexOf(filt) > -1) || + (node.pile && node.pile.indexOf(filt) > -1) || + (node.organizationShortName && + node.organizationShortName.indexOf(filt) > -1) || + (node.positionSideName && node.positionSideName.indexOf(filt) > -1) || + (node.executivePosition && node.executivePosition.indexOf(filt) > -1) || + (node.executivePositionSide && + node.executivePositionSide.indexOf(filt) > -1) || (node.positionLevel && node.positionLevel.indexOf(filt) > -1) ); }; @@ -361,8 +362,10 @@ const checkPosition = (val: string) => { return num; }; const personal = ref(); +const expanded = ref([]); watch(props, () => { + expanded.value = []; const dataPersonal = props.personal; if (dataPersonal) { dataPersonal.map((data: any) => { @@ -373,26 +376,37 @@ watch(props, () => { // console.log("draft===>", personal.value.draft); - if (personal.value.draft === true) { + if (personal.value.draft === false) { // const findData = dataRespone.value.find(findByPerson); let findData: any = null; + console.log(dataRespone.value); + dataRespone.value.map((x: any) => { findData = findByPerson(x); if (findData != null) { console.log("findData===>", findData); - selectedPosition(findData) + selectedPosition(findData); + for (let i = 3; i <= findData.keyId.length; i += 2) { + expanded.value.push(findData.keyId.slice(0, i)); + } } - }) + }); // loadTreeData(); // selectedPosition(findData.children.children.children) } }); -function findByPerson(element: any) { +function findByPerson(element: any): any { // console.log("searchTree element===>", element) - if (element.positionNumId && element.positionLineId === personal.value.positionLineId && + if ( + element.positionNumId && + element.positionLineId === personal.value.positionLineId && element.positionTypeId === personal.value.positionTypeId && - element.positionNumId === personal.value.posNoId + element.positionNumId === personal.value.posNoId && + (element.positionLevelObj === null || + element.positionLevelObj[0].Id === personal.value.positionLevelId) && + (element.positionSideNameObj === null || + element.positionSideNameObj[0].Id === personal.value.positionPathSideId) ) { return element; } else if (element.children) { @@ -408,153 +422,156 @@ function findByPerson(element: any) { + + + + + +
diff --git a/src/modules/05_placement/components/PersonalList/Table.vue b/src/modules/05_placement/components/PersonalList/Table.vue index d85c9247e..2eae18436 100644 --- a/src/modules/05_placement/components/PersonalList/Table.vue +++ b/src/modules/05_placement/components/PersonalList/Table.vue @@ -195,9 +195,9 @@ const convertContainStatus = (val: string) => { }; const convertDraft = (val: boolean) => { switch (val) { - case true: - return "รอส่งตัว"; case false: + return "รอส่งตัว"; + case true: return "ส่งตัวแล้ว"; default: return "-"; @@ -893,7 +893,6 @@ const paginationLabel = (start: number, end: number, total: number) => { - ส่งรายชื่อไปยังหน่วยงาน