ปรัย UI โครงสร้าง

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-01-31 10:34:03 +07:00
parent 533ed31bc8
commit 33f887f792
4 changed files with 143 additions and 39 deletions

View file

@ -19,38 +19,50 @@ const { showLoader, hideLoader, messageError } = useCounterMixin();
const showData = ref<boolean>(false);
const nodeTree = ref<OrgTree[]>();
const historyId = defineModel<string>("historyId", { required: true });
const count = defineModel<number>("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);
}
);
</script>