fix: customer
This commit is contained in:
parent
cfaf1467a6
commit
4bf1a4a346
11 changed files with 1569 additions and 533 deletions
|
|
@ -563,7 +563,7 @@ function customerFormUndo(close = true) {
|
|||
customerFormState.value.readonly = true;
|
||||
}
|
||||
|
||||
function createCustomerForm(customerType: 'CORP' | 'PERS') {
|
||||
async function createCustomerForm(customerType: 'CORP' | 'PERS') {
|
||||
customerFormState.value.dialogModal = true;
|
||||
customerFormState.value.dialogType = 'create';
|
||||
customerFormData.value.customerType = customerType;
|
||||
|
|
@ -1765,6 +1765,7 @@ const emptyCreateDialog = ref(false);
|
|||
customerFormStore.resetForm(customerFormState.dialogType === 'create');
|
||||
onCreateImageList = { selectedImage: '', list: [] };
|
||||
await fetchListOfOptionBranch();
|
||||
await customerFormStore.addCurrentCustomerBranch();
|
||||
}
|
||||
"
|
||||
:on-close="
|
||||
|
|
@ -1777,23 +1778,22 @@ const emptyCreateDialog = ref(false);
|
|||
<template #header>
|
||||
<DialogHeader
|
||||
:title="
|
||||
$t(`form.title.${customerFormState.dialogType}`, {
|
||||
name: `${$t('customer.employer')} ${
|
||||
customerFormData.customerType === 'CORP'
|
||||
? $t('customer.employerLegalEntity')
|
||||
: $t('customer.employerNaturalPerson')
|
||||
}`,
|
||||
$t(`general.add`, {
|
||||
text: `${$t('customer.employer')} `,
|
||||
})
|
||||
"
|
||||
>
|
||||
<template
|
||||
v-if="
|
||||
customerFormState.dialogType !== 'create' &&
|
||||
customerFormState.editCustomerCode
|
||||
"
|
||||
#title-after
|
||||
>
|
||||
{{ customerFormState.editCustomerCode }}
|
||||
<template #title-after>
|
||||
<span
|
||||
:style="`color: hsla(var(--${customerFormData.customerType === 'PERS' ? 'teal-10-hsl' : 'violet-11-hsl'})/1)`"
|
||||
>
|
||||
:
|
||||
{{
|
||||
customerFormData.customerType === 'CORP'
|
||||
? $t('customer.employerLegalEntity')
|
||||
: $t('customer.employerNaturalPerson')
|
||||
}}
|
||||
</span>
|
||||
</template>
|
||||
</DialogHeader>
|
||||
</template>
|
||||
|
|
@ -1876,17 +1876,16 @@ const emptyCreateDialog = ref(false);
|
|||
<q-form
|
||||
@submit.prevent="
|
||||
async () => {
|
||||
await customerFormStore.submitFormCustomer(onCreateImageList);
|
||||
customerFormState.readonly = true;
|
||||
console.log(customerFormData);
|
||||
// await customerFormStore.submitFormCustomer(onCreateImageList);
|
||||
// customerFormState.readonly = true;
|
||||
notify('create', $t('general.success'));
|
||||
await fetchListCustomer();
|
||||
// await fetchListCustomer();
|
||||
}
|
||||
"
|
||||
greedy
|
||||
:style="{
|
||||
opacity: customerFormState.branchIndex !== -1 ? '0.5' : undefined,
|
||||
}"
|
||||
>
|
||||
<!-- :create="customerFormState.dialogType === 'create'" -->
|
||||
<EmployerFormBasicInfo
|
||||
class="q-mb-xl"
|
||||
:readonly="
|
||||
|
|
@ -1896,7 +1895,7 @@ const emptyCreateDialog = ref(false);
|
|||
"
|
||||
:action-disabled="customerFormState.branchIndex !== -1"
|
||||
id="form-basic-info-customer"
|
||||
:create="customerFormState.dialogType === 'create'"
|
||||
:create="false"
|
||||
@edit="
|
||||
(customerFormState.dialogType = 'edit'),
|
||||
(customerFormState.readonly = false)
|
||||
|
|
@ -1907,26 +1906,19 @@ const emptyCreateDialog = ref(false);
|
|||
deleteCustomerById(customerFormState.editCustomerId)
|
||||
"
|
||||
:customer-type="customerFormData.customerType"
|
||||
v-model:code="customerFormData.code"
|
||||
v-model:registered-branch-id="customerFormData.registeredBranchId"
|
||||
v-mode:customerName="customerFormData.customerName"
|
||||
v-mode:registerName="customerFormData.registerName"
|
||||
v-mode:citizenId="customerFormData.citizenId"
|
||||
v-mode:legalPersonNo="customerFormData.legalPersonNo"
|
||||
v-mode:businessType="customerFormData.businessType"
|
||||
v-mode:jobPosition="customerFormData.jobPosition"
|
||||
v-mode:telephoneNo="customerFormData.telephoneNo"
|
||||
v-model:branch-options="registerAbleBranchOption"
|
||||
v-model:first-name="customerFormData.firstName"
|
||||
v-model:last-name="customerFormData.lastName"
|
||||
v-model:first-name-en="customerFormData.firstNameEN"
|
||||
v-model:last-name-en="customerFormData.lastNameEN"
|
||||
v-model:name-prefix="customerFormData.namePrefix"
|
||||
v-model:gender="customerFormData.gender"
|
||||
v-model:birth-date="customerFormData.birthDate"
|
||||
/>
|
||||
</q-form>
|
||||
<div class="row q-col-gutter-sm" id="form-branch-customer-branch">
|
||||
<div
|
||||
class="col-12 text-weight-bold text-body1 row items-center"
|
||||
:style="{
|
||||
opacity:
|
||||
customerFormState.branchIndex !== -1 ? '0.5' : undefined,
|
||||
}"
|
||||
>
|
||||
<div class="col-12 text-weight-bold text-body1 row items-center">
|
||||
<q-icon
|
||||
flat
|
||||
size="xs"
|
||||
|
|
@ -1940,20 +1932,18 @@ const emptyCreateDialog = ref(false);
|
|||
type="button"
|
||||
class="q-ml-sm"
|
||||
@click="customerFormStore.addCurrentCustomerBranch()"
|
||||
v-if="
|
||||
customerFormState.branchIndex === -1 &&
|
||||
!!customerFormState.editCustomerId
|
||||
"
|
||||
v-if="false"
|
||||
:disabled="!customerFormState.readonly"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<template
|
||||
v-for="(_, idx) in customerFormData.customerBranch"
|
||||
:key="idx"
|
||||
>
|
||||
<!-- v-if="customerFormData.customerBranch" -->
|
||||
<q-form
|
||||
class="full-width"
|
||||
v-if="customerFormData.customerBranch"
|
||||
greedy
|
||||
@submit.prevent="
|
||||
async () => {
|
||||
|
|
@ -1961,7 +1951,12 @@ const emptyCreateDialog = ref(false);
|
|||
if (!customerFormState.editCustomerId) return;
|
||||
|
||||
if (customerFormData.customerType === 'CORP') {
|
||||
filtdRequire.main = ['legalPersonNo', 'registerName'];
|
||||
filtdRequire.main = [
|
||||
'legalPersonNo',
|
||||
'registerName',
|
||||
'address',
|
||||
'addressEN',
|
||||
];
|
||||
}
|
||||
if (customerFormData.customerType === 'PERS') {
|
||||
filtdRequire.main = ['citizenId'];
|
||||
|
|
@ -1988,11 +1983,17 @@ const emptyCreateDialog = ref(false);
|
|||
});
|
||||
} else {
|
||||
if (!customerFormData.customerBranch[idx].id) {
|
||||
await customerStore.createBranch({
|
||||
...customerFormData.customerBranch[idx],
|
||||
customerId: customerFormState.editCustomerId,
|
||||
id: undefined,
|
||||
});
|
||||
await customerFormStore.submitFormCustomer(
|
||||
onCreateImageList,
|
||||
);
|
||||
customerFormState.readonly = true;
|
||||
notify('create', $t('general.success'));
|
||||
await fetchListCustomer();
|
||||
// await customerStore.createBranch({
|
||||
// ...customerFormData.customerBranch[idx],
|
||||
// customerId: customerFormState.editCustomerId,
|
||||
// id: undefined,
|
||||
// });
|
||||
} else {
|
||||
await customerStore.editBranchById(
|
||||
customerFormData.customerBranch[idx].id || '',
|
||||
|
|
@ -2034,18 +2035,18 @@ const emptyCreateDialog = ref(false);
|
|||
}
|
||||
"
|
||||
>
|
||||
<!-- v-if="!!customerFormState.editCustomerId" -->
|
||||
<!-- :action-disabled="
|
||||
!customerFormState.readonly ||
|
||||
(customerFormState.branchIndex !== -1 &&
|
||||
customerFormState.branchIndex !== idx)
|
||||
" -->
|
||||
<EmployerFormBranch
|
||||
v-if="!!customerFormState.editCustomerId"
|
||||
:index="idx"
|
||||
v-model:customer="customerFormData"
|
||||
v-model:customer-branch="customerFormData.customerBranch[idx]"
|
||||
:customer-type="customerFormData.customerType"
|
||||
:customer-name="`${customerFormData.firstName} ${customerFormData.lastName}`"
|
||||
:action-disabled="
|
||||
!customerFormState.readonly ||
|
||||
(customerFormState.branchIndex !== -1 &&
|
||||
customerFormState.branchIndex !== idx)
|
||||
"
|
||||
:readonly="customerFormState.branchIndex !== idx"
|
||||
@edit="() => (customerFormState.branchIndex = idx)"
|
||||
@cancel="() => customerFormUndo(false)"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue