diff --git a/src/modules/02_users/components/RoleOrganization/DialogAddPerson.vue b/src/modules/02_users/components/RoleOrganization/DialogAddPerson.vue
index 9fa24abc..f56d3132 100644
--- a/src/modules/02_users/components/RoleOrganization/DialogAddPerson.vue
+++ b/src/modules/02_users/components/RoleOrganization/DialogAddPerson.vue
@@ -1,5 +1,5 @@
diff --git a/src/modules/02_users/components/RolePositionSalary/DialogAddPerson.vue b/src/modules/02_users/components/RolePositionSalary/DialogAddPerson.vue
index 84e8908d..6df8271f 100644
--- a/src/modules/02_users/components/RolePositionSalary/DialogAddPerson.vue
+++ b/src/modules/02_users/components/RolePositionSalary/DialogAddPerson.vue
@@ -1,5 +1,5 @@
diff --git a/src/modules/02_users/views/01_user.vue b/src/modules/02_users/views/01_user.vue
index 9d188adc..fb37c2b6 100644
--- a/src/modules/02_users/views/01_user.vue
+++ b/src/modules/02_users/views/01_user.vue
@@ -232,8 +232,7 @@ async function fetchOrganizationActive() {
* @param id id โครงสร้าง
*/
async function fetchDataTree(id: string) {
- const tokenParsedData = await tokenParsed();
- const isSuperAdmin = tokenParsedData.role.includes("SUPER_ADMIN");
+ const isSuperAdmin = tokenParsedData.value.includes("SUPER_ADMIN");
if (!isSuperAdmin) {
nodeTree.value = [];
}
@@ -436,13 +435,18 @@ watch(
}
);
+const tokenParsedData = ref([]);
/**
* ตรวจสอบการแสดงปุ่ม action
* @param keycloakID keycloakID รหัสผู้ใช้งาน
* @returns true หากผู้ใช้งานมีสิทธิ์ในการดำเนินการ
*/
function checkhideBtnAction(keycloakID: string) {
- if (dataPosition.value?.keycloak === keycloakID) {
+ if (
+ dataPosition.value?.keycloak === keycloakID &&
+ tokenParsedData.value.includes("ADMIN") &&
+ !tokenParsedData.value.includes("SUPER_ADMIN")
+ ) {
return false;
} else {
return true;
@@ -455,6 +459,8 @@ function checkhideBtnAction(keycloakID: string) {
*/
onMounted(async () => {
await fetchOrganizationActive();
+ const token = await tokenParsed();
+ tokenParsedData.value = token.role || [];
});
diff --git a/src/modules/02_users/views/03_permissionsView.vue b/src/modules/02_users/views/03_permissionsView.vue
index 81594e0d..4d05e2ff 100644
--- a/src/modules/02_users/views/03_permissionsView.vue
+++ b/src/modules/02_users/views/03_permissionsView.vue
@@ -286,13 +286,13 @@ async function fetchOrganizationActive() {
});
}
+const tokenParsedData = ref([]);
/**
* function fetch ข้อมูลของ Tree
* @param id id โครงสร้าง
*/
async function fetchDataTree(id: string) {
- const tokenParsedData = await tokenParsed();
- const isSuperAdmin = tokenParsedData.role.includes("SUPER_ADMIN");
+ const isSuperAdmin = tokenParsedData.value.includes("SUPER_ADMIN");
if (!isSuperAdmin) {
nodes.value = [];
} else {
@@ -501,15 +501,21 @@ function isUpload() {
* @returns true หากผู้ใช้งานมีสิทธิ์ในการดำเนินการ
*/
function checkhideBtnAction(current_holderId: string) {
- if (dataPosition.value?.profileId === current_holderId) {
+ if (
+ dataPosition.value?.profileId === current_holderId &&
+ tokenParsedData.value.includes("ADMIN") &&
+ !tokenParsedData.value.includes("SUPER_ADMIN")
+ ) {
return false;
} else {
return true;
}
}
-onMounted(() => {
+onMounted(async () => {
fetchOrganizationActive();
+ const token = await tokenParsed();
+ tokenParsedData.value = token.role || [];
});
diff --git a/src/modules/02_users/views/04_roleOrganization.vue b/src/modules/02_users/views/04_roleOrganization.vue
index fe5b5b43..cdc5c406 100644
--- a/src/modules/02_users/views/04_roleOrganization.vue
+++ b/src/modules/02_users/views/04_roleOrganization.vue
@@ -63,9 +63,8 @@ const personId = ref("");
* ฟังก์ชันดึงข้อมูลโครงสร้าง
* เก็บข้อมูลโครงสร้างไว้ใน nodeTree
*/
-async function fatchOrg() {
- const tokenParsedData = await tokenParsed();
- const isSuperAdmin = tokenParsedData.role.includes("SUPER_ADMIN");
+async function fetchOrg() {
+ const isSuperAdmin = tokenParsedData.value.includes("SUPER_ADMIN");
if (!isSuperAdmin) {
nodeTree.value = [];
}
@@ -215,8 +214,13 @@ function updatemodalPersonal(modal: boolean) {
modalPersonal.value = modal;
}
+const tokenParsedData = ref([]);
function checkhideBtnAction(id: string) {
- if (dataPosition.value?.profileId === id) {
+ if (
+ dataPosition.value?.profileId === id &&
+ tokenParsedData.value.includes("ADMIN") &&
+ !tokenParsedData.value.includes("SUPER_ADMIN")
+ ) {
return false;
} else {
return true;
@@ -236,7 +240,9 @@ watch(
/** hook ทำงานเมื่อ Components ถูกเรียกใช้งาน*/
onMounted(async () => {
- await fatchOrg(); // ดึงข้อมูลโครงสร้าง
+ await fetchOrg(); // ดึงข้อมูลโครงสร้าง
+ const token = await tokenParsed();
+ tokenParsedData.value = token?.role || [];
});
diff --git a/src/modules/02_users/views/05_responsIbilities.vue b/src/modules/02_users/views/05_responsIbilities.vue
index 110d803e..70e0bd21 100644
--- a/src/modules/02_users/views/05_responsIbilities.vue
+++ b/src/modules/02_users/views/05_responsIbilities.vue
@@ -273,13 +273,13 @@ async function fetchOrganizationActive() {
});
}
+const tokenParsedData = ref([]);
/**
* function fetch ข้อมูลของ Tree
* @param id id โครงสร้าง
*/
async function fetchDataTree(id: string) {
- const tokenParsedData = await tokenParsed();
- const isSuperAdmin = tokenParsedData.role.includes("SUPER_ADMIN");
+ const isSuperAdmin = tokenParsedData.value.includes("SUPER_ADMIN");
if (!isSuperAdmin) {
nodes.value = [];
}
@@ -411,7 +411,11 @@ function updatemodalPersonal(modal: boolean) {
}
function hideBtnAction(id: string) {
- if (dataPosition.value?.profileId === id) {
+ if (
+ dataPosition.value?.profileId === id &&
+ tokenParsedData.value.includes("ADMIN") &&
+ !tokenParsedData.value.includes("SUPER_ADMIN")
+ ) {
return false;
} else {
return true;
@@ -432,8 +436,10 @@ watch(
}
);
-onMounted(() => {
+onMounted(async () => {
fetchOrganizationActive();
+ const token = await tokenParsed();
+ tokenParsedData.value = token?.role || [];
});
diff --git a/src/modules/02_users/views/06_rolePositionSalary.vue b/src/modules/02_users/views/06_rolePositionSalary.vue
index ba59b1bc..d686c192 100644
--- a/src/modules/02_users/views/06_rolePositionSalary.vue
+++ b/src/modules/02_users/views/06_rolePositionSalary.vue
@@ -82,13 +82,13 @@ async function fatchOrg() {
});
}
+const tokenParsedData = ref([]);
/**
* function fetch ข้อมูลของ Tree
* @param id id โครงสร้าง
*/
async function fetchDataTree(id: string) {
- const tokenParsedData = await tokenParsed();
- const isSuperAdmin = tokenParsedData.role.includes("SUPER_ADMIN");
+ const isSuperAdmin = tokenParsedData.value.includes("SUPER_ADMIN");
if (!isSuperAdmin) {
nodeTree.value = [];
}
@@ -260,7 +260,11 @@ function updatemodalPersonal(modal: boolean) {
}
function hideBtnAction(id: string) {
- if (dataPosition.value?.profileId === id) {
+ if (
+ dataPosition.value?.profileId === id &&
+ tokenParsedData.value.includes("ADMIN") &&
+ !tokenParsedData.value.includes("SUPER_ADMIN")
+ ) {
return false;
} else {
return true;
@@ -281,6 +285,8 @@ watch(
/** hook ทำงานเมื่อ Components ถูกเรียกใช้งาน*/
onMounted(async () => {
await fatchOrg(); // ดึงข้อมูลโครงสร้าง
+ const token = await tokenParsed();
+ tokenParsedData.value = token?.role || [];
});