refactor: use enum instead
This commit is contained in:
parent
7d76521fb6
commit
59c5c0b0ca
2 changed files with 17 additions and 28 deletions
|
|
@ -5,9 +5,7 @@ import { createSelect, SelectProps } from './select';
|
|||
import SelectInput from '../SelectInput.vue';
|
||||
import SelectCustomerItem from './SelectCustomerItem.vue';
|
||||
|
||||
import { Customer, CustomerBranch } from 'src/stores/customer/types';
|
||||
|
||||
import useStore from 'src/stores/customer';
|
||||
import useStore, { Customer, CustomerBranch } from 'src/stores/customer';
|
||||
|
||||
type SelectOption = CustomerBranch & { customer: Customer };
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
<script lang="ts" setup>
|
||||
import { Customer, CustomerBranch } from 'src/stores/customer/types';
|
||||
import { Customer, CustomerBranch, CustomerType } from 'src/stores/customer';
|
||||
import useOptionStore from 'src/stores/options';
|
||||
import { formatAddress } from 'src/utils/address';
|
||||
import { Lang } from 'src/utils/ui';
|
||||
|
||||
defineProps<{
|
||||
data?: CustomerBranch & { customer: Customer };
|
||||
|
|
@ -18,14 +19,14 @@ const optionStore = useOptionStore();
|
|||
<div v-if="simple" class="row items-center">
|
||||
{{
|
||||
{
|
||||
['CORP']: {
|
||||
['eng']: data.registerNameEN,
|
||||
['tha']: data.registerName,
|
||||
[CustomerType.Corporate]: {
|
||||
[Lang.English]: data.registerNameEN,
|
||||
[Lang.Thai]: data.registerName,
|
||||
}[$i18n.locale],
|
||||
['PERS']:
|
||||
[CustomerType.Person]:
|
||||
{
|
||||
['eng']: `${optionStore.mapOption(data.namePrefix)} ${data.firstNameEN} ${data.lastNameEN}`,
|
||||
['tha']: `${optionStore.mapOption(data.namePrefix)} ${data.firstName} ${data.lastName}`,
|
||||
[Lang.English]: `${optionStore.mapOption(data.namePrefix)} ${data.firstNameEN} ${data.lastNameEN}`,
|
||||
[Lang.Thai]: `${optionStore.mapOption(data.namePrefix)} ${data.firstName} ${data.lastName}`,
|
||||
}[$i18n.locale] || '-',
|
||||
}[data.customer.customerType]
|
||||
}}
|
||||
|
|
@ -61,14 +62,14 @@ const optionStore = useOptionStore();
|
|||
</span>
|
||||
{{
|
||||
{
|
||||
['CORP']: {
|
||||
['eng']: data.registerNameEN,
|
||||
['tha']: data.registerName,
|
||||
[CustomerType.Corporate]: {
|
||||
[Lang.English]: data.registerNameEN,
|
||||
[Lang.Thai]: data.registerName,
|
||||
}[$i18n.locale],
|
||||
['PERS']:
|
||||
[CustomerType.Person]:
|
||||
{
|
||||
['eng']: `${optionStore.mapOption(data.namePrefix)} ${data.firstNameEN} ${data.lastNameEN}`,
|
||||
['tha']: `${optionStore.mapOption(data.namePrefix)} ${data.firstName} ${data.lastName}`,
|
||||
[Lang.English]: `${optionStore.mapOption(data.namePrefix)} ${data.firstNameEN} ${data.lastNameEN}`,
|
||||
[Lang.Thai]: `${optionStore.mapOption(data.namePrefix)} ${data.firstName} ${data.lastName}`,
|
||||
}[$i18n.locale] || '-',
|
||||
}[data.customer.customerType]
|
||||
}}
|
||||
|
|
@ -91,22 +92,12 @@ const optionStore = useOptionStore();
|
|||
v-if="data.customer && data.province"
|
||||
>
|
||||
{{ $t('general.address') }}
|
||||
{{
|
||||
{
|
||||
['eng']: formatAddress({ ...data, en: true }),
|
||||
['tha']: formatAddress({ ...data, en: false }),
|
||||
}[$i18n.locale]
|
||||
}}
|
||||
{{ formatAddress({ ...data, en: $i18n.locale === Lang.English }) }}
|
||||
<q-tooltip v-if="data.customer && data.province">
|
||||
{{ $t('customerBranch.form.title') }}:
|
||||
|
||||
{{ $t('general.address') }}
|
||||
{{
|
||||
{
|
||||
['eng']: formatAddress({ ...data, en: true }),
|
||||
['tha']: formatAddress({ ...data, en: false }),
|
||||
}[$i18n.locale]
|
||||
}}
|
||||
{{ formatAddress({ ...data, en: $i18n.locale === Lang.English }) }}
|
||||
</q-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue