fix: customer => warning

This commit is contained in:
puriphatt 2024-12-10 15:55:01 +07:00
parent 682d6cdae8
commit a5dd047ee5
3 changed files with 42 additions and 27 deletions

View file

@ -12,7 +12,12 @@ import useOcrStore from 'stores/ocr';
import useCustomerStore from 'stores/customer'; import useCustomerStore from 'stores/customer';
import useEmployeeStore from 'stores/employee'; import useEmployeeStore from 'stores/employee';
import useMyBranchStore from 'stores/my-branch'; import useMyBranchStore from 'stores/my-branch';
import { dialog, notify, resetScrollBar } from 'stores/utils'; import {
dialog,
notify,
resetScrollBar,
capitalizeFirstLetter,
} from 'stores/utils';
import { useNavigator } from 'src/stores/navigator'; import { useNavigator } from 'src/stores/navigator';
import useFlowStore from 'stores/flow'; import useFlowStore from 'stores/flow';
import { Status } from 'stores/types'; import { Status } from 'stores/types';
@ -21,6 +26,7 @@ import {
Customer, Customer,
CustomerBranch, CustomerBranch,
CustomerBranchCreate, CustomerBranchCreate,
CustomerType,
} from 'stores/customer/types'; } from 'stores/customer/types';
import { Employee, EmployeeHistory } from 'stores/employee/types'; import { Employee, EmployeeHistory } from 'stores/employee/types';
import { import {
@ -627,7 +633,8 @@ function customerFormUndo(close = true) {
async function createCustomerForm(customerType: 'CORP' | 'PERS') { async function createCustomerForm(customerType: 'CORP' | 'PERS') {
customerFormState.value.dialogModal = true; customerFormState.value.dialogModal = true;
customerFormState.value.dialogType = 'create'; customerFormState.value.dialogType = 'create';
customerFormData.value.customerType = customerType; customerFormData.value.customerType =
customerType === 'CORP' ? CustomerType.Corporate : CustomerType.Person;
} }
function createEmployeeForm() { function createEmployeeForm() {
@ -705,7 +712,7 @@ watch(
const isEdit = const isEdit =
employeeFormState.value.drawerModal && employeeFormState.value.drawerModal &&
employeeFormState.value.isEmployeeEdit; employeeFormState.value.isEmployeeEdit;
let currentFormDate = toISOStringWithTimezone(new Date(v)); let currentFormDate = v && toISOStringWithTimezone(new Date(v));
let currentDate: string = ''; let currentDate: string = '';
if (isEdit && employeeFormState.value.currentEmployee) { if (isEdit && employeeFormState.value.currentEmployee) {
@ -1268,7 +1275,11 @@ const emptyCreateDialog = ref(false);
{{ {{
props.row.customerType === 'CORP' props.row.customerType === 'CORP'
? props.row.branch[0]?.registerNameEN || '-' ? props.row.branch[0]?.registerNameEN || '-'
: props.row.branch[0]?.firstNameEN + : capitalizeFirstLetter(
props.row.branch[0].namePrefix,
) +
' ' +
props.row.branch[0]?.firstNameEN +
' ' + ' ' +
props.row.branch[0]?.lastNameEN || '-' props.row.branch[0]?.lastNameEN || '-'
}} }}
@ -1513,7 +1524,7 @@ const emptyCreateDialog = ref(false);
<BranchCard <BranchCard
i18n-key="customer.table" i18n-key="customer.table"
class="surface-1 col" class="surface-1 col"
:virtual-branch="props.row.virtual" :virtual-branch="false"
:id="`branch-card-${props.row.name}`" :id="`branch-card-${props.row.name}`"
:class="{ :class="{
'cursor-pointer': props.row._count.branch !== 0, 'cursor-pointer': props.row._count.branch !== 0,
@ -2269,7 +2280,6 @@ const emptyCreateDialog = ref(false);
v-model:customer-branch="customerFormData.customerBranch[idx]" v-model:customer-branch="customerFormData.customerBranch[idx]"
:onCreate="customerFormState.dialogType === 'create'" :onCreate="customerFormState.dialogType === 'create'"
:customer-type="customerFormData.customerType" :customer-type="customerFormData.customerType"
:customer-name="`${customerFormData.firstName} ${customerFormData.lastName}`"
:readonly="customerFormState.branchIndex !== idx" :readonly="customerFormState.branchIndex !== idx"
:action-disabled=" :action-disabled="
!customerFormState.readonly || !customerFormState.readonly ||
@ -3306,6 +3316,7 @@ const emptyCreateDialog = ref(false);
<FormEmployeeVisa <FormEmployeeVisa
v-for="(value, index) in currentFromDataEmployee.employeeVisa" v-for="(value, index) in currentFromDataEmployee.employeeVisa"
:key="index"
prefix-id="drawer-info-employee" prefix-id="drawer-info-employee"
id="form-visa" id="form-visa"
dense dense
@ -3661,25 +3672,24 @@ const emptyCreateDialog = ref(false);
{{ $t('general.image') }} {{ $t('general.image') }}
{{ {{
$i18n.locale === 'eng' $i18n.locale === 'eng'
? `${customerFormData.firstNameEN} ${customerFormData.lastNameEN}` ? customerFormData.customerType === 'CORP'
: `${customerFormData.firstName} ${customerFormData.lastName}` ? customerFormData?.customerBranch?.[0].registerNameEN || '-'
: customerFormData?.customerBranch?.[0].firstNameEN +
' ' +
customerFormData?.customerBranch?.[0].lastNameEN || '-'
: customerFormData.customerType === 'CORP'
? customerFormData?.customerBranch?.[0].registerName || '-'
: customerFormData?.customerBranch?.[0].firstName +
' ' +
customerFormData?.customerBranch?.[0].lastName || '-'
}} }}
</span> </span>
</template> </template>
<template #error> <template #error>
<div class="full-height full-width" style="background: white"> <div class="full-height full-width" style="background: white">
<div <div class="full-height full-width flex justify-center items-center">
class="full-height full-width flex justify-center items-center"
:style="`background: ${
customerFormData.gender
? customerFormData.customerType === 'CORP'
? '#5f1775'
: '#347454'
: `hsla(var(--${customerFormData.customerType === 'PERS' ? 'teal-10-hsl' : 'violet-11-hsl'})/0.1)`
}`"
>
<q-img <q-img
:src="`/images/customer-${customerFormData.customerType}-avartar-${customerFormData.customerType === 'PERS' ? customerFormData.gender : 'male'}.png`" :src="`/images/customer-${customerFormData.customerType}-avartar-male.png`"
fit="contain" fit="contain"
style="height: 100%" style="height: 100%"
> >
@ -3754,7 +3764,7 @@ const emptyCreateDialog = ref(false);
imageList ? (imageList.selectedImage = v) : ''; imageList ? (imageList.selectedImage = v) : '';
employeeFormState.profileUrl = `${baseUrl}/employee/${currentFromDataEmployee.id && currentFromDataEmployee.id}/image/${v}`; employeeFormState.profileUrl = `${baseUrl}/employee/${currentFromDataEmployee.id && currentFromDataEmployee.id}/image/${v}`;
employeeFormStore.resetFormDataEmployee(); employeeFormStore.resetFormDataEmployee();
await employeeFormStore.submitPersonal(); await employeeFormStore.submitPersonal(onCreateImageList);
employeeFormState.imageDialog = false; employeeFormState.imageDialog = false;
refreshImageState = false; refreshImageState = false;
employeeFormState.isEmployeeEdit = false; employeeFormState.isEmployeeEdit = false;
@ -3797,9 +3807,10 @@ const emptyCreateDialog = ref(false);
hide-action hide-action
v-model:drawer-open="customerFormState.drawerModal" v-model:drawer-open="customerFormState.drawerModal"
:title=" :title="
customerFormData.customerType === 'CORP' customerFormData.customerType === 'CORP' &&
? customerFormData.customerBranch[0]?.registerName customerFormData.customerBranch
: customerNameInfo ? customerFormData.customerBranch[0]?.registerName || '-'
: customerNameInfo || '-'
" "
:badge-label=" :badge-label="
customerFormData.customerType === 'CORP' customerFormData.customerType === 'CORP'
@ -4144,7 +4155,6 @@ const emptyCreateDialog = ref(false);
customerFormData.customerBranch[idx] customerFormData.customerBranch[idx]
" "
:customer-type="customerFormData.customerType" :customer-type="customerFormData.customerType"
:customer-name="`${customerFormData.firstName} ${customerFormData.lastName}`"
:action-disabled=" :action-disabled="
!customerFormState.readonly || !customerFormState.readonly ||
(customerFormState.branchIndex !== -1 && (customerFormState.branchIndex !== -1 &&
@ -4964,7 +4974,7 @@ const emptyCreateDialog = ref(false);
" "
> >
<template #form="{ mode, meta, isEdit }"> <template #form="{ mode, meta, isEdit }">
<FormCitizen <!-- <FormCitizen
v-if="mode === 'citizen' && meta" v-if="mode === 'citizen' && meta"
orc orc
ra ra
@ -4976,7 +4986,7 @@ const emptyCreateDialog = ref(false);
v-model:last-name="meta.lastName" v-model:last-name="meta.lastName"
v-model:last-name-en="meta.lastNameEN" v-model:last-name-en="meta.lastNameEN"
v-model:address="meta.address" v-model:address="meta.address"
/> /> -->
<FormEmployeePassport <FormEmployeePassport
v-if="mode === 'passport' && meta" v-if="mode === 'passport' && meta"
@ -5057,6 +5067,7 @@ const emptyCreateDialog = ref(false);
v-for="( v-for="(
value, index value, index
) in currentFromDataEmployee.employeePassport" ) in currentFromDataEmployee.employeePassport"
:key="index"
> >
<FormEmployeePassport <FormEmployeePassport
v-if="value !== undefined" v-if="value !== undefined"
@ -5211,6 +5222,7 @@ const emptyCreateDialog = ref(false);
</div> </div>
<FormEmployeeVisa <FormEmployeeVisa
v-for="(value, index) in currentFromDataEmployee.employeeVisa" v-for="(value, index) in currentFromDataEmployee.employeeVisa"
:key="index"
prefix-id="drawer-info-employee" prefix-id="drawer-info-employee"
id="form-visa" id="form-visa"
dense dense

View file

@ -47,7 +47,6 @@ defineEmits<{
withDefaults( withDefaults(
defineProps<{ defineProps<{
index: number; index: number;
customerName: string;
readonly?: boolean; readonly?: boolean;
prefixId?: string; prefixId?: string;
onCreate?: boolean; onCreate?: boolean;

View file

@ -533,3 +533,7 @@ export function changeMode(mode: string) {
return; return;
} }
} }
export function capitalizeFirstLetter(val: string) {
return String(val).charAt(0).toUpperCase() + String(val).slice(1);
}