refactor: create customer

This commit is contained in:
Methapon Metanipat 2024-09-16 15:11:03 +07:00
parent 9008bb54da
commit 2ab96dc816

View file

@ -86,7 +86,7 @@ const ocrStore = useOcrStore();
const tabFieldRequired = ref<{ [key: string]: (keyof CustomerBranchCreate)[] }>(
{
main: ['citizenId', 'legalPersonNo', 'registerName'],
main: [],
address: ['address', 'addressEN', 'provinceId', 'districtId'],
business: [],
contact: ['contactName', 'telephoneNo'],
@ -1950,20 +1950,31 @@ const emptyCreateDialog = ref(false);
@submit.prevent="
async () => {
if (!customerFormData.customerBranch) return;
if (!customerFormState.editCustomerId) return;
if (customerFormData.customerType === 'PERS') {
tabFieldRequired.main = [
'citizenId',
'namePrefix',
'firstName',
'firstNameEN',
'lastName',
'lastNameEN',
'gender',
'birthDate',
];
}
if (customerFormData.customerType === 'CORP') {
tabFieldRequired.main = [
'legalPersonNo',
'registerName',
'address',
'addressEN',
'registerNameEN',
'registerDate',
'authorizedCapital',
'authorizedName',
'authorizedNameEN',
'customerName',
];
}
if (customerFormData.customerType === 'PERS') {
tabFieldRequired.main = ['citizenId'];
}
let tapIsUndefined = validateTabField(
customerFormData.customerBranch?.[idx],
tabFieldRequired,
@ -1996,6 +2007,7 @@ const emptyCreateDialog = ref(false);
// id: undefined,
// });
} else {
if (!customerFormState.editCustomerId) return;
await customerStore.editBranchById(
customerFormData.customerBranch[idx].id || '',
{