diff --git a/src/modules/02_organizationalNew/components/listView.vue b/src/modules/02_organizationalNew/components/listView.vue index a0d0916eb..eb2333ce5 100644 --- a/src/modules/02_organizationalNew/components/listView.vue +++ b/src/modules/02_organizationalNew/components/listView.vue @@ -19,38 +19,50 @@ const { showLoader, hideLoader, messageError } = useCounterMixin(); const showData = ref(false); const nodeTree = ref(); +const historyId = defineModel("historyId", { required: true }); +const count = defineModel("count", { required: true }); // defineProps<{ dataActive: DataActive }>(); -async function fetchDataTree() { +async function fetchDataTree(id: string) { showLoader(); - const id = - store.typeOrganizational === "current" ? store.activeId : store.draftId; - id && - (await http - .get(config.API.orgByid(id.toString())) - .then((res) => { - const data = res.data.result; - nodeTree.value = data; - console.log(res); - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { - hideLoader(); - })); + // const id = + // store.typeOrganizational === "current" ? store.activeId : store.draftId; + // id && + await http + .get(config.API.orgByid(id.toString())) + .then((res) => { + const data = res.data.result; + nodeTree.value = data; + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); // console.log(nodeTree.value); } onMounted(async () => { - await fetchDataTree(); + const id = + store.typeOrganizational === "current" ? store.activeId : store.draftId; + id && (await fetchDataTree(id)); }); +watch( + () => count.value, + () => { + fetchDataTree(historyId.value); + } +); + watch( () => store.typeOrganizational, () => { - fetchDataTree(); + const id = + store.typeOrganizational === "current" ? store.activeId : store.draftId; + id && store.typeOrganizational !== "old" && fetchDataTree(id); } ); diff --git a/src/modules/02_organizationalNew/components/mainTree.vue b/src/modules/02_organizationalNew/components/mainTree.vue index 2a0b97978..f6f0504aa 100644 --- a/src/modules/02_organizationalNew/components/mainTree.vue +++ b/src/modules/02_organizationalNew/components/mainTree.vue @@ -149,9 +149,6 @@ function deleteNode(treeNode: any, organizationId: any): boolean { // console.log("tttttttttttttt", treeNode.orgTreeId, organizationId); if (treeNode.orgTreeId === organizationId) { - console.log(treeNode); - - // ลบ Node โดยการไม่ส่งผลลบ Node ทั้งหมดภายใต้ treeNode.children = []; breakLoop.value = true; @@ -351,6 +348,45 @@ onMounted(async () => {}); + + + + + + + + + {{ item.label }} + + + +