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 SelectInput from '../SelectInput.vue';
|
||||||
import SelectCustomerItem from './SelectCustomerItem.vue';
|
import SelectCustomerItem from './SelectCustomerItem.vue';
|
||||||
|
|
||||||
import { Customer, CustomerBranch } from 'src/stores/customer/types';
|
import useStore, { Customer, CustomerBranch } from 'src/stores/customer';
|
||||||
|
|
||||||
import useStore from 'src/stores/customer';
|
|
||||||
|
|
||||||
type SelectOption = CustomerBranch & { customer: Customer };
|
type SelectOption = CustomerBranch & { customer: Customer };
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
<script lang="ts" setup>
|
<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 useOptionStore from 'src/stores/options';
|
||||||
import { formatAddress } from 'src/utils/address';
|
import { formatAddress } from 'src/utils/address';
|
||||||
|
import { Lang } from 'src/utils/ui';
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
data?: CustomerBranch & { customer: Customer };
|
data?: CustomerBranch & { customer: Customer };
|
||||||
|
|
@ -18,14 +19,14 @@ const optionStore = useOptionStore();
|
||||||
<div v-if="simple" class="row items-center">
|
<div v-if="simple" class="row items-center">
|
||||||
{{
|
{{
|
||||||
{
|
{
|
||||||
['CORP']: {
|
[CustomerType.Corporate]: {
|
||||||
['eng']: data.registerNameEN,
|
[Lang.English]: data.registerNameEN,
|
||||||
['tha']: data.registerName,
|
[Lang.Thai]: data.registerName,
|
||||||
}[$i18n.locale],
|
}[$i18n.locale],
|
||||||
['PERS']:
|
[CustomerType.Person]:
|
||||||
{
|
{
|
||||||
['eng']: `${optionStore.mapOption(data.namePrefix)} ${data.firstNameEN} ${data.lastNameEN}`,
|
[Lang.English]: `${optionStore.mapOption(data.namePrefix)} ${data.firstNameEN} ${data.lastNameEN}`,
|
||||||
['tha']: `${optionStore.mapOption(data.namePrefix)} ${data.firstName} ${data.lastName}`,
|
[Lang.Thai]: `${optionStore.mapOption(data.namePrefix)} ${data.firstName} ${data.lastName}`,
|
||||||
}[$i18n.locale] || '-',
|
}[$i18n.locale] || '-',
|
||||||
}[data.customer.customerType]
|
}[data.customer.customerType]
|
||||||
}}
|
}}
|
||||||
|
|
@ -61,14 +62,14 @@ const optionStore = useOptionStore();
|
||||||
</span>
|
</span>
|
||||||
{{
|
{{
|
||||||
{
|
{
|
||||||
['CORP']: {
|
[CustomerType.Corporate]: {
|
||||||
['eng']: data.registerNameEN,
|
[Lang.English]: data.registerNameEN,
|
||||||
['tha']: data.registerName,
|
[Lang.Thai]: data.registerName,
|
||||||
}[$i18n.locale],
|
}[$i18n.locale],
|
||||||
['PERS']:
|
[CustomerType.Person]:
|
||||||
{
|
{
|
||||||
['eng']: `${optionStore.mapOption(data.namePrefix)} ${data.firstNameEN} ${data.lastNameEN}`,
|
[Lang.English]: `${optionStore.mapOption(data.namePrefix)} ${data.firstNameEN} ${data.lastNameEN}`,
|
||||||
['tha']: `${optionStore.mapOption(data.namePrefix)} ${data.firstName} ${data.lastName}`,
|
[Lang.Thai]: `${optionStore.mapOption(data.namePrefix)} ${data.firstName} ${data.lastName}`,
|
||||||
}[$i18n.locale] || '-',
|
}[$i18n.locale] || '-',
|
||||||
}[data.customer.customerType]
|
}[data.customer.customerType]
|
||||||
}}
|
}}
|
||||||
|
|
@ -91,22 +92,12 @@ const optionStore = useOptionStore();
|
||||||
v-if="data.customer && data.province"
|
v-if="data.customer && data.province"
|
||||||
>
|
>
|
||||||
{{ $t('general.address') }}
|
{{ $t('general.address') }}
|
||||||
{{
|
{{ formatAddress({ ...data, en: $i18n.locale === Lang.English }) }}
|
||||||
{
|
|
||||||
['eng']: formatAddress({ ...data, en: true }),
|
|
||||||
['tha']: formatAddress({ ...data, en: false }),
|
|
||||||
}[$i18n.locale]
|
|
||||||
}}
|
|
||||||
<q-tooltip v-if="data.customer && data.province">
|
<q-tooltip v-if="data.customer && data.province">
|
||||||
{{ $t('customerBranch.form.title') }}:
|
{{ $t('customerBranch.form.title') }}:
|
||||||
|
|
||||||
{{ $t('general.address') }}
|
{{ $t('general.address') }}
|
||||||
{{
|
{{ formatAddress({ ...data, en: $i18n.locale === Lang.English }) }}
|
||||||
{
|
|
||||||
['eng']: formatAddress({ ...data, en: true }),
|
|
||||||
['tha']: formatAddress({ ...data, en: false }),
|
|
||||||
}[$i18n.locale]
|
|
||||||
}}
|
|
||||||
</q-tooltip>
|
</q-tooltip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue