diff --git a/src/modules/14_KPI/components/indicatorByPlan/IndicatorByPlan.vue b/src/modules/14_KPI/components/indicatorByPlan/IndicatorByPlan.vue index 590dbfdd6..261800d3e 100644 --- a/src/modules/14_KPI/components/indicatorByPlan/IndicatorByPlan.vue +++ b/src/modules/14_KPI/components/indicatorByPlan/IndicatorByPlan.vue @@ -126,22 +126,6 @@ function fetchTreeAgency(id: string) { const data = res.data.result; nodeAgency.value = data; store.treeId = ""; - - if (nodeAgency.value && planData.nodeId) { - const nodeTree = await searchAndReplace( - nodeAgency.value, - planData.nodeId - ); - if (nodeTree) { - expandedAgency.value = []; - const parts = nodeTree?.orgName.split("/"); - for (let i = 1; i < parts.length; i++) { - const arrangedParts = parts[i]; - expandedAgency.value.push(arrangedParts); - } - updateSelectedAgency(nodeTree, true); - } - } }) .catch((err) => { messageError($q, err); @@ -175,6 +159,30 @@ function fetchDataById(id: string) { planData.strategy = data.strategy; planData.strategyId = data.strategyId; + // หน่วยงาน/ส่วนราชการ + const arrayexpandedAgency = [ + data.root, + data.child1, + data.child2, + data.child3, + data.child4, + ]; + expandedAgency.value = arrayexpandedAgency + .filter((e) => e !== null) + .slice(0, -1); + + // ยุทธศาสตร์ / แผน + const arrayexpandedPlan = [ + data.strategyChild1, + data.strategyChild2, + data.strategyChild3, + data.strategyChild4, + data.strategyChild5, + ]; + expandedPlan.value = arrayexpandedPlan + .filter((e) => e !== null) + .slice(0, -1); + fetchRoundOption(); }) .catch((err) => { @@ -237,26 +245,6 @@ function onSubmit() { ); } -/** - * function หาหน่วยงานที่รับผิดชอบ - * @param orgTreeData ข้อมูล nodeTree - * @param treeId tree ID - */ -async function searchAndReplace(orgTreeData: any, treeId: string | null) { - if (orgTreeData) { - for (let orgTree of orgTreeData) { - if (orgTree.orgTreeId === treeId) { - return orgTree; - } - let foundOrg: any = await searchAndReplace(orgTree.children, treeId); - if (foundOrg) { - return foundOrg; - } - } - return false; - } -} - onMounted(() => { fetchOrganizationActive(); if (id.value) { @@ -525,7 +513,13 @@ onMounted(() => { - +