jws-frontend/src/pages/03_customer-management/components/employer/EmployerFormBasicInfo.vue

1014 lines
27 KiB
Vue
Raw Normal View History

2024-08-05 15:09:36 +07:00
<script lang="ts" setup>
2024-09-16 14:38:04 +07:00
import { ref, watch } from 'vue';
2024-08-05 15:09:36 +07:00
import { QSelect } from 'quasar';
import { selectFilterOptionRefMod } from 'stores/utils';
import { getRole } from 'src/services/keycloak';
2024-08-20 18:04:27 +07:00
import useOptionStore from 'stores/options';
2024-08-05 15:09:36 +07:00
import { onMounted } from 'vue';
2024-08-20 18:04:27 +07:00
2024-08-07 17:56:59 +07:00
import {
SaveButton,
EditButton,
DeleteButton,
2024-08-09 13:20:38 +07:00
UndoButton,
2024-08-09 14:02:40 +07:00
} from 'components/button';
2024-09-16 14:38:04 +07:00
withDefaults(
defineProps<{
prefixId?: string;
outlined?: boolean;
readonly?: boolean;
create?: boolean;
actionDisabled?: boolean;
customerType?: 'CORP' | 'PERS';
hideAction?: boolean;
}>(),
{
hideAction: false,
},
);
2024-08-07 17:56:59 +07:00
defineEmits<{
(e: 'save'): void;
(e: 'edit'): void;
(e: 'delete'): void;
(e: 'cancel'): void;
}>();
2024-08-05 15:09:36 +07:00
2024-08-20 18:04:27 +07:00
const optionStore = useOptionStore();
2024-08-05 15:09:36 +07:00
const registeredBranchId = defineModel<string>('registeredBranchId', {
required: true,
});
2024-09-16 14:38:04 +07:00
const customerName = defineModel<string>('customerName');
const registerName = defineModel<string>('registerName');
const citizenId = defineModel<string>('citizenId');
const legalPersonNo = defineModel<string>('legalPersonNo');
const businessType = defineModel<'strinf'>('businessType');
const jobPosition = defineModel<'strinf'>('jobPosition');
const telephoneNo = defineModel<string>('telephoneNo');
2024-08-05 15:09:36 +07:00
const branchOptions = defineModel<{ id: string; name: string }[]>(
'branchOptions',
{ default: [] },
);
const filteredBranchOptions = ref<Record<string, unknown>[]>([]);
let branchFilter: (
value: string,
update: (callbackFn: () => void, afterFn?: (ref: QSelect) => void) => void,
) => void;
onMounted(() => {
branchFilter = selectFilterOptionRefMod(
branchOptions,
filteredBranchOptions,
'name',
);
});
watch(
() => branchOptions.value,
() => {
branchFilter = selectFilterOptionRefMod(
branchOptions,
filteredBranchOptions,
'name',
);
},
);
2024-08-13 12:52:25 +07:00
2024-09-16 14:38:04 +07:00
// const prefixNameOptions = ref<Record<string, unknown>[]>([]);
// let prefixNameFilter: (
// value: string,
// update: (callbackFn: () => void, afterFn?: (ref: QSelect) => void) => void,
// ) => void;
2024-08-20 18:04:27 +07:00
2024-09-16 14:38:04 +07:00
// const genderOptions = ref<Record<string, unknown>[]>([]);
// let genderFilter: (
// value: string,
// update: (callbackFn: () => void, afterFn?: (ref: QSelect) => void) => void,
// ) => void;
2024-08-20 18:04:27 +07:00
2024-09-16 14:38:04 +07:00
// onMounted(() => {
// prefixNameFilter = selectFilterOptionRefMod(
// ref(optionStore.globalOption?.prefix),
// prefixNameOptions,
// 'label',
// );
// genderFilter = selectFilterOptionRefMod(
// ref(optionStore.globalOption?.gender),
// genderOptions,
// 'label',
// );
// });
2024-08-20 18:04:27 +07:00
2024-09-16 14:38:04 +07:00
// watch(
// () => optionStore.globalOption,
// () => {
// prefixNameFilter = selectFilterOptionRefMod(
// ref(optionStore.globalOption.prefix),
// prefixNameOptions,
// 'label',
// );
// genderFilter = selectFilterOptionRefMod(
// ref(optionStore.globalOption.gender),
// genderOptions,
// 'label',
// );
// },
// );
2024-08-20 18:04:27 +07:00
2024-09-16 14:38:04 +07:00
// watch(
// () => namePrefix.value,
// (v) => {
// if (v === 'mr') gender.value = 'male';
// else gender.value = 'female';
// },
// );
2024-08-20 18:04:27 +07:00
2024-09-16 14:38:04 +07:00
// function formatCode(input: string | undefined, type: 'code' | 'number') {
// if (!input) return;
// return input.slice(...(type === 'code' ? [0, -6] : [-6]));
// }
2024-08-05 15:09:36 +07:00
</script>
<template>
2024-09-16 14:38:04 +07:00
<div class="row q-col-gutter-sm">
<div
v-if="!hideAction"
class="col-12 text-weight-bold text-body1 row items-center"
>
2024-08-05 15:09:36 +07:00
<q-icon
flat
size="xs"
class="q-pa-sm rounded q-mr-xs"
color="info"
name="mdi-office-building-outline"
style="background-color: var(--surface-3)"
/>
2024-09-16 14:38:04 +07:00
<span>
{{
$t('general.information', {
msg: `${$t('customer.employer')}${
customerType === 'CORP'
? $t('customer.employerLegalEntity')
: $t('customer.employerNaturalPerson')
}`,
})
}}
</span>
<!-- <EditButton
2024-08-08 13:32:46 +07:00
icon-only
2024-08-07 17:56:59 +07:00
v-if="readonly && !create"
type="button"
@click="$emit('edit')"
class="q-ml-auto"
:disabled="actionDisabled"
/>
<DeleteButton
2024-08-08 13:32:46 +07:00
icon-only
2024-08-07 17:56:59 +07:00
v-if="readonly && !create"
@click="$emit('delete')"
type="button"
:disabled="actionDisabled"
/>
2024-08-09 13:20:38 +07:00
<UndoButton
2024-08-08 13:32:46 +07:00
icon-only
2024-08-09 13:20:38 +07:00
v-if="!readonly && !create"
2024-08-07 17:56:59 +07:00
class="q-ml-auto"
2024-08-09 13:20:38 +07:00
type="button"
2024-08-07 17:56:59 +07:00
:disabled="actionDisabled"
2024-08-09 13:20:38 +07:00
@click="$emit('cancel')"
2024-08-07 17:56:59 +07:00
/>
2024-08-09 13:20:38 +07:00
<SaveButton
2024-08-08 13:32:46 +07:00
icon-only
2024-08-09 13:20:38 +07:00
v-if="!readonly"
2024-08-13 12:52:25 +07:00
:class="{ 'q-ml-auto': create }"
2024-08-09 13:20:38 +07:00
@click="$emit('save')"
2024-08-14 09:43:54 +07:00
type="submit"
2024-08-07 17:56:59 +07:00
:disabled="actionDisabled"
2024-09-16 14:38:04 +07:00
/> -->
2024-08-05 15:09:36 +07:00
</div>
2024-08-20 18:04:27 +07:00
2024-08-23 09:19:23 +07:00
<div class="col-12 row q-col-gutter-sm">
2024-09-16 14:38:04 +07:00
<div class="col-12 row q-col-gutter-sm">
<q-select
outlined
clearable
use-input
fill-input
emit-value
map-options
hide-selected
hide-bottom-space
dense
class="col-6"
option-value="id"
input-debounce="0"
option-label="name"
v-model="registeredBranchId"
:readonly="readonly"
:options="filteredBranchOptions"
:hide-dropdown-icon="readonly"
:label="$t('customer.form.registeredBranch')"
:for="`${prefixId}-input-source-nationality`"
:rules="[
(val) => {
const roles = getRole() || [];
return (
['admin', 'system', 'head_of_admin'].some((v) =>
roles.includes(v),
) ||
!!val ||
$t('form.error.required')
);
},
]"
@filter="branchFilter"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
{{ $t('general.noData') }}
</q-item-section>
</q-item>
</template>
</q-select>
</div>
<div
v-if="customerType === 'CORP' && !create"
class="row col-12 q-col-gutter-sm"
>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-12 col-md-6"
:label="$t('customer.form.customerName')"
for="input-first-name"
v-model="registerName"
/>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-6 col-md-3"
:label="$t('general.taxNo')"
for="input-first-name-en"
v-model="legalPersonNo"
/>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-6 col-md-3"
:label="$t('customer.table.businessTypePure')"
for="input-first-name-en"
v-model="businessType"
/>
</div>
<div
v-if="customerType === 'PERS' && !create"
class="row col-12 q-col-gutter-sm"
>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-12 col-md-6"
:label="$t('customer.form.employerName')"
for="input-first-name"
v-model="customerName"
/>
<q-input
outlined
class="col-md-3 col-6"
hide-bottom-space
v-model="citizenId"
mask="#############"
:readonly="readonly"
dense
:label="$t('personnel.form.citizenId')"
for="input-citizen-id"
/>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-6 col-md-3"
:label="$t('customer.table.businessTypePure')"
for="input-first-name-en"
v-model="businessType"
/>
</div>
<div v-if="!create" class="row col-12 q-col-gutter-sm">
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-6 col-md-5"
:label="$t('customer.form.jobPosition')"
for="input-first-name-en"
v-model="jobPosition"
/>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-6 col-md-3"
:label="$t('customer.form.headQuarters.telephoneNo')"
for="input-first-name-en"
v-model="telephoneNo"
>
<template #prepend>
<q-icon
size="xs"
name="mdi-phone-outline"
class="cursor-pointer"
color="primary"
/>
</template>
</q-input>
</div>
</div>
<!-- <div v-if="customerType === 'CORP'" class="col-12 row q-col-gutter-sm">
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-12 col-md-6"
:label="$t('customer.form.customerName')"
for="input-first-name"
v-model="customerName"
:rules="[(val: string) => !!val || $t('form.error.required')]"
/>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-12 col-md-6"
:label="$t('customer.form.customerNameEN')"
for="input-first-name-en"
v-model="customerNameEN"
:rules="[
(val: string) => !!val || $t('form.error.required'),
(val: string) =>
/^[A-Za-z]+$/.test(val) || $t('form.error.letterOnly'),
]"
/>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-6 col-md-3"
:label="$t('general.taxNo')"
for="input-first-name-en"
v-model="taxNo"
mask="#############"
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
(val) =>
(val && val.length === 13 && /[0-9]+/.test(val)) ||
$t('form.error.invalidCustomeMessage', {
msg: $t('form.error.requireLength', { msg: 13 }),
}),
]"
/>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-6 col-md-3"
:label="$t('customer.table.businessTypePure')"
for="input-first-name-en"
v-model="businessType"
/>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-6 col-md-3"
:label="$t('customer.form.jobPosition')"
for="input-first-name-en"
v-model="jobPosition"
/>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-6 col-md-3"
:label="$t('customer.form.headQuarters.telephoneNo')"
for="input-first-name-en"
v-model="telephoneNo"
>
<template #prepend>
<q-icon
size="xs"
name="mdi-phone-outline"
class="cursor-pointer"
color="primary"
/>
</template>
</q-input>
</div>
<div v-if="customerType === 'PERS'" class="col-12 row q-col-gutter-sm">
<div class="col-9 row q-col-gutter-sm">
<q-select
outlined
clearable
use-input
fill-input
emit-value
map-options
hide-selected
hide-bottom-space
dense
class="col-12"
option-value="id"
input-debounce="0"
option-label="name"
v-model="registeredBranchId"
:readonly="readonly"
:options="filteredBranchOptions"
:hide-dropdown-icon="readonly"
:label="$t('customer.form.registeredBranch')"
:for="`${prefixId}-input-source-nationality`"
:rules="[
(val) => {
const roles = getRole() || [];
return (
['admin', 'system', 'head_of_admin'].some((v) =>
roles.includes(v),
) ||
!!val ||
$t('form.error.required')
);
},
]"
@filter="branchFilter"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
{{ $t('general.noData') }}
</q-item-section>
</q-item>
</template>
</q-select>
<q-select
outlined
use-input
fill-input
emit-value
map-options
hide-selected
hide-bottom-space
input-debounce="0"
option-label="label"
option-value="value"
hide-dropdown-icon
class="col-12 col-md-2"
dense
:readonly="readonly"
:options="prefixNameOptions"
:for="`${prefixId}-select-prefix-name`"
:label="$t('form.prefixName')"
@filter="prefixNameFilter"
:model-value="readonly ? namePrefix || '-' : namePrefix"
@update:model-value="
(v) => {
typeof v === 'string' ? (namePrefix = v) : '';
}
"
@clear="namePrefix = ''"
:rules="[
(val) => {
const roles = getRole() || [];
return !!val || $t('form.error.required');
},
]"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
{{ $t('general.noData') }}
</q-item-section>
</q-item>
</template>
</q-select>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-12 col-md-5"
:label="$t('customer.form.firstName')"
for="input-first-name"
v-model="firstName"
:rules="[
(val) => {
const roles = getRole() || [];
return !!val || $t('form.error.required');
},
]"
/>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-12 col-md-5"
:label="$t('customer.form.lastName')"
for="input-last-name"
v-model="lastName"
:rules="[
(val) => {
const roles = getRole() || [];
return !!val || $t('form.error.required');
},
]"
/>
<q-input
dense
outlined
:disable="!readonly"
readonly
hide-bottom-space
class="col-12 col-md-2"
label="Title"
for="input-prefix-name-en"
:model-value="
readonly
? capitalize(namePrefix || '') || '-'
: capitalize(namePrefix || '')
"
/>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-12 col-md-5"
label="Name"
for="input-first-name-en"
v-model="firstNameEN"
:rules="[
(val: string) => !!val || $t('form.error.required'),
(val: string) =>
/^[A-Za-z]+$/.test(val) || $t('form.error.letterOnly'),
]"
/>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-12 col-md-5"
label="Surname"
for="input-last-name-en"
v-model="lastNameEN"
:rules="[
(val: string) => !!val || $t('form.error.required'),
(val: string) =>
/^[A-Za-z]+$/.test(val) || $t('form.error.letterOnly'),
]"
/>
<q-input
outlined
class="col-md-5 col-12"
hide-bottom-space
v-model="lastNameEN"
mask="#############"
:readonly="readonly"
dense
:label="$t('personnel.form.citizenId')"
:rules="[
(val) => (val && val.length > 0) || $t('form.error.required'),
(val) =>
(val && val.length === 13 && /[0-9]+/.test(val)) ||
$t('form.error.invalidCustomeMessage', {
msg: $t('form.error.requireLength', { msg: 13 }),
}),
]"
for="input-citizen-id"
/>
<q-select
outlined
use-input
fill-input
emit-value
map-options
hide-selected
hide-bottom-space
input-debounce="0"
option-label="label"
option-value="value"
class="col-md-2 col-6"
dense
:readonly="readonly"
:options="genderOptions"
:hide-dropdown-icon="readonly"
:for="`${prefixId}-select-gender`"
:label="$t('form.gender')"
@filter="genderFilter"
:model-value="readonly ? gender || '-' : gender"
@update:model-value="
(v) => (typeof v === 'string' ? (gender = v) : '')
"
@clear="gender = ''"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
{{ $t('general.noData') }}
</q-item-section>
</q-item>
</template>
</q-select>
<DatePicker
v-model="birthDate"
class="col-md col-6"
:id="`${prefixId}-input-birth-date`"
:readonly="readonly"
:label="$t('form.birthDate')"
:disabled-dates="disabledAfterToday"
:rules="[
(val: string) =>
!!val ||
$t('form.error.selectField', { field: $t('form.birthDate') }),
]"
/>
<q-input
:for="`${prefixId}-input-age`"
:id="`${prefixId}-input-age`"
dense
outlined
:label="$t('personnel.age')"
class="col-md col-12"
:model-value="
birthDate?.toString() === 'Invalid Date' ||
birthDate?.toString() === undefined
? ''
: calculateAge(birthDate)
"
/>
</div>
<div class="row col-12 q-col-gutter-sm">
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-6 col-md"
:label="$t('customer.table.businessTypePure')"
for="input-first-name-en"
v-model="firstNameEN"
/>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-6 col-md"
:label="$t('customer.form.jobPosition')"
for="input-first-name-en"
v-model="firstNameEN"
/>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
class="col-6 col-md-3"
:label="$t('customer.form.headQuarters.telephoneNo')"
for="input-first-name-en"
v-model="firstNameEN"
>
<template #prepend>
<q-icon
size="xs"
name="mdi-phone-outline"
class="cursor-pointer"
color="primary"
/>
</template>
</q-input>
</div>
</div> -->
<!-- <div class="col-12 row q-col-gutter-sm">
2024-08-20 18:04:27 +07:00
<q-select
outlined
clearable
use-input
fill-input
emit-value
map-options
hide-selected
hide-bottom-space
dense
2024-08-23 09:19:23 +07:00
class="col-12 col-md-7"
2024-08-20 18:04:27 +07:00
option-value="id"
input-debounce="0"
option-label="name"
v-model="registeredBranchId"
:readonly="readonly"
:options="filteredBranchOptions"
:hide-dropdown-icon="readonly"
2024-08-26 16:24:08 +07:00
:label="$t('customer.form.registeredBranch')"
2024-08-20 18:04:27 +07:00
:for="`${prefixId}-input-source-nationality`"
:rules="[
(val) => {
const roles = getRole() || [];
return (
['admin', 'system', 'head_of_admin'].some((v) =>
roles.includes(v),
) ||
!!val ||
$t('form.error.required')
);
},
]"
@filter="branchFilter"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
2024-08-26 16:24:08 +07:00
{{ $t('general.noData') }}
2024-08-20 18:04:27 +07:00
</q-item-section>
</q-item>
</template>
</q-select>
</div>
<div class="col-12 row q-col-gutter-sm">
<q-select
outlined
use-input
fill-input
emit-value
map-options
hide-selected
hide-bottom-space
input-debounce="0"
option-label="label"
option-value="value"
hide-dropdown-icon
2024-08-23 09:19:23 +07:00
class="col-12 col-md-2"
2024-08-20 18:04:27 +07:00
dense
:readonly="readonly"
:options="prefixNameOptions"
:for="`${prefixId}-select-prefix-name`"
2024-08-26 16:24:08 +07:00
:label="$t('form.prefixName')"
2024-08-20 18:04:27 +07:00
@filter="prefixNameFilter"
:model-value="readonly ? namePrefix || '-' : namePrefix"
@update:model-value="
(v) => {
typeof v === 'string' ? (namePrefix = v) : '';
}
"
@clear="namePrefix = ''"
2024-08-23 11:11:31 +07:00
:rules="[
(val) => {
const roles = getRole() || [];
return !!val || $t('form.error.required');
},
]"
2024-08-20 18:04:27 +07:00
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
2024-08-26 16:24:08 +07:00
{{ $t('general.noData') }}
2024-08-20 18:04:27 +07:00
</q-item-section>
</q-item>
</template>
</q-select>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
2024-08-23 09:19:23 +07:00
class="col-12 col-md-5"
2024-08-20 18:04:27 +07:00
:label="$t('customer.form.firstName')"
for="input-first-name"
v-model="firstName"
2024-08-23 11:11:31 +07:00
:rules="[
(val) => {
const roles = getRole() || [];
return !!val || $t('form.error.required');
},
]"
2024-08-20 18:04:27 +07:00
/>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
2024-08-23 09:19:23 +07:00
class="col-12 col-md-5"
2024-08-20 18:04:27 +07:00
:label="$t('customer.form.lastName')"
for="input-last-name"
v-model="lastName"
2024-08-23 11:11:31 +07:00
:rules="[
(val) => {
const roles = getRole() || [];
return !!val || $t('form.error.required');
},
]"
2024-08-20 18:04:27 +07:00
/>
</div>
<div class="col-12 row q-col-gutter-sm">
<q-input
dense
outlined
2024-08-23 09:51:00 +07:00
:disable="!readonly"
readonly
2024-08-20 18:04:27 +07:00
hide-bottom-space
2024-08-23 09:19:23 +07:00
class="col-12 col-md-2"
2024-08-20 18:04:27 +07:00
:label="$t('customer.form.prefixName')"
for="input-prefix-name"
:model-value="
readonly
? capitalize(namePrefix || '') || '-'
: capitalize(namePrefix || '')
2024-08-20 18:04:27 +07:00
"
/>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
2024-08-23 09:19:23 +07:00
class="col-12 col-md-5"
2024-08-20 18:04:27 +07:00
:label="$t('customer.form.firstNameEN')"
for="input-first-name-en"
v-model="firstNameEN"
2024-09-11 09:56:38 +07:00
:rules="[
(val: string) => !!val || $t('form.error.required'),
(val: string) =>
/^[A-Za-z]+$/.test(val) || $t('form.error.letterOnly'),
]"
2024-08-20 18:04:27 +07:00
/>
<q-input
dense
outlined
:readonly="readonly"
hide-bottom-space
2024-08-23 09:19:23 +07:00
class="col-12 col-md-5"
2024-08-20 18:04:27 +07:00
:label="$t('customer.form.lastNameEN')"
for="input-last-name-en"
v-model="lastNameEN"
2024-09-11 09:56:38 +07:00
:rules="[
(val: string) => !!val || $t('form.error.required'),
(val: string) =>
/^[A-Za-z]+$/.test(val) || $t('form.error.letterOnly'),
]"
2024-08-20 18:04:27 +07:00
/>
</div>
<div class="col-12 row q-col-gutter-sm">
<q-select
outlined
use-input
fill-input
emit-value
map-options
hide-selected
hide-bottom-space
input-debounce="0"
option-label="label"
option-value="value"
2024-08-23 09:19:23 +07:00
class="col-12 col-md-2"
2024-08-20 18:04:27 +07:00
dense
:readonly="readonly"
:options="genderOptions"
:hide-dropdown-icon="readonly"
:for="`${prefixId}-select-gender`"
2024-08-26 16:24:08 +07:00
:label="$t('form.gender')"
2024-08-20 18:04:27 +07:00
@filter="genderFilter"
:model-value="readonly ? gender || '-' : gender"
@update:model-value="(v) => (typeof v === 'string' ? (gender = v) : '')"
@clear="gender = ''"
2024-08-23 11:11:31 +07:00
:rules="[
(val) => {
const roles = getRole() || [];
return !!val || $t('form.error.required');
},
]"
2024-08-20 18:04:27 +07:00
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
2024-08-26 16:24:08 +07:00
{{ $t('general.noData') }}
2024-08-20 18:04:27 +07:00
</q-item-section>
</q-item>
</template>
</q-select>
<VueDatePicker
:id="`${prefixId}-input-birth-date`"
:for="`${prefixId}-input-birth-date`"
utc
autoApply
v-model="birthDate"
:disabled-dates="disabledAfterToday"
:teleport="true"
:dark="$q.dark.isActive"
2024-08-26 16:24:08 +07:00
:locale="$i18n.locale === 'tha' ? 'th' : 'en'"
2024-08-20 18:04:27 +07:00
:enableTimePicker="false"
:disabled="readonly"
2024-08-23 09:19:23 +07:00
class="col-12 col-md-3"
2024-08-20 18:04:27 +07:00
>
<template #year="{ value }">
2024-08-26 16:24:08 +07:00
{{ $i18n.locale === 'tha' ? value + 543 : value }}
2024-08-20 18:04:27 +07:00
</template>
<template #year-overlay-value="{ value }">
2024-08-26 16:24:08 +07:00
{{ $i18n.locale === 'tha' ? value + 543 : value }}
2024-08-20 18:04:27 +07:00
</template>
<template #trigger>
<q-input
:for="`${prefixId}-input-birth-date`"
hide-bottom-space
placeholder="DD/MM/YYYY"
2024-08-26 16:24:08 +07:00
:label="$t('form.birthDate')"
2024-08-20 18:04:27 +07:00
dense
outlined
:readonly="readonly"
:rules="[
(val: string) =>
2024-08-26 16:24:08 +07:00
!!val || $t('selectValidate') + $t('form.birthDate'),
2024-08-20 18:04:27 +07:00
]"
:mask="readonly ? '' : '##/##/####'"
:model-value="
birthDate && readonly
? dateFormat(birthDate)
: dateFormat(birthDate, false, false, true)
"
@update:model-value="
(v) => {
if (v && v.toString().length === 10) {
const today = new Date();
const date = parseAndFormatDate(v, locale);
birthDate = date && date > today ? today : date;
}
}
"
>
<template v-slot:prepend>
<q-icon
size="xs"
name="mdi-calendar-blank-outline"
class="cursor-pointer"
color="primary"
/>
</template>
</q-input>
</template>
</VueDatePicker>
<q-input
:for="`${prefixId}-input-age`"
:id="`${prefixId}-input-age`"
dense
outlined
2024-09-04 16:20:22 +07:00
readonly
2024-08-26 16:24:08 +07:00
:label="$t('general.age')"
2024-08-23 09:19:23 +07:00
class="col-12 col-md-2"
2024-08-20 18:04:27 +07:00
:model-value="
birthDate?.toString() === 'Invalid Date' ||
birthDate?.toString() === undefined
? ''
: calculateAge(birthDate)
"
/>
2024-09-16 14:38:04 +07:00
</div> -->
2024-08-05 15:09:36 +07:00
</div>
</template>