diff --git a/src/api/02_organizational/api.organization.ts b/src/api/02_organizational/api.organization.ts index c5e6cd258..5ca74825d 100644 --- a/src/api/02_organizational/api.organization.ts +++ b/src/api/02_organizational/api.organization.ts @@ -39,4 +39,5 @@ export default { orgSearchProfile: `${orgProfile}/search`, orgProfile: `${orgPos}/profile`, orgDeleteProfile: (id: string) => `${orgPos}/profile/delete/${id}`, + orgSummary: `${orgPos}/summary`, }; diff --git a/src/modules/02_organizationalNew/components/DialogFormPosition.vue b/src/modules/02_organizationalNew/components/DialogFormPosition.vue index cf5ec98e3..a9d0551a5 100644 --- a/src/modules/02_organizationalNew/components/DialogFormPosition.vue +++ b/src/modules/02_organizationalNew/components/DialogFormPosition.vue @@ -33,6 +33,7 @@ const props = defineProps({ actionType: String, rowId: String, fetchDataTable: Function, + getSummary: Function, }); const modalAdd = ref(false); @@ -376,6 +377,7 @@ function onSubmit() { reqMaster.value.type, false ); + props.getSummary?.(); }) .catch((err) => { messageError($q, err); diff --git a/src/modules/02_organizationalNew/components/DialogSelectPerson.vue b/src/modules/02_organizationalNew/components/DialogSelectPerson.vue index d99de44ee..a4d38275e 100644 --- a/src/modules/02_organizationalNew/components/DialogSelectPerson.vue +++ b/src/modules/02_organizationalNew/components/DialogSelectPerson.vue @@ -52,6 +52,10 @@ const props = defineProps({ type: Function, required: true, }, + getSummary: { + type: Function, + required: true, + }, dataDetailPos: { type: Object, require: true }, }); @@ -290,6 +294,7 @@ function onSubmit() { .post(config.API.orgProfile, body) .then(() => { props.fetchDataTable?.(store.treeId, store.level, false); + props.getSummary(); success($q, "บันทึกข้อมูลสำเร็จ"); }) .catch((err) => { diff --git a/src/modules/02_organizationalNew/components/mainTree.vue b/src/modules/02_organizationalNew/components/mainTree.vue index 09c97bb0c..9d0fb2102 100644 --- a/src/modules/02_organizationalNew/components/mainTree.vue +++ b/src/modules/02_organizationalNew/components/mainTree.vue @@ -105,18 +105,29 @@ function updateSelected(data: DataTree) { nodeId.value = data.orgTreeId ? data.orgTreeId : "111"; data.orgTreeId && props.fetchDataTable?.(data.orgTreeId, data.orgLevel, true); - store.getSumPosition({ - totalPosition: data.totalPosition, - totalPositionCurrentUse: data.totalPositionCurrentUse, - totalPositionCurrentVacant: data.totalPositionCurrentVacant, - totalPositionNextUse: data.totalPositionNextUse, - totalPositionNextVacant: data.totalPositionNextVacant, - totalRootPosition: data.totalRootPosition, - totalRootPositionCurrentUse: data.totalRootPositionCurrentUse, - totalRootPositionCurrentVacant: data.totalRootPositionCurrentVacant, - totalRootPositionNextUse: data.totalRootPositionNextUse, - totalRootPositionNextVacant: data.totalRootPositionNextVacant, - }); + /** ดึงข้อมูลสถิติจำนวนด้านบน*/ + http + .post(config.API.orgSummary, { + id: data.orgTreeId, //*Id node + type: data.orgLevel, //*ประเภทnode + isNode: false, //*นับทั้ง node ไหม + }) + .then(async (res: any) => { + const data = await res.data.result; + + 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, + }); + }); // } } diff --git a/src/modules/02_organizationalNew/components/tableTree.vue b/src/modules/02_organizationalNew/components/tableTree.vue index 874de01d5..670f9973d 100644 --- a/src/modules/02_organizationalNew/components/tableTree.vue +++ b/src/modules/02_organizationalNew/components/tableTree.vue @@ -268,6 +268,7 @@ function onClickDelete(id: string) { .then(() => { success($q, "ลบข้อมูลสำเร็จ"); props.fetchDataTable?.(reqMaster.value.id, reqMaster.value.type, false); + getSummary(); }) .catch((err) => { messageError($q, err); @@ -336,6 +337,7 @@ function removePerson(id: string) { reqMaster.value.type, false ); + getSummary(); }) .catch((err) => { messageError($q, err); @@ -348,6 +350,39 @@ function removePerson(id: string) { "ต้องการยืนยันการลบคนครองนี้ใช่หรือไม่?" ); } + +/** ดึงข้อมูลสถิติจำนวนด้านบน*/ +function getSummary() { + showLoader(); + http + .post(config.API.orgSummary, { + id: reqMaster.value.id, //*Id node + type: reqMaster.value.type, //*ประเภทnode + isNode: reqMaster.value.isAll, //*นับทั้ง node ไหม + }) + .then(async (res: any) => { + const data = await res.data.result; + + 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); + }) + .finally(() => { + hideLoader(); + }); +}