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

@ -286,13 +286,13 @@ async function fetchOrganizationActive() {
});
}
const tokenParsedData = ref<string[]>([]);
/**
* 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 || [];
});
</script>