refactor(02): input select

This commit is contained in:
puriphatt 2024-07-30 04:04:17 +00:00
parent 05f0d00871
commit 3b0510922b
4 changed files with 428 additions and 159 deletions

View file

@ -1,10 +1,12 @@
<script setup lang="ts"> <script setup lang="ts">
import { onMounted, watch, reactive } from 'vue'; import { onMounted, watch, reactive, ref } from 'vue';
import useAddressStore, { import useAddressStore, {
District, District,
Province, Province,
SubDistrict, SubDistrict,
} from 'src/stores/address'; } from 'src/stores/address';
import { selectFilterOptionRefMod } from 'src/stores/utils';
import { QSelect } from 'quasar';
defineProps<{ defineProps<{
title?: string; title?: string;
@ -43,6 +45,18 @@ async function fetchProvince() {
const result = await adrressStore.fetchProvince(); const result = await adrressStore.fetchProvince();
if (result) addrOptions.provinceOps = result; if (result) addrOptions.provinceOps = result;
provinceFilter = selectFilterOptionRefMod(
ref(addrOptions.provinceOps),
provinceOptions,
'name',
);
provinceEnFilter = selectFilterOptionRefMod(
ref(addrOptions.provinceOps),
provinceOptions,
'nameEN',
);
} }
async function fetchDistrict() { async function fetchDistrict() {
@ -50,6 +64,18 @@ async function fetchDistrict() {
const result = await adrressStore.fetchDistrictByProvinceId(provinceId.value); const result = await adrressStore.fetchDistrictByProvinceId(provinceId.value);
if (result) addrOptions.districtOps = result; if (result) addrOptions.districtOps = result;
districtFilter = selectFilterOptionRefMod(
ref(addrOptions.districtOps),
districtOptions,
'name',
);
districtEnFilter = selectFilterOptionRefMod(
ref(addrOptions.districtOps),
districtOptions,
'nameEN',
);
} }
async function fetchSubDistrict() { async function fetchSubDistrict() {
@ -58,6 +84,18 @@ async function fetchSubDistrict() {
districtId.value, districtId.value,
); );
if (result) addrOptions.subDistrictOps = result; if (result) addrOptions.subDistrictOps = result;
subDistrictFilter = selectFilterOptionRefMod(
ref(addrOptions.subDistrictOps),
subDistrictOptions,
'name',
);
subDistrictEnFilter = selectFilterOptionRefMod(
ref(addrOptions.subDistrictOps),
subDistrictOptions,
'nameEN',
);
} }
async function selectSubDistrict(id: string) { async function selectSubDistrict(id: string) {
@ -68,6 +106,36 @@ async function selectSubDistrict(id: string) {
.map((x) => x.zipCode)[0] ?? ''; .map((x) => x.zipCode)[0] ?? '';
} }
const provinceOptions = ref<Record<string, unknown>[]>([]);
let provinceFilter: (
value: string,
update: (callbackFn: () => void, afterFn?: (ref: QSelect) => void) => void,
) => void;
let provinceEnFilter: (
value: string,
update: (callbackFn: () => void, afterFn?: (ref: QSelect) => void) => void,
) => void;
const districtOptions = ref<Record<string, unknown>[]>([]);
let districtFilter: (
value: string,
update: (callbackFn: () => void, afterFn?: (ref: QSelect) => void) => void,
) => void;
let districtEnFilter: (
value: string,
update: (callbackFn: () => void, afterFn?: (ref: QSelect) => void) => void,
) => void;
const subDistrictOptions = ref<Record<string, unknown>[]>([]);
let subDistrictFilter: (
value: string,
update: (callbackFn: () => void, afterFn?: (ref: QSelect) => void) => void,
) => void;
let subDistrictEnFilter: (
value: string,
update: (callbackFn: () => void, afterFn?: (ref: QSelect) => void) => void,
) => void;
onMounted(async () => { onMounted(async () => {
await fetchProvince(); await fetchProvince();
await fetchDistrict(); await fetchDistrict();
@ -124,15 +192,15 @@ watch(districtId, fetchSubDistrict);
</div> </div>
<div class="col-md-9 col-12 row q-col-gutter-md"> <div class="col-md-9 col-12 row q-col-gutter-md">
<q-input <q-input
lazy-rules="ondemand"
:for="`${prefixId}-${id !== undefined ? `input-address-${id}` : 'input-address'}`"
:dense="dense"
outlined outlined
:readonly="readonly || sameWithEmployer"
hide-bottom-space hide-bottom-space
:label="$t('address')"
class="col-12" class="col-12"
v-model="address" v-model="address"
lazy-rules="ondemand"
:dense="dense"
:label="$t('address')"
:readonly="readonly || sameWithEmployer"
:for="`${prefixId}-${id !== undefined ? `input-address-${id}` : 'input-address'}`"
:rules=" :rules="
disabledRule disabledRule
? [] ? []
@ -144,21 +212,26 @@ watch(districtId, fetchSubDistrict);
" "
/> />
<q-select <q-select
lazy-rules="ondemand"
:id="`${prefixId}-${id !== undefined ? `select-province-${id}` : 'select-province'}`"
:dense="dense"
:readonly="readonly || sameWithEmployer"
outlined outlined
:hide-dropdown-icon="readonly || sameWithEmployer" clearable
hide-bottom-space use-input
fill-input
emit-value emit-value
map-options map-options
v-model="provinceId" hide-selected
hide-bottom-space
option-value="id" option-value="id"
input-debounce="0"
option-label="name" option-label="name"
:label="$t('province')" v-model="provinceId"
lazy-rules="ondemand"
class="col-md-3 col-6" class="col-md-3 col-6"
:options="addrOptions.provinceOps" :dense="dense"
:label="$t('province')"
:options="provinceOptions"
:readonly="readonly || sameWithEmployer"
:hide-dropdown-icon="readonly || sameWithEmployer"
:id="`${prefixId}-${id !== undefined ? `select-province-${id}` : 'select-province'}`"
:rules=" :rules="
disabledRule disabledRule
? [] ? []
@ -168,25 +241,39 @@ watch(districtId, fetchSubDistrict);
$t('formDialogInputProvinceValidate'), $t('formDialogInputProvinceValidate'),
] ]
" "
@filter="provinceFilter"
@update:model-value="districtId = subDistrictId = zipCode = null" @update:model-value="districtId = subDistrictId = zipCode = null"
/> >
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
{{ $t('noResults') }}
</q-item-section>
</q-item>
</template>
</q-select>
<q-select <q-select
lazy-rules="ondemand"
:id="`${prefixId}-${id !== undefined ? `select-district-${id}` : 'select-district'}`"
:dense="dense"
:readonly="readonly || sameWithEmployer"
outlined outlined
:hide-dropdown-icon="readonly || sameWithEmployer" clearable
hide-bottom-space use-input
fill-input
emit-value emit-value
map-options map-options
v-model="districtId" hide-selected
hide-bottom-space
option-value="id" option-value="id"
input-debounce="0"
option-label="name" option-label="name"
:label="$t('district')" v-model="districtId"
lazy-rules="ondemand"
class="col-md-3 col-6" class="col-md-3 col-6"
:options="addrOptions.districtOps" :dense="dense"
:label="$t('district')"
:options="districtOptions"
:readonly="readonly || sameWithEmployer"
:hide-dropdown-icon="readonly || sameWithEmployer"
:id="`${prefixId}-${id !== undefined ? `select-district-${id}` : 'select-district'}`"
:rules=" :rules="
disabledRule disabledRule
? [] ? []
@ -196,24 +283,38 @@ watch(districtId, fetchSubDistrict);
$t('formDialogInputDistrictValidate'), $t('formDialogInputDistrictValidate'),
] ]
" "
@filter="districtFilter"
@update:model-value="subDistrictId = zipCode = null" @update:model-value="subDistrictId = zipCode = null"
/> >
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
{{ $t('noResults') }}
</q-item-section>
</q-item>
</template>
</q-select>
<q-select <q-select
lazy-rules="ondemand"
:id="`${prefixId}-${id !== undefined ? `select-sub-district-${id}` : 'select-sub-district'}`"
:dense="dense"
:readonly="readonly || sameWithEmployer"
outlined outlined
:hide-dropdown-icon="readonly || sameWithEmployer" clearable
hide-bottom-space use-input
fill-input
emit-value emit-value
map-options map-options
v-model="subDistrictId" hide-selected
hide-bottom-space
option-value="id" option-value="id"
input-debounce="0"
option-label="name" option-label="name"
:label="$t('subDistrict')" lazy-rules="ondemand"
class="col-md-3 col-6" class="col-md-3 col-6"
:options="addrOptions.subDistrictOps" v-model="subDistrictId"
:dense="dense"
:label="$t('subDistrict')"
:options="subDistrictOptions"
:readonly="readonly || sameWithEmployer"
:hide-dropdown-icon="readonly || sameWithEmployer"
:id="`${prefixId}-${id !== undefined ? `select-sub-district-${id}` : 'select-sub-district'}`"
:rules=" :rules="
disabledRule disabledRule
? [] ? []
@ -224,7 +325,16 @@ watch(districtId, fetchSubDistrict);
] ]
" "
@update:model-value="(v: string) => selectSubDistrict(v)" @update:model-value="(v: string) => selectSubDistrict(v)"
/> @filter="subDistrictFilter"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
{{ $t('noResults') }}
</q-item-section>
</q-item>
</template>
</q-select>
<q-input <q-input
lazy-rules="ondemand" lazy-rules="ondemand"
:for="`${prefixId}-${id !== undefined ? `input-zip-code-${id}` : 'input-zip-code'}`" :for="`${prefixId}-${id !== undefined ? `input-zip-code-${id}` : 'input-zip-code'}`"
@ -264,21 +374,26 @@ watch(districtId, fetchSubDistrict);
" "
/> />
<q-select <q-select
lazy-rules="ondemand"
:id="`${prefixId}-${id !== undefined ? `select-province-en-${id}` : 'select-province-en'}`"
hide-bottom-space
:dense="dense"
:readonly="readonly || sameWithEmployer"
outlined outlined
:hide-dropdown-icon="readonly || sameWithEmployer" clearable
use-input
fill-input
emit-value emit-value
map-options map-options
v-model="provinceId" hide-selected
hide-bottom-space
option-value="id" option-value="id"
input-debounce="0"
v-model="provinceId"
lazy-rules="ondemand"
option-label="nameEN" option-label="nameEN"
:label="$t('province')"
class="col-md-3 col-6" class="col-md-3 col-6"
:options="addrOptions.provinceOps" :dense="dense"
:label="$t('province')"
:options="provinceOptions"
:readonly="readonly || sameWithEmployer"
:hide-dropdown-icon="readonly || sameWithEmployer"
:id="`${prefixId}-${id !== undefined ? `select-province-en-${id}` : 'select-province-en'}`"
:rules=" :rules="
disabledRule disabledRule
? [] ? []
@ -289,23 +404,37 @@ watch(districtId, fetchSubDistrict);
] ]
" "
@update:model-value="districtId = subDistrictId = zipCode = null" @update:model-value="districtId = subDistrictId = zipCode = null"
/> @filter="provinceEnFilter"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
{{ $t('noResults') }}
</q-item-section>
</q-item>
</template>
</q-select>
<q-select <q-select
lazy-rules="ondemand"
:id="`${prefixId}-${id !== undefined ? `select-district-en-${id}` : 'select-district-en'}`"
hide-bottom-space
:dense="dense"
:readonly="readonly || sameWithEmployer"
outlined outlined
:hide-dropdown-icon="readonly || sameWithEmployer" clearable
use-input
fill-input
emit-value emit-value
map-options map-options
v-model="districtId" hide-selected
hide-bottom-space
option-value="id" option-value="id"
input-debounce="0"
v-model="districtId"
lazy-rules="ondemand"
option-label="nameEN" option-label="nameEN"
:label="$t('district')"
class="col-md-3 col-6" class="col-md-3 col-6"
:options="addrOptions.districtOps" :dense="dense"
:label="$t('district')"
:options="districtOptions"
:readonly="readonly || sameWithEmployer"
:hide-dropdown-icon="readonly || sameWithEmployer"
:id="`${prefixId}-${id !== undefined ? `select-district-en-${id}` : 'select-district-en'}`"
:rules=" :rules="
disabledRule disabledRule
? [] ? []
@ -316,23 +445,37 @@ watch(districtId, fetchSubDistrict);
] ]
" "
@update:model-value="subDistrictId = zipCode = null" @update:model-value="subDistrictId = zipCode = null"
/> @filter="districtEnFilter"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
{{ $t('noResults') }}
</q-item-section>
</q-item>
</template>
</q-select>
<q-select <q-select
lazy-rules="ondemand"
:id="`${prefixId}-${id !== undefined ? `select-sub-district-en-${id}` : 'select-sub-district-en'}`"
hide-bottom-space
:dense="dense"
:readonly="readonly || sameWithEmployer"
outlined outlined
:hide-dropdown-icon="readonly || sameWithEmployer" clearable
use-input
fill-input
emit-value emit-value
map-options map-options
v-model="subDistrictId" hide-selected
hide-bottom-space
option-value="id" option-value="id"
input-debounce="0"
lazy-rules="ondemand"
option-label="nameEN" option-label="nameEN"
:label="$t('subDistrict')"
class="col-md-3 col-6" class="col-md-3 col-6"
:options="addrOptions.subDistrictOps" v-model="subDistrictId"
:dense="dense"
:label="$t('subDistrict')"
:options="subDistrictOptions"
:readonly="readonly || sameWithEmployer"
:hide-dropdown-icon="readonly || sameWithEmployer"
:id="`${prefixId}-${id !== undefined ? `select-sub-district-en-${id}` : 'select-sub-district-en'}`"
:rules=" :rules="
disabledRule disabledRule
? [] ? []
@ -343,7 +486,16 @@ watch(districtId, fetchSubDistrict);
] ]
" "
@update:model-value="(v: string) => selectSubDistrict(v)" @update:model-value="(v: string) => selectSubDistrict(v)"
/> @filter="subDistrictEnFilter"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
{{ $t('noResults') }}
</q-item-section>
</q-item>
</template>
</q-select>
<q-input <q-input
lazy-rules="ondemand" lazy-rules="ondemand"
hide-bottom-space hide-bottom-space

View file

@ -1,8 +1,11 @@
<script setup lang="ts"> <script setup lang="ts">
import useUserStore from 'src/stores/user'; import useUserStore from 'src/stores/user';
import { onMounted } from 'vue'; import { selectFilterOptionRefMod } from 'src/stores/utils';
import { onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n';
const userStore = useUserStore(); const userStore = useUserStore();
const { t } = useI18n();
const hqId = defineModel<string | null | undefined>('hqId'); const hqId = defineModel<string | null | undefined>('hqId');
const brId = defineModel<string | null | undefined>('brId'); const brId = defineModel<string | null | undefined>('brId');
@ -29,6 +32,39 @@ async function selectHq(id: string) {
} }
} }
const hqOptions = ref<Record<string, unknown>[]>([]);
const hqFilter = selectFilterOptionRefMod(
ref(userStore.userOption.hqOpts),
hqOptions,
'label',
);
const brOptions = ref<Record<string, unknown>[]>([]);
const brFilter = selectFilterOptionRefMod(
ref(userStore.userOption.brOpts),
brOptions,
'label',
);
const userTypeOptions = ref<Record<string, unknown>[]>([]);
const userTypeFilter = selectFilterOptionRefMod(
ref(
userStore.userOption.userTypeOpts.map((v) => ({
label: t(v.label),
value: v.value,
})),
),
userTypeOptions,
'label',
);
const roleOptions = ref<Record<string, unknown>[]>([]);
const roleFilter = selectFilterOptionRefMod(
ref(userStore.userOption.roleOpts),
roleOptions,
'label',
);
onMounted(async () => { onMounted(async () => {
if (userStore.userOption.hqOpts[0].value) if (userStore.userOption.hqOpts[0].value)
await userStore.fetchBrOption(userStore.userOption.hqOpts[0].value); await userStore.fetchBrOption(userStore.userOption.hqOpts[0].value);
@ -40,44 +76,69 @@ onMounted(async () => {
</div> </div>
<div class="col-md-9 col-12 row q-col-gutter-md"> <div class="col-md-9 col-12 row q-col-gutter-md">
<q-select <q-select
lazy-rules="ondemand"
id="select-hq-id"
:dense="dense"
outlined outlined
:readonly="readonly" clearable
:hide-dropdown-icon="readonly" use-input
fill-input
emit-value emit-value
map-options map-options
options-dense hide-selected
hide-bottom-space hide-bottom-space
class="col-md-4 col-6"
v-model="hqId" v-model="hqId"
id="select-hq-id"
input-debounce="0"
option-label="label" option-label="label"
option-value="value" option-value="value"
lazy-rules="ondemand"
class="col-md-4 col-6"
:dense="dense"
:readonly="readonly"
:hide-dropdown-icon="readonly"
:label="$t('formDialogInputCode')" :label="$t('formDialogInputCode')"
:options="userStore.userOption.hqOpts" :options="hqOptions"
:rules="[(val: string) => !!val || $t('formDialogInputHqIdValidate')]" :rules="[(val: string) => !!val || $t('formDialogInputHqIdValidate')]"
@update:model-value="(val: string) => selectHq(val)" @update:model-value="(val: string) => selectHq(val)"
/> @filter="hqFilter"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
{{ $t('noResults') }}
</q-item-section>
</q-item>
</template>
</q-select>
<q-select <q-select
lazy-rules="ondemand"
id="select-br-id"
:dense="dense"
outlined outlined
:readonly="readonly" clearable
:hide-dropdown-icon="readonly" use-input
fill-input
emit-value emit-value
map-options map-options
options-dense hide-selected
clearable
hide-bottom-space hide-bottom-space
class="col-md-4 col-6"
v-model="brId" v-model="brId"
:label="$t('formDialogInputBrId')" id="select-br-id"
input-debounce="0"
option-label="label" option-label="label"
option-value="value" option-value="value"
:options="userStore.userOption.brOpts" lazy-rules="ondemand"
/> class="col-md-4 col-6"
:dense="dense"
:readonly="readonly"
:hide-dropdown-icon="readonly"
:label="$t('formDialogInputBrId')"
:options="brOptions"
@filter="brFilter"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
{{ $t('noResults') }}
</q-item-section>
</q-item>
</template>
</q-select>
<q-input <q-input
lazy-rules="ondemand" lazy-rules="ondemand"
for="input-username" for="input-username"
@ -97,54 +158,69 @@ onMounted(async () => {
]" ]"
/> />
<q-select <q-select
outlined
clearable
use-input
fill-input
emit-value
map-options
hide-selected
hide-bottom-space
class="col-6"
v-model="userType"
input-debounce="0"
option-value="value"
option-label="label"
lazy-rules="ondemand" lazy-rules="ondemand"
id="select-user-type" id="select-user-type"
:dense="dense" :dense="dense"
outlined
:readonly="readonly" :readonly="readonly"
:hide-dropdown-icon="readonly" :hide-dropdown-icon="readonly"
emit-value
map-options
options-dense
hide-bottom-space
class="col-6"
option-value="value"
:label="$t('formDialogInputUserType')" :label="$t('formDialogInputUserType')"
v-model="userType" :options="userTypeOptions"
:options="userStore.userOption.userTypeOpts"
:rules="[(val: string) => !!val || $t('formDialogInputUserTypeValidate')]" :rules="[(val: string) => !!val || $t('formDialogInputUserTypeValidate')]"
@filter="userTypeFilter"
> >
<template v-slot:option="scope"> <template v-slot:no-option>
<q-item v-if="scope.opt" v-bind="scope.itemProps"> <q-item>
{{ $t(scope.opt.label) }} <q-item-section class="text-grey">
{{ $t('noResults') }}
</q-item-section>
</q-item> </q-item>
</template> </template>
<template v-slot:selected-item="scope">
<div v-if="scope.opt">
{{ $t(scope.opt.label) }}
</div>
</template>
</q-select> </q-select>
<q-select <q-select
outlined
clearable
use-input
fill-input
emit-value
map-options
hide-selected
hide-bottom-space
class="col-6"
input-debounce="0"
option-label="label"
option-value="value"
lazy-rules="ondemand" lazy-rules="ondemand"
id="select-user-role" id="select-user-role"
:dense="dense" :dense="dense"
outlined v-model="userRole"
:readonly="readonly" :readonly="readonly"
:hide-dropdown-icon="readonly" :hide-dropdown-icon="readonly"
emit-value
map-options
options-dense
hide-bottom-space
class="col-6"
:label="$t('formDialogInputUserRole')" :label="$t('formDialogInputUserRole')"
option-label="label" :options="roleOptions"
option-value="value"
v-model="userRole"
:options="userStore.userOption.roleOpts"
:rules="[(val: string) => !!val || $t('formDialogInputUserRoleValidate')]" :rules="[(val: string) => !!val || $t('formDialogInputUserRoleValidate')]"
/> @filter="roleFilter"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
{{ $t('noResults') }}
</q-item-section>
</q-item>
</template>
</q-select>
<!-- <q-input lazy-rules="ondemand" <!-- <q-input lazy-rules="ondemand"
id="input-user-code" id="input-user-code"
:dense="dense" :dense="dense"

View file

@ -1,12 +1,13 @@
<script setup lang="ts"> <script setup lang="ts">
import useOptionStore from 'src/stores/options'; import useOptionStore from 'src/stores/options';
import { selectOptionFilter } from 'src/stores/utils'; import { selectFilterOptionRefMod } from 'src/stores/utils';
import { import {
dateFormat, dateFormat,
calculateAge, calculateAge,
parseAndFormatDate, parseAndFormatDate,
disabledAfterToday, disabledAfterToday,
} from 'src/utils/datetime'; } from 'src/utils/datetime';
import { ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
const { locale } = useI18n(); const { locale } = useI18n();
@ -22,11 +23,19 @@ const gender = defineModel<string>('gender');
const birthDate = defineModel<Date | string | null>('birthDate'); const birthDate = defineModel<Date | string | null>('birthDate');
const nationality = defineModel<string>('nationality'); const nationality = defineModel<string>('nationality');
const { options: genderOptions, filter: genderFilter } = selectOptionFilter( const genderOptions = ref<Record<string, unknown>[]>([]);
optionStore.globalOption.gender, const genderFilter = selectFilterOptionRefMod(
ref(optionStore.globalOption.gender),
genderOptions,
'label',
);
const nationalityOptions = ref<Record<string, unknown>[]>([]);
const nationalityFilter = selectFilterOptionRefMod(
ref(optionStore.globalOption.nationality),
nationalityOptions,
'label',
); );
const { options: nationalityOptions, filter: nationalityFilter } =
selectOptionFilter(optionStore.globalOption.nationality);
defineProps<{ defineProps<{
dense?: boolean; dense?: boolean;
@ -121,24 +130,37 @@ defineProps<{
v-model="email" v-model="email"
/> />
<q-select <q-select
lazy-rules="ondemand"
v-if="!employee" v-if="!employee"
:id="`${prefixId}-select-gender`"
:dense="dense"
outlined outlined
:readonly="readonly" clearable
:hide-dropdown-icon="readonly" use-input
fill-input
emit-value emit-value
map-options map-options
:label="$t('formDialogInputGender')" hide-selected
class="col-md-3 col-6" hide-bottom-space
v-model="gender"
input-debounce="0"
option-label="label" option-label="label"
option-value="value" option-value="value"
v-model="gender" lazy-rules="ondemand"
use-input class="col-md-3 col-6"
@filter="genderFilter" :dense="dense"
:readonly="readonly"
:options="genderOptions" :options="genderOptions"
/> :hide-dropdown-icon="readonly"
:id="`${prefixId}-select-gender`"
:label="$t('formDialogInputGender')"
@filter="genderFilter"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
{{ $t('noResults') }}
</q-item-section>
</q-item>
</template>
</q-select>
<VueDatePicker <VueDatePicker
:id="`${prefixId}-input-birth-date`" :id="`${prefixId}-input-birth-date`"
@ -218,54 +240,77 @@ defineProps<{
" "
/> />
<q-select <q-select
lazy-rules="ondemand"
v-if="employee" v-if="employee"
:id="`${prefixId}-select-gender`"
hide-bottom-space
:dense="dense"
outlined outlined
:readonly="readonly" clearable
:hide-dropdown-icon="readonly" use-input
fill-input
emit-value emit-value
map-options map-options
:label="$t('formDialogInputGender')" hide-selected
class="col-md-3 col-6" hide-bottom-space
input-debounce="0"
option-label="label" option-label="label"
option-value="value" option-value="value"
use-input lazy-rules="ondemand"
class="col-md-3 col-6"
:dense="dense"
v-model="gender" v-model="gender"
@filter="genderFilter" :readonly="readonly"
:options="genderOptions" :options="genderOptions"
:hide-dropdown-icon="readonly"
:id="`${prefixId}-select-gender`"
:label="$t('formDialogInputGender')"
:rules="[ :rules="[
(val: string) => (val: string) =>
!!val || $t('selectValidate') + $t('formDialogInputGender'), !!val || $t('selectValidate') + $t('formDialogInputGender'),
]" ]"
/> @filter="genderFilter"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
{{ $t('noResults') }}
</q-item-section>
</q-item>
</template>
</q-select>
<q-select <q-select
lazy-rules="ondemand"
v-if="employee" v-if="employee"
:id="`${prefixId}-select-nationality`"
hide-bottom-space
:dense="dense"
outlined outlined
:readonly="readonly" clearable
:hide-dropdown-icon="readonly" use-input
fill-input
emit-value emit-value
map-options map-options
options-dense hide-selected
:label="$t('formDialogInputNationality')" hide-bottom-space
class="col-md-3 col-6" input-debounce="0"
option-label="label" option-label="label"
option-value="label" option-value="label"
v-model="nationality" v-model="nationality"
lazy-rules="ondemand"
class="col-md-3 col-6"
:dense="dense"
:readonly="readonly"
:options="nationalityOptions" :options="nationalityOptions"
use-input :hide-dropdown-icon="readonly"
@filter="nationalityFilter" :id="`${prefixId}-select-nationality`"
:label="$t('formDialogInputNationality')"
:rules="[ :rules="[
(val: string) => (val: string) =>
!!val || $t('selectValidate') + $t('formDialogInputNationality'), !!val || $t('selectValidate') + $t('formDialogInputNationality'),
]" ]"
/> @filter="nationalityFilter"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
{{ $t('noResults') }}
</q-item-section>
</q-item>
</template>
</q-select>
</div> </div>
<q-separator <q-separator
v-if="separator" v-if="separator"

View file

@ -599,10 +599,6 @@ onMounted(async () => {
modeView.value = $q.screen.lt.md ? true : false; modeView.value = $q.screen.lt.md ? true : false;
await fetchUserList(); await fetchUserList();
userStore.userOption.roleOpts.length === 0
? await userStore.fetchRoleOption()
: '';
if (optionStore.globalOption) { if (optionStore.globalOption) {
userStore.userOption.genderOpts = optionStore.globalOption.gender; userStore.userOption.genderOpts = optionStore.globalOption.gender;
userStore.userOption.responsibleAreaOpts = optionStore.globalOption.area; userStore.userOption.responsibleAreaOpts = optionStore.globalOption.area;