fix: ตรวจสอบ input

This commit is contained in:
Net 2024-07-10 12:52:27 +07:00
parent 6e27e51bba
commit 19c928bab4
2 changed files with 16 additions and 2 deletions

View file

@ -1,4 +1,5 @@
<script setup lang="ts">
import { getRole } from 'src/services/keycloak';
import { ref, onMounted } from 'vue';
import { useI18n } from 'vue-i18n';
const { locale } = useI18n({ useScope: 'global' });
@ -85,7 +86,13 @@ onMounted(async () => {
option-value="id"
v-model="registeredBranchId"
:options="optionsBranch"
:rules="[(val) => !!val]"
:rules="[
(val) => {
const roles = getRole() || [];
const isSpecialRole = ['admin', 'system', 'head_of_admin'].some(role => roles.includes(role));
return isSpecialRole || !!val || 'กรุณากรอกข้อมูล';
}
]"
/>
<q-input

View file

@ -1,4 +1,5 @@
<script setup lang="ts">
import { getRole } from 'src/services/keycloak';
import useOptionStore from 'src/stores/options';
import { onMounted } from 'vue';
@ -109,7 +110,13 @@ onMounted( async() => {
option-value="id"
v-model="registeredBranchId"
:options="optionsBranch"
:rules="[(val) => !!val]"
:rules="[
(val) => {
const roles = getRole() || [];
const isSpecialRole = ['admin', 'system', 'head_of_admin'].some(role => roles.includes(role));
return isSpecialRole || !!val || 'กรุณากรอกข้อมูล';
}
]"
/>
<q-input