fix: form employee disable rule validate

This commit is contained in:
puriphatt 2024-06-12 09:08:43 +00:00
parent 70664067e5
commit 60431904ce
5 changed files with 131 additions and 59 deletions

View file

@ -15,6 +15,7 @@ defineProps<{
readonly?: boolean;
separator?: boolean;
employee?: boolean;
disabledRule?: boolean;
}>();
const adrressStore = useAddressStore();
@ -116,10 +117,15 @@ watch(districtId, fetchSubDistrict);
class="col-12"
v-model="address"
lazy-rules
:rules="[
(val) =>
(val && val.length > 0) || $t('formDialogInputAddressValidate'),
]"
:rules="
disabledRule
? []
: [
(val) =>
(val && val.length > 0) ||
$t('formDialogInputAddressValidate'),
]
"
/>
<q-select
id="select-province"
@ -138,10 +144,15 @@ watch(districtId, fetchSubDistrict);
class="col-3"
:options="addrOptions.provinceOps"
lazy-rules
:rules="[
(val) =>
(val && val.length > 0) || $t('formDialogInputProvinceValidate'),
]"
:rules="
disabledRule
? []
: [
(val) =>
(val && val.length > 0) ||
$t('formDialogInputProvinceValidate'),
]
"
@update:model-value="districtId = subDistrictId = zipCode = null"
/>
<q-select
@ -161,10 +172,15 @@ watch(districtId, fetchSubDistrict);
class="col-3"
:options="addrOptions.districtOps"
lazy-rules
:rules="[
(val) =>
(val && val.length > 0) || $t('formDialogInputDistrictValidate'),
]"
:rules="
disabledRule
? []
: [
(val) =>
(val && val.length > 0) ||
$t('formDialogInputDistrictValidate'),
]
"
@update:model-value="subDistrictId = zipCode = null"
/>
<q-select
@ -184,11 +200,15 @@ watch(districtId, fetchSubDistrict);
class="col-3"
:options="addrOptions.subDistrictOps"
lazy-rules
:rules="[
(val) =>
(val && val.length > 0) ||
$t('formDialogInputSubDistrictValidate'),
]"
:rules="
disabledRule
? []
: [
(val) =>
(val && val.length > 0) ||
$t('formDialogInputSubDistrictValidate'),
]
"
@update:model-value="(v: string) => selectSubDistrict(v)"
/>
<q-input
@ -217,10 +237,15 @@ watch(districtId, fetchSubDistrict);
class="col-12"
v-model="addressEN"
lazy-rules
:rules="[
(val) =>
(val && val.length > 0) || $t('formDialogInputAddressValidate'),
]"
:rules="
disabledRule
? []
: [
(val) =>
(val && val.length > 0) ||
$t('formDialogInputAddressValidate'),
]
"
/>
<q-select
id="select-province-en"
@ -239,10 +264,15 @@ watch(districtId, fetchSubDistrict);
class="col-3"
:options="addrOptions.provinceOps"
lazy-rules
:rules="[
(val) =>
(val && val.length > 0) || $t('formDialogInputProvinceValidate'),
]"
:rules="
disabledRule
? []
: [
(val) =>
(val && val.length > 0) ||
$t('formDialogInputProvinceValidate'),
]
"
@update:model-value="districtId = subDistrictId = zipCode = null"
/>
<q-select
@ -262,10 +292,15 @@ watch(districtId, fetchSubDistrict);
class="col-3"
:options="addrOptions.districtOps"
lazy-rules
:rules="[
(val) =>
(val && val.length > 0) || $t('formDialogInputDistrictValidate'),
]"
:rules="
disabledRule
? []
: [
(val) =>
(val && val.length > 0) ||
$t('formDialogInputDistrictValidate'),
]
"
@update:model-value="subDistrictId = zipCode = null"
/>
<q-select
@ -285,11 +320,15 @@ watch(districtId, fetchSubDistrict);
class="col-3"
:options="addrOptions.subDistrictOps"
lazy-rules
:rules="[
(val) =>
(val && val.length > 0) ||
$t('formDialogInputSubDistrictValidate'),
]"
:rules="
disabledRule
? []
: [
(val) =>
(val && val.length > 0) ||
$t('formDialogInputSubDistrictValidate'),
]
"
@update:model-value="(v: string) => selectSubDistrict(v)"
/>
<q-input

View file

@ -9,6 +9,7 @@ defineProps<{
addressTitleEN?: string;
noAddress?: boolean;
noPaddingTab?: boolean;
disabledRule?: boolean;
}>();
const address = defineModel('address', { default: '' });
@ -75,6 +76,7 @@ const tabsList = defineModel<{ name: string; label: string }[]>('tabsList');
outlined
separator
:readonly="readonly"
:disabledRule="disabledRule"
v-model:address="address"
v-model:addressEN="addressEN"
v-model:provinceId="provinceId"