Merge branch 'nice' into develop

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-05 10:54:17 +07:00
commit 8b4e14708d
5 changed files with 92 additions and 54 deletions

View file

@ -333,9 +333,11 @@ function clearSelect(t: string) {
fetchDataPerson();
}
const isLoad = ref<boolean>(false);
async function fetchTree() {
const data = await fetchStructureTree(route.meta.Key as string);
if (data) {
isLoad.value = true;
node.value = data;
store.formFilter.node = nodeData.node;
store.formFilter.nodeId = nodeData.nodeId;
@ -365,6 +367,11 @@ function updateSelectedTreeMain(data: any) {
}
}
/** callback function เมื่อมีการเปิด popup*/
watch(selectNode, () => {
isLoad.value && hideLoader();
});
onMounted(async () => {
selectType();
fetchTree();
@ -453,7 +460,7 @@ onMounted(async () => {
label-color="white"
dropdown-icon="mdi-chevron-down"
class="q-px-sm"
@click="() => (selectNode = true)"
@click="() => ((selectNode = true), showLoader())"
>
<template v-slot:label>
{{

View file

@ -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>

View file

@ -215,14 +215,14 @@ watch(
}
);
function fetchList() {
async function fetchList() {
showLoader();
http
.get(config.API.registryNew("-temp"), { params: queryParams })
.then((res) => {
.then(async (res) => {
rows.value = await res.data.result.data;
maxPage.value = Math.ceil(res.data.result.total / queryParams.pageSize);
total.value = res.data.result.total;
rows.value = res.data.result.data;
})
.catch((err) => {
messageError($q, err);
@ -273,8 +273,8 @@ function onClickSendOrder() {
modalSendOrder.value = true;
}
onMounted(() => {
fetchList();
onMounted(async () => {
await fetchList();
});
</script>