Refactoring code module 02_organization

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-11 17:00:27 +07:00
parent 63b9aafbaf
commit 0f5d772e53
24 changed files with 805 additions and 1033 deletions

View file

@ -1,8 +1,11 @@
<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 { useOrganizational } from "@/modules/02_organization/store/organizational";
import { useCounterMixin } from "@/stores/mixin";
/** importType*/
import type {
@ -17,10 +20,6 @@ import type { FilterMaster } from "@/modules/02_organization/interface/request/o
import TreeMain from "@/modules/02_organization/components/TreeMain.vue";
import TreeTable from "@/modules/02_organization/components/TreeTable.vue";
/** importStore*/
import { useOrganizational } from "@/modules/02_organization/store/organizational";
import { useCounterMixin } from "@/stores/mixin";
/** use*/
const store = useOrganizational();
const $q = useQuasar();
@ -133,7 +132,9 @@ async function fetchDataTable(id: string, level: number, action: boolean) {
});
}
/** ดึงข้อมูลสถิติจำนวนด้านบน*/
/**
* งขอมลสถจำนวนดานบน
*/
function getSummary() {
http
.post(config.API.orgSummary, {
@ -158,13 +159,20 @@ function getSummary() {
});
}
/** funcion ค้นหาข้อมูลใน Table*/
/**
* funcion นหาขอมลใน Table
*/
async function filterKeyword() {
reqMaster.page = 1;
action1.value === false &&
fetchDataTable(reqMaster.id, reqMaster.type, false);
}
/**
* นหาโครงสรางในขอมลแบบลำดบชนเพอหาทตรงก orgTreeId
* @param data อมลโครงสราง
* @param targetId id ของโครงสรางทองการคนหา
*/
function searchAndReplaceOrgName(data: any, targetId: string) {
for (const child of data) {
if (child.orgTreeId === targetId) {
@ -179,17 +187,6 @@ function searchAndReplaceOrgName(data: any, targetId: string) {
return false; // Not found in this branch
}
/**lifecycle Hook*/
onMounted(async () => {
const id =
store.typeOrganizational === "current"
? store.activeId
: store.typeOrganizational === "draft"
? store.draftId
: historyId.value;
id && (await fetchDataTree(id));
});
/** callback function ทำงาน ทำการ fetch ข้อมูล Tree เมื่อมีการเลือกประวัติโครงสร้าง*/
watch(
() => count.value,
@ -198,7 +195,9 @@ watch(
}
);
/** callblck function ทำการ fetch ข้อมูล Tree เมื่อมีการเปลี่ยนโครงสร้าง*/
/**
* callblck function ทำการ fetch อม Tree เมอมการเปลยนโครงสราง
*/
watch(
() => store.typeOrganizational,
() => {
@ -210,13 +209,17 @@ watch(
}
);
/** callblck function ทำการ fetch ข้อมูล Table เมื่อมีการเปลี่ยนหน้า*/
/**
* callblck function ทำการ fetch อม Table เมอมการเปลยนหน
*/
watch([() => reqMaster.page, () => reqMaster.pageSize], () => {
action1.value === false &&
fetchDataTable(reqMaster.id, reqMaster.type, false);
});
/** callblck function ทำการ fetch ข้อมูล Table เมื่อแสดงตำแหน่งทั้งหมด*/
/**
* callblck function ทำการ fetch อม Table เมอแสดงตำแหนงทงหมด
*/
watch(
() => reqMaster.isAll,
() => {
@ -235,6 +238,21 @@ watch(
store.draftId && fetchDataTree(store.draftId?.toString());
}
);
/**
* lifecycle Hook ทำเม Components กเรยกใชงาน
*
* และดงชอมลโครงสรางตาม ID ของประเภทโครงสราง จจ,แบบราง
*/
onMounted(async () => {
const id =
store.typeOrganizational === "current"
? store.activeId
: store.typeOrganizational === "draft"
? store.draftId
: historyId.value;
id && (await fetchDataTree(id));
});
</script>
<template>