diff --git a/src/modules/02_organizationalNew/components/StructureDetail.vue b/src/modules/02_organizationalNew/components/StructureDetail.vue index 3973c2e47..06b4be766 100644 --- a/src/modules/02_organizationalNew/components/StructureDetail.vue +++ b/src/modules/02_organizationalNew/components/StructureDetail.vue @@ -50,7 +50,11 @@ async function fetchDetailTree(id: string, type: string) { formData.orgType = range != "DEPARTMENT" ? "ส่วนราชการ" : "หน่วยงาน"; formData.orgLevel = store.convertType(range); formData.status = - store.typeOrganizational === "current" ? "ปัจจุบัน" : "แบบร่าง"; + store.typeOrganizational === "current" + ? "ปกติ" + : store.typeOrganizational === "draft" + ? "แบบร่าง" + : "ยุบเลิก"; formData.orgPhoneEx = data[`org${type}PhoneEx`]; formData.orgPhoneIn = data[`org${type}PhoneIn`]; formData.orgFax = data[`org${type}Fax`]; 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..84afe164a 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; @@ -283,7 +280,24 @@ onMounted(async () => {}); @update:selected="updateSelected" > -