โครงสร้างทะเบียนประวัติ
This commit is contained in:
parent
3666cd61a9
commit
b5f7d75599
5 changed files with 92 additions and 54 deletions
|
|
@ -1,5 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive, watch } from "vue";
|
||||
import { ref, reactive, watch, onBeforeMount, onMounted } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
import { useRoute } from "vue-router";
|
||||
|
||||
|
|
@ -19,10 +19,11 @@ import Header from "@/components/DialogHeader.vue";
|
|||
|
||||
/** importStore*/
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { asCleanDays } from "@fullcalendar/core/internal";
|
||||
import { useStructureTree } from "@/stores/structureTree";
|
||||
|
||||
/** use*/
|
||||
const $q = useQuasar();
|
||||
const { fetchStructureTree } = useStructureTree();
|
||||
const {
|
||||
success,
|
||||
showLoader,
|
||||
|
|
@ -204,47 +205,18 @@ const selectedPos = ref<any[]>([]);
|
|||
const datePos = ref<Date>(new Date());
|
||||
const posMasterMain = ref<any>([]);
|
||||
const orgRevisionId = ref<string>("");
|
||||
|
||||
/** function เรียกข้อมูลโครงสร้าง แบบปัจุบันและ แบบร่าง*/
|
||||
async function fetchOrganizationActive() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.activeOrganization)
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
if (data) {
|
||||
orgRevisionId.value = data.activeId;
|
||||
fetchDataTree(data.activeId);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
});
|
||||
}
|
||||
|
||||
const isLoad = ref<boolean>(false);
|
||||
/**
|
||||
* function fetch ข้อมูลของ Tree
|
||||
* @param id id โครงสร้าง
|
||||
*/
|
||||
async function fetchDataTree(id: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.orgByIdSystem(id, route.meta.Key as string))
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
if (data) {
|
||||
nodes.value = data;
|
||||
filterItemsTaps(data);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
setTimeout(() => {
|
||||
hideLoader();
|
||||
}, 1000);
|
||||
});
|
||||
async function fetchDataTree() {
|
||||
const data = await fetchStructureTree(route.meta.Key as string, true);
|
||||
if (data) {
|
||||
nodes.value = data;
|
||||
filterItemsTaps(data);
|
||||
isLoad.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -333,7 +305,7 @@ async function fetchPosFind(level: number, id: string) {
|
|||
await http
|
||||
.post(config.API.orgPosFind, body)
|
||||
.then(async (res) => {
|
||||
const data = res.data.result;
|
||||
const data = await res.data.result;
|
||||
|
||||
expanded.value = data;
|
||||
nodeId.value = id;
|
||||
|
|
@ -400,7 +372,7 @@ function closePopup() {
|
|||
}
|
||||
|
||||
/** function clearData*/
|
||||
function clearData() {
|
||||
async function clearData() {
|
||||
nodeId.value = "";
|
||||
expanded.value = [];
|
||||
positionId.value = "";
|
||||
|
|
@ -441,12 +413,14 @@ watch(
|
|||
() => modal.value,
|
||||
async () => {
|
||||
if (modal.value) {
|
||||
await fetchOrganizationActive();
|
||||
showLoader();
|
||||
await clearData();
|
||||
if (props?.dataRow?.node !== null && props?.dataRow?.nodeId !== null) {
|
||||
await fetchPosFind(props?.dataRow?.node, props?.dataRow?.nodeId);
|
||||
} else {
|
||||
expanded.value = [];
|
||||
}
|
||||
isLoad.value && hideLoader();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
@ -468,6 +442,10 @@ watch(
|
|||
}
|
||||
}
|
||||
);
|
||||
|
||||
onBeforeMount(async () => {
|
||||
await fetchDataTree();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue