jws-frontend/src/components/03_customer-management/BasicInformation.vue

336 lines
9.2 KiB
Vue
Raw Normal View History

2024-04-22 17:00:30 +07:00
<script setup lang="ts">
import { CustomerBranch } from 'src/stores/customer/types';
2024-06-11 12:27:58 +00:00
import { onMounted, ref } from 'vue';
2024-06-11 04:58:59 +00:00
2024-06-18 13:59:12 +07:00
const personName = defineModel<string>('personName');
const customerName = defineModel<string>('customerName');
const customerNameEn = defineModel<string>('customerNameEn');
const taxNo = defineModel<string | null | undefined>('taxNo');
const employerID = defineModel<string>('employerID');
2024-04-22 17:00:30 +07:00
// employee
const customerBranch = defineModel<{
id: string;
address: string;
addressEN: string;
provinceId: string;
districtId: string;
subDistrictId: string;
zipCode: string;
}>('customerBranch');
const employeeId = defineModel<string>('employeeId');
const nrcNo = defineModel<string>('nrcNo');
2024-04-22 17:00:30 +07:00
defineProps<{
dense?: boolean;
outlined?: boolean;
readonly?: boolean;
separator?: boolean;
typeCustomer?: string;
employee?: boolean;
2024-06-11 12:27:58 +00:00
employeeOwnerOption?: CustomerBranch[];
2024-04-22 17:00:30 +07:00
}>();
2024-06-11 12:27:58 +00:00
defineEmits<{
(e: 'filterOwnerBranch', val: string, update: void): void;
}>();
onMounted(async () => {});
2024-04-22 17:00:30 +07:00
</script>
<template>
<div class="col-3 app-text-muted">
{{ $t(`formDialogTitleInformation`) }}
</div>
<div v-if="!employee" class="col-9 row q-col-gutter-md">
<q-input
for="input-employer-id"
id="input-employer-id"
2024-06-11 11:23:23 +07:00
v-if="typeCustomer === 'PERS'"
:dense="dense"
:outlined="!readonly"
:readonly="readonly"
:borderless="readonly"
hide-bottom-space
class="col-6"
:label="$t('formDialogCustomerName')"
2024-06-18 13:59:12 +07:00
v-model="personName"
/>
<q-input
for="input-tax-no"
id="input-tax-no"
2024-06-11 11:23:23 +07:00
v-if="typeCustomer === 'PERS'"
:dense="dense"
:outlined="!readonly"
:readonly="readonly"
:borderless="readonly"
hide-bottom-space
class="col-6"
:label="$t('taxNo')"
v-model="taxNo"
/>
2024-04-22 17:00:30 +07:00
<q-input
for="input-customer-name"
id="input-customer-name"
2024-04-22 17:00:30 +07:00
:dense="dense"
:outlined="!readonly"
:readonly="readonly"
:borderless="readonly"
hide-bottom-space
class="col-6"
:label="
$t(typeCustomer === 'PERS' ? 'corporationThai' : 'corporationThaiName')
"
v-model="customerName"
2024-04-22 17:00:30 +07:00
/>
<q-input
for="input-customer-name-en"
id="input-customer-name-en"
2024-04-22 17:00:30 +07:00
:dense="dense"
:outlined="!readonly"
:readonly="readonly"
:borderless="readonly"
hide-bottom-space
class="col-6"
:label="
$t(
typeCustomer === 'PERS'
? 'corporationEnglish'
: 'corporationEnglishName',
)
"
v-model="customerNameEn"
2024-04-22 17:00:30 +07:00
/>
<q-input
v-if="typeCustomer !== 'PERS'"
for="input-owner-name"
:dense="dense"
:outlined="!readonly"
:readonly="readonly"
:borderless="readonly"
hide-bottom-space
class="col-6"
:label="$t('companyOwnerName')"
2024-06-18 13:59:12 +07:00
v-model="personName"
/>
2024-04-22 17:00:30 +07:00
</div>
<div v-if="employee" class="col-9 row q-col-gutter-md">
<q-select
2024-06-17 04:00:43 +00:00
for="select-employer-branch"
2024-06-11 12:27:58 +00:00
use-input
input-debounce="0"
:hide-dropdown-icon="readonly"
:dense="dense"
:outlined="!readonly"
2024-06-14 11:04:57 +00:00
:readonly="readonly || customerBranch !== undefined"
:borderless="readonly"
hide-bottom-space
class="col-12"
2024-06-11 04:58:59 +00:00
:label="$t('formDialogEmployerBranchCode')"
v-model="customerBranch"
:option-value="
(v) => ({
id: v.id,
address: v.address,
addressEN: v.addressEN,
provinceId: v.provinceId,
districtId: v.districtId,
subDistrictId: v.subDistrictId,
zipCode: v.zipCode,
})
"
2024-06-11 04:58:59 +00:00
emit-value
map-options
2024-06-11 12:27:58 +00:00
:options="employeeOwnerOption"
@filter="(val, update) => $emit('filterOwnerBranch', val, update)"
2024-06-11 04:58:59 +00:00
:rules="[
(val: string) =>
!!val || $t('selectValidate') + $t('formDialogEmployerBranchCode'),
]"
>
<template v-slot:option="scope">
2024-06-14 11:04:57 +00:00
<q-item
v-if="scope.opt"
v-bind="scope.itemProps"
class="row items-start col-12 no-padding"
>
<div class="q-ma-sm">
<i class="isax isax-frame5" style="color: var(--brand-1)" />
</div>
<div class="q-mt-sm">
<div>
{{ scope.opt.code }} {{ $t('branchName') }}:
{{ $i18n.locale === 'en-US' ? scope.opt.nameEN : scope.opt.name }}
</div>
2024-06-14 11:04:57 +00:00
<div class="text-caption app-text-muted-2 q-mb-xs">
<div v-if="scope.opt.customer" class="col column">
2024-06-17 04:00:43 +00:00
{{ $t('customerBranchName') }}:
{{
$i18n.locale === 'en-US'
? scope.opt.customer.customerNameEN
: scope.opt.customer.customerName
}}
2024-06-14 11:04:57 +00:00
</div>
<div v-if="scope.opt.province" class="col">
{{ $t('address') }}
{{
$i18n.locale === 'en-US'
? scope.opt.addressEN
: scope.opt.address
}}
{{
$i18n.locale === 'en-US'
? scope.opt.subDistrict.nameEN
: scope.opt.subDistrict.name
}}
{{
$i18n.locale === 'en-US'
? scope.opt.district.nameEN
: scope.opt.district.name
}}
{{
$i18n.locale === 'en-US'
? scope.opt.province.nameEN
: scope.opt.province.name
}}
2024-06-17 04:00:43 +00:00
{{ scope.opt.zipCode }}
2024-06-14 11:04:57 +00:00
</div>
</div>
</div>
</q-item>
2024-06-14 11:04:57 +00:00
<q-separator class="q-mx-sm" />
</template>
<template v-slot:selected-item="scope">
2024-06-17 04:00:43 +00:00
<div v-if="scope.opt" class="row items-center no-wrap">
{{ scope.opt.code }}
{{ $t('branchName') }}:
{{ $i18n.locale === 'en-US' ? scope.opt.nameEN : scope.opt.name }}
2024-06-14 11:04:57 +00:00
<div
class="text-caption app-text-muted-2 ellipsis q-ml-sm"
2024-06-17 04:00:43 +00:00
style="max-width: 24vw; min-width: 0"
v-if="scope.opt.customer && scope.opt.province"
2024-06-14 11:04:57 +00:00
>
{{ $t('customerBranchName') }}:
{{
$i18n.locale === 'en-US'
? scope.opt.customer.customerNameEN
: scope.opt.customer.customerName
}}
{{ $t('address') }}
{{
$i18n.locale === 'en-US' ? scope.opt.addressEN : scope.opt.address
}}
2024-06-14 11:04:57 +00:00
{{
$i18n.locale === 'en-US'
? scope.opt.subDistrict.nameEN
: scope.opt.subDistrict.name
}}
{{
$i18n.locale === 'en-US'
? scope.opt.district.nameEN
: scope.opt.district.name
}}
{{
$i18n.locale === 'en-US'
? scope.opt.province.nameEN
: scope.opt.province.name
2024-06-14 11:04:57 +00:00
}}
2024-06-17 04:00:43 +00:00
{{ scope.opt.zipCode }}
<q-tooltip v-if="scope.opt.customer && scope.opt.province">
2024-06-14 11:04:57 +00:00
{{ $t('customerBranchName') }}:
{{
$i18n.locale === 'en-US'
? scope.opt.customer.customerNameEN
: scope.opt.customer.customerName
}}
{{ $t('address') }}
{{
$i18n.locale === 'en-US'
? scope.opt.addressEN
: scope.opt.address
}}
{{
$i18n.locale === 'en-US'
? scope.opt.subDistrict.nameEN
: scope.opt.subDistrict.name
}}
{{
$i18n.locale === 'en-US'
? scope.opt.district.nameEN
: scope.opt.district.name
}}
{{
$i18n.locale === 'en-US'
? scope.opt.province.nameEN
: scope.opt.province.name
}}
2024-06-17 04:00:43 +00:00
{{ scope.opt.zipCode }}
2024-06-14 11:04:57 +00:00
</q-tooltip>
</div>
</div>
</template>
2024-06-14 11:04:57 +00:00
<template v-slot:append>
<q-icon
v-if="!readonly && customerBranch"
name="mdi-close-circle"
@click.stop="customerBranch = undefined"
class="cursor-pointer clear-btn"
/>
</template>
</q-select>
<q-input
2024-06-11 04:58:59 +00:00
for="input-employeeID"
:dense="dense"
:outlined="!readonly"
:readonly="true"
:borderless="readonly"
hide-bottom-space
class="col-6"
:label="$t('formDialogEmployeeID')"
v-model="employeeId"
/>
<q-input
2024-06-11 12:27:58 +00:00
mask="## #### ###### #"
2024-06-11 04:58:59 +00:00
for="input-nrcNo"
:dense="dense"
:outlined="!readonly"
:readonly="readonly"
:borderless="readonly"
hide-bottom-space
class="col-6"
:label="$t('formDialogEmployeeNRCNo')"
v-model="nrcNo"
2024-06-11 04:58:59 +00:00
:rules="[
(val: string) =>
!!val || $t('inputValidate') + $t('formDialogEmployeeNRCNo'),
]"
/>
</div>
2024-04-22 17:00:30 +07:00
<q-separator
v-if="separator"
class="col-12 q-mt-xl q-mb-md"
style="padding-block: 0.5px"
/>
</template>
2024-06-14 11:04:57 +00:00
<style scoped lang="scss">
.clear-btn {
opacity: 50%;
transition: opacity 0.2s ease-in-out;
&:hover {
opacity: 100%;
}
}
</style>