refactor: handle input require name en
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 9s

This commit is contained in:
Thanaphon Frappet 2025-04-04 11:28:41 +07:00
parent 25b62de139
commit 2511690d54
2 changed files with 32 additions and 12 deletions

View file

@ -196,7 +196,11 @@ watch(
class="col" class="col"
:label="$t('personnel.form.firstName')" :label="$t('personnel.form.firstName')"
v-model="firstName" v-model="firstName"
:rules="[(val: string) => !!val || $t('form.error.required')]" :rules="
employee
? []
: [(val: string) => !!val || $t('form.error.required')]
"
/> />
<q-input <q-input
@ -289,10 +293,22 @@ watch(
class="col" class="col"
label="Surname" label="Surname"
v-model="lastNameEN" v-model="lastNameEN"
:rules="[ :rules="
(val: string) => employee
!val || /^[A-Za-z\s]+$/.test(val) || $t('form.error.letterOnly'), ? [
]" (val: string) => !!val || $t('form.error.required'),
(val: string) =>
!val ||
/^[A-Za-z\s]+$/.test(val) ||
$t('form.error.letterOnly'),
]
: [
(val: string) =>
!val ||
/^[A-Za-z\s]+$/.test(val) ||
$t('form.error.letterOnly'),
]
"
/> />
</div> </div>
@ -394,11 +410,15 @@ watch(
:readonly="readonly" :readonly="readonly"
:label="$t('form.birthDate')" :label="$t('form.birthDate')"
:disabled-dates="disabledAfterToday" :disabled-dates="disabledAfterToday"
:rules="[ :rules="
(val: string) => employee
!!val || ? []
$t('form.error.selectField', { field: $t('form.birthDate') }), : [
]" (val: string) =>
!!val ||
$t('form.error.selectField', { field: $t('form.birthDate') }),
]
"
/> />
<q-input <q-input
@ -480,7 +500,6 @@ watch(
:hide-dropdown-icon="readonly" :hide-dropdown-icon="readonly"
:for="`${prefixId}-select-gender`" :for="`${prefixId}-select-gender`"
:label="$t('form.gender')" :label="$t('form.gender')"
:rules="[(val: string) => !!val || $t('form.error.required')]"
@filter="genderFilter" @filter="genderFilter"
> >
<template v-slot:no-option> <template v-slot:no-option>
@ -513,7 +532,6 @@ watch(
:hide-dropdown-icon="readonly" :hide-dropdown-icon="readonly"
:for="`${prefixId}-select-nationality`" :for="`${prefixId}-select-nationality`"
:label="$t('general.nationality')" :label="$t('general.nationality')"
:rules="[(val: string) => !!val || $t('form.error.required')]"
@filter="nationalityFilter" @filter="nationalityFilter"
> >
<template v-slot:no-option> <template v-slot:no-option>

View file

@ -2918,6 +2918,7 @@ const emptyCreateDialog = ref(false);
class="q-mb-xl" class="q-mb-xl"
/> />
<AddressForm <AddressForm
disabledRule
id="form-personal-address" id="form-personal-address"
prefix-id="form-employee" prefix-id="form-employee"
:readonly="!employeeFormState.isEmployeeEdit" :readonly="!employeeFormState.isEmployeeEdit"
@ -4871,6 +4872,7 @@ const emptyCreateDialog = ref(false);
<AddressForm <AddressForm
id="drawer-form-personal-address" id="drawer-form-personal-address"
employee employee
disabledRule
v-model:address="currentFromDataEmployee.address" v-model:address="currentFromDataEmployee.address"
v-model:address-en="currentFromDataEmployee.addressEN" v-model:address-en="currentFromDataEmployee.addressEN"
v-model:moo="currentFromDataEmployee.moo" v-model:moo="currentFromDataEmployee.moo"