diff --git a/src/modules/21_report/components/01_org/Main.vue b/src/modules/21_report/components/01_org/Main.vue
index 40512081d..1a408ecee 100644
--- a/src/modules/21_report/components/01_org/Main.vue
+++ b/src/modules/21_report/components/01_org/Main.vue
@@ -1,5 +1,5 @@
@@ -264,11 +102,8 @@ onMounted(async () => {
@@ -294,36 +129,18 @@ onMounted(async () => {
@@ -331,19 +148,7 @@ onMounted(async () => {
diff --git a/src/modules/21_report/components/01_org/TableMain.vue b/src/modules/21_report/components/01_org/TableMain.vue
index eaf4ec504..21689f88d 100644
--- a/src/modules/21_report/components/01_org/TableMain.vue
+++ b/src/modules/21_report/components/01_org/TableMain.vue
@@ -1,5 +1,5 @@
diff --git a/src/modules/21_report/components/01_org/TreeMain.vue b/src/modules/21_report/components/01_org/TreeMain.vue
index 96279f6a9..4f7e9feed 100644
--- a/src/modules/21_report/components/01_org/TreeMain.vue
+++ b/src/modules/21_report/components/01_org/TreeMain.vue
@@ -19,7 +19,7 @@ import { useCounterMixin } from "@/stores/mixin";
/** use*/
const $q = useQuasar();
const store = useOrganizational();
-const { showLoader } = useCounterMixin();
+const { showLoader, hideLoader, messageError } = useCounterMixin();
/** props*/
const nodeTEST = defineModel("nodeTree", { default: [] });
@@ -27,17 +27,6 @@ const nodeId = defineModel("nodeId", { required: true });
const orgRootId = defineModel("orgRootId", {
required: true,
});
-const shortName = defineModel("shortName", { required: true });
-const props = defineProps({
- fetchDataTree: {
- type: Function,
- require: true,
- },
- fetchDataTable: {
- type: Function,
- require: true,
- },
-});
const filter = ref("");
const nodes = ref>([]);
@@ -51,50 +40,31 @@ const orgLevel = ref(0);
* funtion เลือกข้อมูล Tree
* @param data ข่อมูล Tree
*/
-function updateSelected(data: DataTree) {
- orgRootId.value = data?.orgLevel === 0 ? data?.orgTreeId : data?.orgRootId;
- store.rootId = (
- data.orgLevel === 0 ? data.orgTreeId : data.orgRootId
- ) as string;
- shortName.value = data.orgTreeShortName;
+async function updateSelected(data: DataTree) {
+ showLoader();
+ try {
+ orgRootId.value = data?.orgLevel === 0 ? data?.orgTreeId : data?.orgRootId;
+ store.rootId = (
+ data.orgLevel === 0 ? data.orgTreeId : data.orgRootId
+ ) as string;
- if (!store.treeId || store.treeId != data.orgTreeId) {
- store.treeId = data.orgTreeId;
- store.level = data.orgLevel;
+ if (!store.treeId || store.treeId != data.orgTreeId) {
+ store.treeId = data.orgTreeId;
+ store.level = data.orgLevel;
- nodeId.value = data.orgTreeId ? data.orgTreeId : "111";
+ nodeId.value = data.orgTreeId ? data.orgTreeId : "";
- data.orgTreeId &&
- props.fetchDataTable?.(data.orgTreeId, data.orgLevel, true);
- /** ดึงข้อมูลสถิติจำนวนด้านบน*/
- http
- .post(config.API.orgSummary, {
- id: data.orgTreeId, //*Id node
- type: data.orgLevel, //*ประเภทnode
- isNode: true, //*นับทั้ง node ไหม
- })
- .then(async (res: any) => {
- const data = await res.data.result;
- if (data) {
- store.getSumPosition({
- totalPosition: data.totalPosition,
- totalPositionCurrentUse: data.totalPositionCurrentUse,
- totalPositionCurrentVacant: data.totalPositionCurrentVacant,
- totalPositionNextUse: data.totalPositionNextUse,
- totalPositionNextVacant: data.totalPositionNextVacant,
- totalRootPosition: data.totalPosition,
- totalRootPositionCurrentUse: data.totalPositionCurrentUse,
- totalRootPositionCurrentVacant: data.totalPositionCurrentVacant,
- totalRootPositionNextUse: data.totalPositionNextUse,
- totalRootPositionNextVacant: data.totalPositionNextVacant,
- });
- }
- });
+ /** ดึงข้อมูลสถิติจำนวนด้านบน*/
+ await fetchSummary(data);
+ }
+ } catch (error) {
+ console.error("Error showing loader:", error);
+ } finally {
+ hideLoader();
}
}
const treeId = ref("");
-
const dialogDetail = ref(false);
/**
* funtion ดูรายละเอียดโครงสร้าง
@@ -108,6 +78,39 @@ function onClickDetail(id: string, level: number) {
orgLevel.value = level;
}
+/**
+ * ฟังก์ชันดึงข้อมูลสถิติ
+ * @param data ขอมูลโครงสร้าง
+ */
+async function fetchSummary(data: DataTree) {
+ await http
+ .post(config.API.orgSummary, {
+ id: data.orgTreeId, //*Id node
+ type: data.orgLevel, //*ประเภทnode
+ isNode: true, //*นับทั้ง node ไหม
+ })
+ .then(async (res: any) => {
+ const data = await res.data.result;
+ if (data) {
+ store.getSumPosition({
+ totalPosition: data.totalPosition,
+ totalPositionCurrentUse: data.totalPositionCurrentUse,
+ totalPositionCurrentVacant: data.totalPositionCurrentVacant,
+ totalPositionNextUse: data.totalPositionNextUse,
+ totalPositionNextVacant: data.totalPositionNextVacant,
+ totalRootPosition: data.totalPosition,
+ totalRootPositionCurrentUse: data.totalPositionCurrentUse,
+ totalRootPositionCurrentVacant: data.totalPositionCurrentVacant,
+ totalRootPositionNextUse: data.totalPositionNextUse,
+ totalRootPositionNextVacant: data.totalPositionNextVacant,
+ });
+ }
+ })
+ .catch((err) => {
+ messageError($q, err);
+ });
+}
+
watch(
() => nodeTEST.value,
() => {
diff --git a/src/modules/21_report/views/01_reportOrg.vue b/src/modules/21_report/views/01_reportOrg.vue
index 76866448c..cd534a6a7 100644
--- a/src/modules/21_report/views/01_reportOrg.vue
+++ b/src/modules/21_report/views/01_reportOrg.vue
@@ -1,5 +1,5 @@