fix(03): form validate rule and i18n
This commit is contained in:
parent
aa42f1dcfc
commit
effa640c6d
3 changed files with 33 additions and 23 deletions
|
|
@ -121,8 +121,11 @@ watch(
|
|||
:for="`${prefixId}-select-passport-type`"
|
||||
:label="$t('customerEmployee.form.passportType')"
|
||||
:rules="[
|
||||
(val: string) =>
|
||||
!!val || $t('selectValidate') + $t('formDialogInputPassportType'),
|
||||
(val) =>
|
||||
(val && val.length > 0) ||
|
||||
$t('form.error.selectField', {
|
||||
field: $t('customerEmployee.form.passportType'),
|
||||
}),
|
||||
]"
|
||||
@filter="passportTypeFilter"
|
||||
>
|
||||
|
|
@ -143,10 +146,7 @@ watch(
|
|||
:class="{ 'col-12': ocr, 'col-6': !ocr, 'col-md-3': !ocr }"
|
||||
:label="$t('customerEmployee.form.passportNo')"
|
||||
v-model="passportNumber"
|
||||
:rules="[
|
||||
(val: string) =>
|
||||
!!val || $t('inputValidate') + $t('formDialogInputPassportNo'),
|
||||
]"
|
||||
:rules="[(val) => (val && val.length > 0) || $t('form.error.required')]"
|
||||
/>
|
||||
<q-input
|
||||
:for="`${prefixId}-input-passport-ref`"
|
||||
|
|
@ -174,10 +174,7 @@ watch(
|
|||
:class="{ 'col-12': ocr, 'col-6': !ocr, 'col-md-3': !ocr }"
|
||||
:label="$t('customerEmployee.form.passportPlace')"
|
||||
v-model="passportIssuingPlace"
|
||||
:rules="[
|
||||
(val: string) =>
|
||||
!!val || $t('inputValidate') + $t('formDialogInputWPassportPlace'),
|
||||
]"
|
||||
:rules="[(val) => (val && val.length > 0) || $t('form.error.required')]"
|
||||
/>
|
||||
<q-select
|
||||
outlined
|
||||
|
|
@ -200,9 +197,11 @@ watch(
|
|||
:for="`${prefixId}-select-passport-country`"
|
||||
:label="$t('customerEmployee.form.passportIssuer')"
|
||||
:rules="[
|
||||
(val: string) =>
|
||||
!!val ||
|
||||
$t('selectValidate') + $t('formDialogInputPassportCountry'),
|
||||
(val) =>
|
||||
(val && val.length > 0) ||
|
||||
$t('form.error.selectField', {
|
||||
field: $t('customerEmployee.form.passportIssuer'),
|
||||
}),
|
||||
]"
|
||||
@filter="passportIssuingCountryFilter"
|
||||
>
|
||||
|
|
@ -222,9 +221,11 @@ watch(
|
|||
:class="{ 'col-md-3': !ocr }"
|
||||
:readonly="readonly"
|
||||
:rules="[
|
||||
(val: string) =>
|
||||
!!val ||
|
||||
$t('selectValidate') + $t('formDialogInputPassportIssuance'),
|
||||
(val) =>
|
||||
(val && val.length > 0) ||
|
||||
$t('form.error.selectField', {
|
||||
field: $t('customerEmployee.form.passportIssueDate'),
|
||||
}),
|
||||
]"
|
||||
/>
|
||||
<DatePicker
|
||||
|
|
@ -235,8 +236,11 @@ watch(
|
|||
:class="{ 'col-md-3': !ocr }"
|
||||
:readonly="readonly"
|
||||
:rules="[
|
||||
(val: string) =>
|
||||
!!val || $t('selectValidate') + $t('formDialogInputPassportExpire'),
|
||||
(val) =>
|
||||
(val && val.length > 0) ||
|
||||
$t('form.error.selectField', {
|
||||
field: $t('customerEmployee.form.passportExpireDate'),
|
||||
}),
|
||||
]"
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ onMounted(() => {
|
|||
(val: string) =>
|
||||
!!val ||
|
||||
$t('form.error.selectField', {
|
||||
field: $t('customer.form.employerBranch'),
|
||||
field: $t('customerEmployee.branch'),
|
||||
}),
|
||||
]"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -344,8 +344,11 @@ function formatCode(input: string | undefined, type: 'code' | 'number') {
|
|||
:label="$t('customer.form.firstNameEN')"
|
||||
for="input-first-name-en"
|
||||
v-model="firstNameEN"
|
||||
:rules="[(val) => /^[A-Za-z]+$/.test(val)]"
|
||||
:error-message="$t('form.error.letterOnly')"
|
||||
:rules="[
|
||||
(val: string) => !!val || $t('form.error.required'),
|
||||
(val: string) =>
|
||||
/^[A-Za-z]+$/.test(val) || $t('form.error.letterOnly'),
|
||||
]"
|
||||
/>
|
||||
<q-input
|
||||
dense
|
||||
|
|
@ -356,8 +359,11 @@ function formatCode(input: string | undefined, type: 'code' | 'number') {
|
|||
:label="$t('customer.form.lastNameEN')"
|
||||
for="input-last-name-en"
|
||||
v-model="lastNameEN"
|
||||
:rules="[(val) => /^[A-Za-z]+$/.test(val)]"
|
||||
:error-message="$t('form.error.letterOnly')"
|
||||
:rules="[
|
||||
(val: string) => !!val || $t('form.error.required'),
|
||||
(val: string) =>
|
||||
/^[A-Za-z]+$/.test(val) || $t('form.error.letterOnly'),
|
||||
]"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue