refactor: handle input rules

This commit is contained in:
Thanaphon Frappet 2024-11-29 13:57:19 +07:00
parent 9fa735c529
commit 0d72c5eee6
2 changed files with 39 additions and 0 deletions

View file

@ -263,6 +263,9 @@ watch(
(v) => (typeof v === 'string' ? (workerStatus = v) : '')
"
@clear="workerStatus = ''"
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
>
<template v-slot:no-option>
<q-item>
@ -384,6 +387,9 @@ watch(
@update:model-value="
(v) => (typeof v === 'string' ? (firstNameEN = v.trim()) : '')
"
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
/>
<q-input
@ -412,6 +418,9 @@ watch(
@update:model-value="
(v) => (typeof v === 'string' ? (lastNameEN = v.trim()) : '')
"
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
/>
<q-input
@ -530,6 +539,9 @@ watch(
typeof v === 'string' ? (birthCountry = nationality = v) : ''
"
@clear="nationality = ''"
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
>
<template v-slot:no-option>
<q-item>

View file

@ -188,6 +188,9 @@ watch(
(v) => (typeof v === 'string' ? (workerType = v) : '')
"
@clear="workerType = ''"
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
>
<template v-slot:no-option>
<q-item>
@ -224,6 +227,9 @@ watch(
@update:model-value="
(v) => (typeof v === 'string' ? (issuePlace = v) : '')
"
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
/>
<q-select
@ -314,6 +320,9 @@ watch(
}
}
"
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
clearable
/>
</div>
@ -330,6 +339,9 @@ watch(
((issueDate && new Date(issueDate).getTime()) || Date.now())
"
clearable
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
/>
</div>
<div class="col">
@ -356,6 +368,9 @@ watch(
@update:model-value="
(v) => (typeof v === 'string' ? (arrivalTMNo = v) : '')
"
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
/>
<DatePicker
@ -365,6 +380,9 @@ watch(
:label="$t('customerEmployee.form.visaEnter')"
v-model="arrivalTM"
clearable
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
/>
<q-input
@ -379,6 +397,9 @@ watch(
@update:model-value="
(v) => (typeof v === 'string' ? (arrivalAt = v) : '')
"
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
/>
<q-select
@ -406,6 +427,9 @@ watch(
(v) => (typeof v === 'string' ? (issueCountry = v) : '')
"
@clear="type = ''"
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
>
<template v-slot:no-option>
<q-item>
@ -427,6 +451,9 @@ watch(
v-model="entryCount"
type="number"
min="0"
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
]"
/>
</div>
</div>