From e043a3c9cc8b4e5b66b37c3a4073f56bf3c5f0c6 Mon Sep 17 00:00:00 2001 From: setthawutttty Date: Fri, 25 Oct 2024 17:43:51 +0700 Subject: [PATCH] isOfficer --- .../components/Other/OtherDetail.vue | 27 ++++++++-- .../PersonalList/PersonalListPage.vue | 5 +- .../components/PersonalList/Table.vue | 53 ++++++++++++------- src/modules/05_placement/store.ts | 26 +++++---- 4 files changed, 74 insertions(+), 37 deletions(-) diff --git a/src/modules/05_placement/components/Other/OtherDetail.vue b/src/modules/05_placement/components/Other/OtherDetail.vue index 3b768f9a3..04204d097 100644 --- a/src/modules/05_placement/components/Other/OtherDetail.vue +++ b/src/modules/05_placement/components/Other/OtherDetail.vue @@ -32,6 +32,9 @@ const { success, } = mixin; +const isOfficer = ref(null); +const isStaff = ref(null); + const paramsId = route.params.id; const myForm = ref(null); const roleAdmin = ref(false); @@ -140,11 +143,27 @@ const getClass = (val: boolean) => { }; }; +async function getWorkFlow() { + showLoader(); + await http + .get(config.API.workflowKeycloakSystem("ORG_COMMAND")) + .then(async (res) => { + const data = await res.data.result; + isOfficer.value = data.isOfficer; + isStaff.value = data.isStaff; + roleAdmin.value = data.isOfficer; + hideLoader(); + }) + .catch((e) => { + messageError($q, e); + hideLoader(); + }) + .finally(() => {}); +} + onMounted(async () => { - const user = await tokenParsed(); - if (user) { - roleAdmin.value = await user.role.includes("placement1"); - } + getWorkFlow(); + fetchData(); }); diff --git a/src/modules/05_placement/components/PersonalList/PersonalListPage.vue b/src/modules/05_placement/components/PersonalList/PersonalListPage.vue index 2534653bc..2606b1863 100644 --- a/src/modules/05_placement/components/PersonalList/PersonalListPage.vue +++ b/src/modules/05_placement/components/PersonalList/PersonalListPage.vue @@ -83,9 +83,8 @@ onMounted(async () => { await fetchPlacementData(); } - const user = await tokenParsed(); - if (user) { - roleAdmin.value = await user.role.includes("placement1"); + if (DataStore.isOfficer) { + roleAdmin.value = DataStore.isOfficer; } await getStat(); diff --git a/src/modules/05_placement/components/PersonalList/Table.vue b/src/modules/05_placement/components/PersonalList/Table.vue index 5a7606396..82cda3075 100644 --- a/src/modules/05_placement/components/PersonalList/Table.vue +++ b/src/modules/05_placement/components/PersonalList/Table.vue @@ -779,26 +779,41 @@ watch(containStatus, () => { } }); +async function getWorkFlow() { + showLoader(); + await http + .get(config.API.workflowKeycloakSystem("ORG_COMMAND")) + .then(async (res) => { + const data = await res.data.result; + DataStore.isOfficer = data.isOfficer; + DataStore.isStaff = data.isStaff; + roleAdmin.value = data.isOfficer; + if (roleAdmin.value === false) { + displayAdd.value = false; + visibleColumns.value = [ + "position", + "fullName", + "examNumber", + "idCard", + "positionNumber", + "organizationName", + "reportingDate", + "bmaOfficer", + "statusName", + "positionCandidate", + ]; + } + hideLoader(); + }) + .catch((e) => { + messageError($q, e); + hideLoader(); + }) + .finally(() => {}); +} + onMounted(async () => { - const user = await tokenParsed(); - if (user) { - roleAdmin.value = await user.role.includes("placement1"); - if (roleAdmin.value === false) { - displayAdd.value = false; - visibleColumns.value = [ - "position", - "fullName", - "examNumber", - "idCard", - "positionNumber", - "organizationName", - "reportingDate", - "bmaOfficer", - "statusName", - "positionCandidate", - ]; - } - } + await getWorkFlow(); await getTable(); }); diff --git a/src/modules/05_placement/store.ts b/src/modules/05_placement/store.ts index 8b63d0a25..bb3e08d5a 100644 --- a/src/modules/05_placement/store.ts +++ b/src/modules/05_placement/store.ts @@ -89,6 +89,8 @@ export const useProfileDataStore = defineStore("profilePlacenent", () => { export const usePlacementDataStore = defineStore("placement", () => { const mixin = useCounterMixin(); //เรียกฟังก์ชันกลาง const tabsMain = ref("probation"); + const isOfficer = ref(null); + const isStaff = ref(null); const { hideLoader } = mixin; interface placement { mappingPosition: { columns: String[] }; @@ -209,7 +211,9 @@ export const usePlacementDataStore = defineStore("placement", () => { DataMain, DataUpdateMain, checkLoad, - tabsMain + tabsMain, + isOfficer, + isStaff, }; }); export const useOrderPlacementDataStore = defineStore("placementOrder", () => { @@ -312,43 +316,43 @@ export const useOrderPlacementDataStore = defineStore("placementOrder", () => { export const useTransferDataStore = defineStore("transferDataStore", () => { const optionStatusProbation = ref([ { - id: '', + id: "", value: "ทั้งหมด", }, { - id: '1', + id: "1", value: "อยู่ระหว่างการทดลองปฏิบัติหน้าที่ราชการ", }, { - id: '2', + id: "2", value: "พ้นการทดลองปฏิบัติหน้าที่ราชการ", }, { - id: '3', + id: "3", value: "ไม่พ้นการทดลองปฏิบัติหน้าที่ราชการ", }, { - id: '4', + id: "4", value: "ยุติการทดลองปฏิบัติหน้าที่ราชการเนื่องจากเปลี่ยนตำแหน่ง", }, { - id: '5', + id: "5", value: "ยุติการทดลองปฏิบัติหน้าที่ราชการเนื่องจากลาออก", }, { - id: '6', + id: "6", value: "ยุติการทดลองปฏิบัติหน้าที่ราชการเนื่องจากถึงแก่กรรม", }, { - id: '7', + id: "7", value: "ขยายระยะเวลาทดลองปฏิบัติหน้าที่ราชการ", }, { - id: '8', + id: "8", value: "ส่งรายชื่อไปออกคำสั่ง", }, { - id: '9', + id: "9", value: "ออกคำสั่งเสร็จแล้ว", }, ]);