refactor: chech role

This commit is contained in:
Thanaphon Frappet 2024-12-10 15:29:05 +07:00
parent 1df80aeb02
commit db12f4f75e
2 changed files with 18 additions and 83 deletions

View file

@ -1,5 +1,6 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { getRole } from 'src/services/keycloak';
import { createSelect, SelectProps } from './select';
import SelectInput from '../SelectInput.vue';
@ -29,6 +30,7 @@ type ExclusiveProps = {
codeOnly?: boolean;
selectFirstValue?: boolean;
branchVirtual?: boolean;
checkRole?: string[];
};
const props = defineProps<SelectProps<typeof getList> & ExclusiveProps>();
@ -98,7 +100,12 @@ function setDefaultValue() {
"
:hide-selected="false"
:fill-input="false"
:rules="[(v: string) => !!v || $t('form.error.required')]"
:rules="[
(v: string) =>
checkRole?.some((v) => getRole()?.includes(v)) ||
!!v ||
$t('form.error.required'),
]"
@filter="filter"
>
<template #append v-if="clearable">