refactor: customer table and card

This commit is contained in:
puriphatt 2024-09-18 11:41:03 +07:00
parent 72dbab6b33
commit 2dc6902ff5
4 changed files with 105 additions and 53 deletions

View file

@ -366,6 +366,7 @@ export default {
table: { table: {
orderNumber: 'No.', orderNumber: 'No.',
fullname: 'Full Name', fullname: 'Full Name',
titleName: 'Name',
businessTypePure: 'Business Type', businessTypePure: 'Business Type',
jobPosition: 'Job Position', jobPosition: 'Job Position',
address: 'Address', address: 'Address',

View file

@ -366,6 +366,7 @@ export default {
table: { table: {
orderNumber: 'ลําดับ', orderNumber: 'ลําดับ',
fullname: 'ชื่อ-นามสกุล', fullname: 'ชื่อ-นามสกุล',
titleName: 'ชื่อ บริษัท/นิติบุคคล',
businessTypePure: 'ประเภทกิจการ', businessTypePure: 'ประเภทกิจการ',
jobPosition: 'ตำแหน่งงาน', jobPosition: 'ตำแหน่งงาน',
address: 'ที่อยู่', address: 'ที่อยู่',

View file

@ -914,7 +914,16 @@ const emptyCreateDialog = ref(false);
class="q-ml-sm col" class="q-ml-sm col"
:options=" :options="
currentTab === 'employer' currentTab === 'employer'
? fieldDisplayCustomer ? gridView
? fieldDisplayCustomer.filter((v) => {
return (
v.value !== 'orderNumber' &&
v.value !== 'titleName' &&
v.value !== 'address' &&
v.value !== 'contactName'
);
})
: fieldDisplayCustomer
: fieldDisplayEmployee : fieldDisplayEmployee
" "
:display-value="$t('general.displayField')" :display-value="$t('general.displayField')"
@ -1176,7 +1185,10 @@ const emptyCreateDialog = ref(false);
}} }}
</q-td> </q-td>
<q-td v-if="fieldSelected.includes('fullname')"> <q-td
v-if="fieldSelected.includes('titleName')"
style="padding-block: 7px; padding-inline: 0px"
>
<div class="row items-center"> <div class="row items-center">
<div <div
class="q-mr-sm" class="q-mr-sm"
@ -1238,7 +1250,7 @@ const emptyCreateDialog = ref(false);
? optionStore.mapOption( ? optionStore.mapOption(
props.row.branch[0].businessType, props.row.branch[0].businessType,
) )
: '' : '-'
: '-' : '-'
}} }}
</q-td> </q-td>
@ -1250,21 +1262,29 @@ const emptyCreateDialog = ref(false);
? optionStore.mapOption( ? optionStore.mapOption(
props.row.branch[0].jobPosition, props.row.branch[0].jobPosition,
) )
: '' : '-'
: '-' : '-'
}} }}
</q-td> </q-td>
<q-td v-if="fieldSelected.includes('officeTel')"> <q-td v-if="fieldSelected.includes('address')">
{{ {{
props.row.branch.length !== 0 props.row.branch.length !== 0
? props.row.branch[0].officeTel !== null ? props.row.branch[0].address !== null
? props.row.branch[0].officeTel ? `${props.row.branch[0].address} ${props.row.branch[0].moo} ${props.row.branch[0].soi} ${props.row.branch[0].street} จ.${props.row.branch[0].province.name} อ.${props.row.branch[0].district.name} ต.${props.row.branch[0].subDistrict.name} ${props.row.branch[0].subDistrict.zipCode}`
: '' : '-'
: '-' : '-'
}} }}
</q-td> </q-td>
<q-td v-if="fieldSelected.includes('contactName')">
{{ props.row.branch[0]?.contactName || '-' }}
</q-td>
<q-td v-if="fieldSelected.includes('officeTel')">
{{ props.row.branch[0]?.officeTel || '-' }}
</q-td>
<q-td> <q-td>
<q-btn <q-btn
dense dense
@ -1423,12 +1443,7 @@ const emptyCreateDialog = ref(false);
: props.row.branch[0]?.firstName + : props.row.branch[0]?.firstName +
' ' + ' ' +
props.row.branch[0]?.lastName || '-', props.row.branch[0]?.lastName || '-',
taxNo: 'asdasd',
branchLabelTel: 'asdas',
contactName: 'zxczxcz',
branchImgUrl: `/customer/${props.row.id}/image/${props.row.selectedImage}`,
}" }"
:badge-field="['branchLabelStatus']"
:inactive="props.row.status === 'INACTIVE'" :inactive="props.row.status === 'INACTIVE'"
:field-selected=" :field-selected="
fieldSelected.filter((v) => { fieldSelected.filter((v) => {
@ -1452,8 +1467,8 @@ const emptyCreateDialog = ref(false);
class="absolute-bottom-right no-padding" class="absolute-bottom-right no-padding"
style=" style="
border-radius: 50%; border-radius: 50%;
min-width: 11.31px; min-width: 10px;
min-height: 11.31px; min-height: 10px;
" "
:style="{ :style="{
background: `var(--${props.row.status === 'INACTIVE' ? 'stone-5' : 'green-6'})`, background: `var(--${props.row.status === 'INACTIVE' ? 'stone-5' : 'green-6'})`,
@ -1469,6 +1484,22 @@ const emptyCreateDialog = ref(false);
padding-block: var(--size-2); padding-block: var(--size-2);
" "
> >
<div class="col-12 q-py-sm row">
<span class="col-4 app-text-muted">
{{
props.row.customerType === 'CORP'
? $t('customer.form.legalPersonCode')
: $t('customer.form.cardNumber')
}}
</span>
<span class="col">
{{
props.row.customerType === 'CORP'
? props.row.branch[0]?.legalPersonNo
: props.row.branch[0]?.citizenId
}}
</span>
</div>
<div <div
class="col-12 q-py-sm row" class="col-12 q-py-sm row"
v-for="key in fieldSelected v-for="key in fieldSelected
@ -1479,7 +1510,10 @@ const emptyCreateDialog = ref(false);
}) })
.filter((v) => { .filter((v) => {
return ( return (
v !== 'orderNumber' && v !== 'fullname' v !== 'orderNumber' &&
v !== 'titleName' &&
v !== 'address' &&
v !== 'contactName'
); );
})" })"
:key="key" :key="key"
@ -1927,6 +1961,7 @@ const emptyCreateDialog = ref(false);
{ {
name: $t('customer.form.group.branch'), name: $t('customer.form.group.branch'),
anchor: 'form-branch-customer-branch', anchor: 'form-branch-customer-branch',
useBtn: true,
}, },
...(customerFormData.customerBranch?.map((v, i) => ({ ...(customerFormData.customerBranch?.map((v, i) => ({
name: name:
@ -1945,7 +1980,21 @@ const emptyCreateDialog = ref(false);
foreground: 'var(--blue-6)', foreground: 'var(--blue-6)',
}" }"
scroll-element="#customer-form-content" scroll-element="#customer-form-content"
/> >
<template v-slot:btn-form-branch-customer-branch>
<AddButton
iconOnly
type="button"
@click.stop="customerFormStore.addCurrentCustomerBranch()"
v-if="
customerFormState.branchIndex === -1 &&
!!customerFormState.editCustomerId &&
customerFormState.dialogType !== 'create'
"
:disabled="!customerFormState.readonly"
/>
</template>
</SideMenu>
</div> </div>
</div> </div>
<div <div
@ -2004,18 +2053,6 @@ const emptyCreateDialog = ref(false);
style="background-color: var(--surface-3)" style="background-color: var(--surface-3)"
/> />
<span>{{ $t('customer.form.group.branch') }}</span> <span>{{ $t('customer.form.group.branch') }}</span>
<AddButton
icon-only
type="button"
class="q-ml-sm"
@click="customerFormStore.addCurrentCustomerBranch()"
v-if="
customerFormState.branchIndex === -1 &&
!!customerFormState.editCustomerId &&
customerFormState.dialogType !== 'create'
"
:disabled="!customerFormState.readonly"
/>
</div> </div>
<template <template
@ -2471,7 +2508,6 @@ const emptyCreateDialog = ref(false);
v-model:provinceId="currentFromDataEmployee.provinceId" v-model:provinceId="currentFromDataEmployee.provinceId"
v-model:districtId="currentFromDataEmployee.districtId" v-model:districtId="currentFromDataEmployee.districtId"
v-model:subDistrictId="currentFromDataEmployee.subDistrictId" v-model:subDistrictId="currentFromDataEmployee.subDistrictId"
v-model:zipCode="currentFromDataEmployee.zipCode"
employee employee
dense dense
class="q-mb-xl" class="q-mb-xl"
@ -2935,13 +2971,13 @@ const emptyCreateDialog = ref(false);
() => { () => {
if (customerFormStore.isFormDataDifferent()) { if (customerFormStore.isFormDataDifferent()) {
customerConfirmUnsave(); customerConfirmUnsave();
return false; return true;
} else { } else {
fetchListCustomer(); fetchListCustomer();
customerFormState.branchIndex = -1; customerFormState.branchIndex = -1;
customerFormStore.resetForm(true); customerFormStore.resetForm(true);
} }
return false; return true;
} }
" "
> >
@ -3011,13 +3047,10 @@ const emptyCreateDialog = ref(false);
name: $t('form.field.basicInformation'), name: $t('form.field.basicInformation'),
anchor: 'form-basic-info-customer', anchor: 'form-basic-info-customer',
}, },
{
name: $t('customerBranch.tab.attachment'),
anchor: 'form-upload-file-customer',
},
{ {
name: $t('customer.form.group.branch'), name: $t('customer.form.group.branch'),
anchor: 'form-branch-customer-branch', anchor: 'form-branch-customer-branch',
useBtn: true,
}, },
...(customerFormData.customerBranch?.map((v, i) => ({ ...(customerFormData.customerBranch?.map((v, i) => ({
@ -3037,7 +3070,21 @@ const emptyCreateDialog = ref(false);
foreground: 'var(--blue-6)', foreground: 'var(--blue-6)',
}" }"
scroll-element="#customer-form-content" scroll-element="#customer-form-content"
/> >
<template v-slot:btn-form-branch-customer-branch>
<AddButton
iconOnly
type="button"
@click.stop="customerFormStore.addCurrentCustomerBranch()"
v-if="
customerFormState.branchIndex === -1 &&
!!customerFormState.editCustomerId &&
customerFormState.dialogType !== 'create'
"
:disabled="!customerFormState.readonly"
/>
</template>
</SideMenu>
</div> </div>
</div> </div>
@ -3117,18 +3164,6 @@ const emptyCreateDialog = ref(false);
style="background-color: var(--surface-3)" style="background-color: var(--surface-3)"
/> />
<span>{{ $t('customer.form.group.branch') }}</span> <span>{{ $t('customer.form.group.branch') }}</span>
<AddButton
icon-only
type="button"
class="q-ml-sm"
@click="customerFormStore.addCurrentCustomerBranch()"
v-if="
customerFormState.branchIndex === -1 &&
!!customerFormState.editCustomerId &&
customerFormData.status !== 'INACTIVE'
"
:disabled="!customerFormState.readonly"
/>
</div> </div>
<template <template
@ -3578,7 +3613,6 @@ const emptyCreateDialog = ref(false);
v-model:provinceId="currentFromDataEmployee.provinceId" v-model:provinceId="currentFromDataEmployee.provinceId"
v-model:districtId="currentFromDataEmployee.districtId" v-model:districtId="currentFromDataEmployee.districtId"
v-model:subDistrictId="currentFromDataEmployee.subDistrictId" v-model:subDistrictId="currentFromDataEmployee.subDistrictId"
v-model:zipCode="currentFromDataEmployee.zipCode"
v-model:sameWithEmployer=" v-model:sameWithEmployer="
employeeFormState.formDataEmployeeSameAddr employeeFormState.formDataEmployeeSameAddr
" "

View file

@ -255,10 +255,10 @@ export const columnsCustomer = [
}, },
{ {
name: 'fullname', name: 'titleName',
align: 'left', align: 'left',
label: 'customer.table.fullname', label: 'customer.table.titleName',
field: 'fullname', field: 'titleName',
sortable: true, sortable: true,
}, },
@ -278,6 +278,22 @@ export const columnsCustomer = [
sortable: true, sortable: true,
}, },
{
name: 'address',
align: 'center',
label: 'customer.table.address',
field: 'address',
sortable: true,
},
{
name: 'contactName',
align: 'center',
label: 'customer.table.contactName',
field: 'contactName',
sortable: true,
},
{ {
name: 'officeTel', name: 'officeTel',
align: 'left', align: 'left',