Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 2m0s

* develop:
  fix bug: "ADMIN" only disable action
This commit is contained in:
Warunee Tamkoo 2025-11-08 21:35:20 +07:00
commit 3d238d2400
7 changed files with 75 additions and 23 deletions

View file

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { reactive, ref, watch } from "vue"; import { reactive, ref, watch, onMounted } from "vue";
import { useQuasar } from "quasar"; import { useQuasar } from "quasar";
import { storeToRefs } from "pinia"; import { storeToRefs } from "pinia";
@ -8,6 +8,7 @@ import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
import { useDataStoreUser } from "@/modules/02_users/stores/main"; import { useDataStoreUser } from "@/modules/02_users/stores/main";
import { usekeycloakPosition } from "@/stores/keycloakPosition"; import { usekeycloakPosition } from "@/stores/keycloakPosition";
import { tokenParsed } from "@/plugins/auth";
import type { QTableProps } from "quasar"; import type { QTableProps } from "quasar";
import type { import type {
@ -171,12 +172,17 @@ function onClose() {
selected.value = []; selected.value = [];
} }
const tokenParsedData = ref<string[]>([]);
/** /**
* อน checkbox ของผใชงานทกำลงลอกอนอย * อน checkbox ของผใชงานทกำลงลอกอนอย
* @param id รหสผใชงาน * @param id รหสผใชงาน
*/ */
function hideCheckbox(id: string) { function hideCheckbox(id: string) {
if (dataPosition.value?.profileId === id) { if (
dataPosition.value?.profileId === id &&
tokenParsedData.value.includes("ADMIN") &&
!tokenParsedData.value.includes("SUPER_ADMIN")
) {
return false; return false;
} else { } else {
return true; return true;
@ -194,6 +200,11 @@ watch(
onSearchListPerson(true); onSearchListPerson(true);
} }
); );
onMounted(async () => {
const token = await tokenParsed();
tokenParsedData.value = token?.role || [];
});
</script> </script>
<template> <template>

View file

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { reactive, ref, watch } from "vue"; import { reactive, ref, watch, onMounted } from "vue";
import { useQuasar } from "quasar"; import { useQuasar } from "quasar";
import { storeToRefs } from "pinia"; import { storeToRefs } from "pinia";
@ -8,6 +8,7 @@ import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
import { useDataStoreUser } from "@/modules/02_users/stores/main"; import { useDataStoreUser } from "@/modules/02_users/stores/main";
import { usekeycloakPosition } from "@/stores/keycloakPosition"; import { usekeycloakPosition } from "@/stores/keycloakPosition";
import { tokenParsed } from "@/plugins/auth";
import type { QTableProps } from "quasar"; import type { QTableProps } from "quasar";
import type { import type {
@ -187,12 +188,17 @@ function onClose() {
isCheck.value = false; isCheck.value = false;
} }
const tokenParsedData = ref<string[]>([]);
/** /**
* อน checkbox ของผใชงานทกำลงลอกอนอย * อน checkbox ของผใชงานทกำลงลอกอนอย
* @param id รหสผใชงาน * @param id รหสผใชงาน
*/ */
function hideCheckbox(id: string) { function hideCheckbox(id: string) {
if (dataPosition.value?.profileId === id) { if (
dataPosition.value?.profileId === id &&
tokenParsedData.value.includes("ADMIN") &&
!tokenParsedData.value.includes("SUPER_ADMIN")
) {
return false; return false;
} else { } else {
return true; return true;
@ -210,6 +216,11 @@ watch(
onSearchListPerson(true); onSearchListPerson(true);
} }
); );
onMounted(async () => {
const token = await tokenParsed();
tokenParsedData.value = token?.role || [];
});
</script> </script>
<template> <template>

View file

@ -232,8 +232,7 @@ async function fetchOrganizationActive() {
* @param id id โครงสราง * @param id id โครงสราง
*/ */
async function fetchDataTree(id: string) { async function fetchDataTree(id: string) {
const tokenParsedData = await tokenParsed(); const isSuperAdmin = tokenParsedData.value.includes("SUPER_ADMIN");
const isSuperAdmin = tokenParsedData.role.includes("SUPER_ADMIN");
if (!isSuperAdmin) { if (!isSuperAdmin) {
nodeTree.value = []; nodeTree.value = [];
} }
@ -436,13 +435,18 @@ watch(
} }
); );
const tokenParsedData = ref<string[]>([]);
/** /**
* ตรวจสอบการแสดงป action * ตรวจสอบการแสดงป action
* @param keycloakID keycloakID รหสผใชงาน * @param keycloakID keycloakID รหสผใชงาน
* @returns true หากผใชงานมทธในการดำเนนการ * @returns true หากผใชงานมทธในการดำเนนการ
*/ */
function checkhideBtnAction(keycloakID: string) { 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; return false;
} else { } else {
return true; return true;
@ -455,6 +459,8 @@ function checkhideBtnAction(keycloakID: string) {
*/ */
onMounted(async () => { onMounted(async () => {
await fetchOrganizationActive(); await fetchOrganizationActive();
const token = await tokenParsed();
tokenParsedData.value = token.role || [];
}); });
</script> </script>

View file

@ -286,13 +286,13 @@ async function fetchOrganizationActive() {
}); });
} }
const tokenParsedData = ref<string[]>([]);
/** /**
* function fetch อมลของ Tree * function fetch อมลของ Tree
* @param id id โครงสราง * @param id id โครงสราง
*/ */
async function fetchDataTree(id: string) { async function fetchDataTree(id: string) {
const tokenParsedData = await tokenParsed(); const isSuperAdmin = tokenParsedData.value.includes("SUPER_ADMIN");
const isSuperAdmin = tokenParsedData.role.includes("SUPER_ADMIN");
if (!isSuperAdmin) { if (!isSuperAdmin) {
nodes.value = []; nodes.value = [];
} else { } else {
@ -501,15 +501,21 @@ function isUpload() {
* @returns true หากผใชงานมทธในการดำเนนการ * @returns true หากผใชงานมทธในการดำเนนการ
*/ */
function checkhideBtnAction(current_holderId: string) { 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; return false;
} else { } else {
return true; return true;
} }
} }
onMounted(() => { onMounted(async () => {
fetchOrganizationActive(); fetchOrganizationActive();
const token = await tokenParsed();
tokenParsedData.value = token.role || [];
}); });
</script> </script>

View file

@ -63,9 +63,8 @@ const personId = ref<string>("");
* งกนดงขอมลโครงสราง * งกนดงขอมลโครงสราง
* เกบขอมลโครงสรางไวใน nodeTree * เกบขอมลโครงสรางไวใน nodeTree
*/ */
async function fatchOrg() { async function fetchOrg() {
const tokenParsedData = await tokenParsed(); const isSuperAdmin = tokenParsedData.value.includes("SUPER_ADMIN");
const isSuperAdmin = tokenParsedData.role.includes("SUPER_ADMIN");
if (!isSuperAdmin) { if (!isSuperAdmin) {
nodeTree.value = []; nodeTree.value = [];
} }
@ -215,8 +214,13 @@ function updatemodalPersonal(modal: boolean) {
modalPersonal.value = modal; modalPersonal.value = modal;
} }
const tokenParsedData = ref<string[]>([]);
function checkhideBtnAction(id: string) { 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; return false;
} else { } else {
return true; return true;
@ -236,7 +240,9 @@ watch(
/** hook ทำงานเมื่อ Components ถูกเรียกใช้งาน*/ /** hook ทำงานเมื่อ Components ถูกเรียกใช้งาน*/
onMounted(async () => { onMounted(async () => {
await fatchOrg(); // await fetchOrg(); //
const token = await tokenParsed();
tokenParsedData.value = token?.role || [];
}); });
</script> </script>

View file

@ -273,13 +273,13 @@ async function fetchOrganizationActive() {
}); });
} }
const tokenParsedData = ref<string[]>([]);
/** /**
* function fetch อมลของ Tree * function fetch อมลของ Tree
* @param id id โครงสราง * @param id id โครงสราง
*/ */
async function fetchDataTree(id: string) { async function fetchDataTree(id: string) {
const tokenParsedData = await tokenParsed(); const isSuperAdmin = tokenParsedData.value.includes("SUPER_ADMIN");
const isSuperAdmin = tokenParsedData.role.includes("SUPER_ADMIN");
if (!isSuperAdmin) { if (!isSuperAdmin) {
nodes.value = []; nodes.value = [];
} }
@ -411,7 +411,11 @@ function updatemodalPersonal(modal: boolean) {
} }
function hideBtnAction(id: string) { 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; return false;
} else { } else {
return true; return true;
@ -432,8 +436,10 @@ watch(
} }
); );
onMounted(() => { onMounted(async () => {
fetchOrganizationActive(); fetchOrganizationActive();
const token = await tokenParsed();
tokenParsedData.value = token?.role || [];
}); });
</script> </script>

View file

@ -82,13 +82,13 @@ async function fatchOrg() {
}); });
} }
const tokenParsedData = ref<string[]>([]);
/** /**
* function fetch อมลของ Tree * function fetch อมลของ Tree
* @param id id โครงสราง * @param id id โครงสราง
*/ */
async function fetchDataTree(id: string) { async function fetchDataTree(id: string) {
const tokenParsedData = await tokenParsed(); const isSuperAdmin = tokenParsedData.value.includes("SUPER_ADMIN");
const isSuperAdmin = tokenParsedData.role.includes("SUPER_ADMIN");
if (!isSuperAdmin) { if (!isSuperAdmin) {
nodeTree.value = []; nodeTree.value = [];
} }
@ -260,7 +260,11 @@ function updatemodalPersonal(modal: boolean) {
} }
function hideBtnAction(id: string) { 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; return false;
} else { } else {
return true; return true;
@ -281,6 +285,8 @@ watch(
/** hook ทำงานเมื่อ Components ถูกเรียกใช้งาน*/ /** hook ทำงานเมื่อ Components ถูกเรียกใช้งาน*/
onMounted(async () => { onMounted(async () => {
await fatchOrg(); // await fatchOrg(); //
const token = await tokenParsed();
tokenParsedData.value = token?.role || [];
}); });
</script> </script>