refactor: customer

This commit is contained in:
puriphatt 2024-09-17 18:01:13 +07:00
parent e50904bead
commit f2b318060e
11 changed files with 596 additions and 355 deletions

View file

@ -17,6 +17,7 @@ import { CustomerBranch, CustomerType } from 'stores/customer/types';
import { columnsEmployee } from './constant';
import { useCustomerBranchForm, useEmployeeForm } from './form';
import EmployerFormAuthorized from './components/employer/EmployerFormAuthorized.vue';
import ButtonAddComponent from 'components/ButtonAddCompoent.vue';
import SideMenu from 'components/SideMenu.vue';
import { DialogFormContainer, DialogHeader } from 'components/dialog';
@ -77,6 +78,7 @@ const prop = withDefaults(
customerType: CustomerType;
countEmployee?: number;
gender: string;
selectedImage: string;
}>(),
{
color: 'green',
@ -251,12 +253,12 @@ watch([customerId, inputSearch, currentStatus], async () => {
>
<q-avatar no-padding size="50px">
<q-img
:src="`${baseUrl}/customer/${customerId}/image`"
:src="`${baseUrl}/customer/${customerId}/image/${selectedImage}`"
class="full-height full-width"
>
<template #error>
<q-img
:src="`${customerType === 'CORP' ? `/images/customer-CORP-avartar-${gender}.png` : `/images/customer-PERS-avartar-${gender}.png`}`"
:src="`${customerType === 'CORP' ? `/images/customer-CORP-avartar-male.png` : `/images/customer-PERS-avartar-${gender}.png`}`"
/>
</template>
</q-img>
@ -433,9 +435,16 @@ watch([customerId, inputSearch, currentStatus], async () => {
<div class="col" style="min-width: fit-content">
<div class="col">
{{
$i18n.locale === 'eng'
? props.row.registerNameEN
: props.row.registerName
customerType === 'CORP'
? $i18n.locale === 'eng'
? props.row.registerNameEN || '-'
: props.row.registerName || '-'
: $i18n.locale === 'eng'
? props.row.firstNameEN +
' ' +
props.row.lastNameEN || '-'
: props.row.firstName + ' ' + props.row.lastName ||
'-'
}}
</div>
<div class="col app-text-muted">
@ -619,6 +628,7 @@ watch([customerId, inputSearch, currentStatus], async () => {
"
@submit="
async () => {
console.log('asasd');
const res = await customerBranchFormStore.submitForm();
if (res) {
@ -718,7 +728,12 @@ watch([customerId, inputSearch, currentStatus], async () => {
</div>
</div>
<EmployerFormAbout
:index="customerBranchFormData.code"
:readonly="customerBranchFormState.dialogType === 'info'"
class="q-mb-xl"
:index="
customerBranchFormData.code &&
Number(customerBranchFormData.code.split('-').pop()).toString()
"
:customer-type="customerType"
v-model:citizen-id="customerBranchFormData.citizenId"
v-model:prefixName="customerBranchFormData.namePrefix"
@ -738,35 +753,6 @@ watch([customerId, inputSearch, currentStatus], async () => {
v-model:telephoneNo="customerBranchFormData.telephoneNo"
v-model:codeCustomer="customerBranchFormData.codeCustomer"
/>
<div class="row q-col-gutter-sm q-mb-sm" id="employer-branch-address">
<div class="col-12 text-weight-bold text-body1 row items-center">
<q-icon
flat
size="xs"
class="q-pa-sm rounded q-mr-sm"
color="info"
name="mdi-office-building-outline"
style="background-color: var(--surface-3)"
/>
<span>{{ $t('customerBranch.tab.address') }}</span>
</div>
</div>
<AddressForm
prefix-id="employer-branch"
class="q-mb-xl"
hide-title
dense
:readonly="customerBranchFormState.dialogType === 'info'"
outlined
:title="$t('form.address')"
v-model:address="customerBranchFormData.address"
v-model:addressEN="customerBranchFormData.addressEN"
v-model:province-id="customerBranchFormData.provinceId"
v-model:district-id="customerBranchFormData.districtId"
v-model:sub-district-id="customerBranchFormData.subDistrictId"
:addressTitle="$t('form.address')"
:addressTitleEN="$t('form.address', { suffix: '(EN)' })"
/>
<div
class="row q-col-gutter-sm q-mb-sm"
id="employer-branch-business"
@ -789,15 +775,76 @@ watch([customerId, inputSearch, currentStatus], async () => {
outlined
prefix-id="employer-branch"
:readonly="customerBranchFormState.dialogType === 'info'"
v-model:employment-office="customerBranchFormData.employmentOffice"
v-model:bussiness-type="customerBranchFormData.businessType"
v-model:bussiness-type-en="customerBranchFormData.businessTypeEN"
v-model:job-position="customerBranchFormData.jobPosition"
v-model:job-position-en="customerBranchFormData.jobPositionEN"
v-model:job-description="customerBranchFormData.jobDescription"
v-model:sale-employee="customerBranchFormData.saleEmployee"
v-model:pay-date="customerBranchFormData.payDate"
v-model:pay-date-e-n="customerBranchFormData.payDateEN"
v-model:wage-rate="customerBranchFormData.wageRate"
v-model:wage-rate-text="customerBranchFormData.wageRateText"
/>
<div class="row q-col-gutter-sm q-mb-sm" id="employer-branch-address">
<div class="col-12 text-weight-bold text-body1 row items-center">
<q-icon
flat
size="xs"
class="q-pa-sm rounded q-mr-sm"
color="info"
name="mdi-office-building-outline"
style="background-color: var(--surface-3)"
/>
<span>{{ $t('customerBranch.tab.authorized') }}</span>
</div>
</div>
<EmployerFormAuthorized
class="q-mb-xl"
prefix-id="employer-branch"
:readonly="customerBranchFormState.dialogType === 'info'"
v-model:authorized-name="customerBranchFormData.authorizedName"
v-model:authorized-name-e-n="
customerBranchFormData.authorizedNameEN
"
/>
<div class="row q-col-gutter-sm q-mb-sm" id="employer-branch-address">
<div class="col-12 text-weight-bold text-body1 row items-center">
<q-icon
flat
size="xs"
class="q-pa-sm rounded q-mr-sm"
color="info"
name="mdi-office-building-outline"
style="background-color: var(--surface-3)"
/>
<span>{{ $t('customerBranch.tab.address') }}</span>
</div>
</div>
<AddressForm
prefix-id="employer-branch"
class="q-mb-xl"
hide-title
use-employment
dense
:readonly="customerBranchFormState.dialogType === 'info'"
outlined
:title="$t('form.address')"
v-model:homeCode="customerBranchFormData.homeCode"
v-model:employmentOffice="customerBranchFormData.employmentOffice"
v-model:employmentOfficeEN="
customerBranchFormData.employmentOfficeEN
"
v-model:address="customerBranchFormData.address"
v-model:addressEN="customerBranchFormData.addressEN"
v-model:province-id="customerBranchFormData.provinceId"
v-model:district-id="customerBranchFormData.districtId"
v-model:sub-district-id="customerBranchFormData.subDistrictId"
v-model:street="customerBranchFormData.street"
v-model:streetEN="customerBranchFormData.streetEN"
v-model:moo="customerBranchFormData.moo"
v-model:mooEN="customerBranchFormData.mooEN"
v-model:soi="customerBranchFormData.soi"
v-model:soiEN="customerBranchFormData.soiEN"
:addressTitle="$t('form.address')"
:addressTitleEN="$t('form.address', { suffix: '(EN)' })"
/>
<div class="row q-col-gutter-sm q-mb-sm" id="employer-branch-contact">
<div class="col-12 text-weight-bold text-body1 row items-center">
@ -815,8 +862,11 @@ watch([customerId, inputSearch, currentStatus], async () => {
<EmployerFormContact
class="q-mb-lg"
:readonly="customerBranchFormState.dialogType === 'info'"
v-model:contactName="customerBranchFormData.contactName"
v-model:email="customerBranchFormData.email"
v-model:telephone="customerBranchFormData.telephoneNo"
v-model:contactTel="customerBranchFormData.contactTel"
v-model:officeTel="customerBranchFormData.officeTel"
v-model:agent="customerBranchFormData.agent"
/>
</div>
</div>