fix bug: "ADMIN" only disable action

This commit is contained in:
Warunee Tamkoo 2025-11-08 21:35:03 +07:00
parent 3856035ce1
commit d4b61dd490
7 changed files with 75 additions and 23 deletions

View file

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