อัตรากำลังลูกจ้างประจำ ฯ ==> ปรับ โครงสร้าง

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-16 09:53:09 +07:00
parent c5262bf04d
commit d7af620b4a
3 changed files with 18 additions and 56 deletions

View file

@ -1,8 +1,10 @@
<script setup lang="ts">
import { ref, reactive, onMounted, watch } from "vue";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import { useStructureTree } from "@/stores/structureTree";
/** importType*/
import type {
@ -27,6 +29,8 @@ const store = usePositionEmp();
const $q = useQuasar();
const { showLoader, hideLoader, messageError } = useCounterMixin();
const route = useRoute();
const { fetchStructureTree } = useStructureTree();
const storeStructureTree = useStructureTree();
const nodeTree = ref<OrgTree[]>([]); // Tree
const nodeId = ref<string>(""); // id Tree
@ -54,24 +58,16 @@ const shortName = ref<string>("");
* function fetch อมลของ Tree
* @param id id โครงสราง
*/
function fetchDataTree(id: string) {
async function fetchDataTree() {
isLoadTree.value = false;
showLoader();
http
.get(config.API.orgByIdSystem(id, route.meta.Key as string))
.then((res) => {
const data = res.data.result;
nodeTree.value = data;
selected.value = "";
nodeId.value = "";
store.treeId = "";
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
const dataTree = await fetchStructureTree(route.meta.Key as string, true);
store.activeId = storeStructureTree.activeId;
if (dataTree) {
nodeTree.value = dataTree;
selected.value = "";
nodeId.value = "";
store.treeId = "";
}
}
/**
@ -186,9 +182,10 @@ function searchAndReplaceOrgName(data: any, targetId: string) {
* lifecycle Hook
*/
onMounted(() => {
setTimeout(async () => {
store.activeId && (await fetchDataTree(store.activeId));
}, 200);
fetchDataTree();
// setTimeout(async () => {
// store.activeId && (await );
// }, 200);
});
/**

View file

@ -1,42 +1,6 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
/** importComponents*/
import TreeView from "@/modules/16_positionEmployee/components/TreeView.vue";
/** importStore*/
import { usePositionEmp } from "@/modules/16_positionEmployee/store/organizational";
import { useCounterMixin } from "@/stores/mixin";
/** use*/
const $q = useQuasar();
const { showLoader, hideLoader, messageError } = useCounterMixin();
const store = usePositionEmp();
/** function เรียกข้อมูลโครงสร้าง แบบปัจุบันและ แบบร่าง*/
async function fetchOrganizationActive() {
showLoader();
await http
.get(config.API.activeOrganization)
.then((res) => {
const data = res.data.result;
if (data) {
store.fetchDataActive(data);
}
})
.catch((err) => {
messageError($q, err);
hideLoader();
});
}
/** lifecycleHook */
onMounted(async () => {
await fetchOrganizationActive();
});
</script>
<template>

View file

@ -92,6 +92,7 @@ export const useStructureTree = defineStore("structureTree", () => {
}
return {
activeId,
fetchStructureTree,
fetchTreeStrategy,
};