feat: customer form code abbrev
This commit is contained in:
parent
0af5d049c3
commit
560e9dc272
5 changed files with 52 additions and 10 deletions
|
|
@ -1952,6 +1952,7 @@ watch(
|
|||
deleteCustomerById(customerFormState.editCustomerId)
|
||||
"
|
||||
:customer-type="customerFormData.customerType"
|
||||
v-model:code="customerFormData.code"
|
||||
v-model:tax-no="customerFormData.taxNo"
|
||||
v-model:customer-name="customerFormData.customerName"
|
||||
v-model:customer-name-en="customerFormData.customerNameEN"
|
||||
|
|
@ -2724,7 +2725,6 @@ watch(
|
|||
v-model:entry-date="currentFromDataEmployee.entryDate"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="col-10 q-pa-md q-gutter-y-xl" v-else>
|
||||
<FormEmployeeHealthCheck
|
||||
v-if="employeeFormState.currentTab === 'healthCheck'"
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ defineEmits<{
|
|||
(e: 'cancel'): void;
|
||||
}>();
|
||||
|
||||
const code = defineModel<string>('code', { required: true });
|
||||
const personName = defineModel<string>('personName', { required: true });
|
||||
const customerName = defineModel<string>('customerName', { required: true });
|
||||
const customerNameEN = defineModel<string>('customerNameEn', {
|
||||
|
|
@ -64,10 +65,15 @@ watch(
|
|||
);
|
||||
},
|
||||
);
|
||||
|
||||
function formatCode(input: string | undefined, type: 'code' | 'number') {
|
||||
if (!input) return;
|
||||
return input.slice(...(type === 'code' ? [0, -6] : [-6]));
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="row q-col-gutter-sm">
|
||||
<div class="row q-col-gutter-sm q-mb-sm">
|
||||
<div class="col-12 text-weight-bold text-body1 row items-center">
|
||||
<q-icon
|
||||
flat
|
||||
|
|
@ -104,6 +110,7 @@ watch(
|
|||
<SaveButton
|
||||
icon-only
|
||||
v-if="!readonly"
|
||||
:class="{ 'q-ml-auto': create }"
|
||||
@click="$emit('save')"
|
||||
:disabled="actionDisabled"
|
||||
/>
|
||||
|
|
@ -151,6 +158,37 @@ watch(
|
|||
</q-item>
|
||||
</template>
|
||||
</q-select>
|
||||
<q-input
|
||||
lazy-rules="ondemand"
|
||||
dense
|
||||
outlined
|
||||
:disable="!readonly && !create"
|
||||
:readonly="readonly"
|
||||
hide-bottom-space
|
||||
class="col-12 col-md-4"
|
||||
:label="$t('customer.form.codeAbbrev')"
|
||||
for="input-abbreviation"
|
||||
:model-value="!create ? formatCode(code, 'code') : code"
|
||||
:rules="[
|
||||
(val: string) =>
|
||||
(val && val.length > 0 && /[a-zA-Z]+/.test(val)) ||
|
||||
$t('formDialogInputHqAbbreviation'),
|
||||
]"
|
||||
@update:model-value="(v: string) => (code = v)"
|
||||
/>
|
||||
<q-input
|
||||
lazy-rules="ondemand"
|
||||
dense
|
||||
outlined
|
||||
readonly
|
||||
:disable="!readonly"
|
||||
hide-bottom-space
|
||||
class="col-12 col-md-4"
|
||||
:label="$t('customer.form.codeNumber')"
|
||||
for="input-code"
|
||||
:model-value="!create ? formatCode(code, 'number') : ''"
|
||||
@update:model-value="(v: string) => (code = v)"
|
||||
/>
|
||||
<q-input
|
||||
lazy-rules="ondemand"
|
||||
dense
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ export const useCustomerForm = defineStore('form-customer', () => {
|
|||
const branchStore = useMyBranch();
|
||||
|
||||
const defaultFormData: CustomerCreate = {
|
||||
code: '',
|
||||
status: 'CREATED',
|
||||
personName: '',
|
||||
customerType: 'CORP',
|
||||
|
|
@ -106,6 +107,7 @@ export const useCustomerForm = defineStore('form-customer', () => {
|
|||
state.value.customerImageUrl = `${apiBaseUrl}/customer/${id}/image`;
|
||||
|
||||
resetFormData.registeredBranchId = data.registeredBranchId;
|
||||
resetFormData.code = data.code;
|
||||
resetFormData.status = data.status;
|
||||
resetFormData.customerType = data.customerType;
|
||||
resetFormData.customerName = data.customerName;
|
||||
|
|
@ -190,7 +192,11 @@ export const useCustomerForm = defineStore('form-customer', () => {
|
|||
if (state.value.dialogType === 'info') return;
|
||||
|
||||
if (state.value.dialogType === 'create') {
|
||||
return await customerStore.create(currentFormData.value);
|
||||
const _data = await customerStore.create(currentFormData.value);
|
||||
|
||||
if (_data) await assignFormData(_data.id);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!state.value.editCustomerId) {
|
||||
|
|
@ -199,8 +205,10 @@ export const useCustomerForm = defineStore('form-customer', () => {
|
|||
);
|
||||
}
|
||||
|
||||
const { code: _, ...payload } = currentFormData.value;
|
||||
|
||||
const _data = await customerStore.editById(state.value.editCustomerId, {
|
||||
...currentFormData.value,
|
||||
...payload,
|
||||
status:
|
||||
currentFormData.value.status !== 'CREATED'
|
||||
? currentFormData.value.status
|
||||
|
|
|
|||
|
|
@ -182,11 +182,6 @@ const useCustomerStore = defineStore('api-customer', () => {
|
|||
|
||||
const attachment = payload.customerBranch?.map((v) => v.file);
|
||||
|
||||
payload.customerBranch = payload.customerBranch?.map((v) => {
|
||||
delete v['code'];
|
||||
return { ...v };
|
||||
});
|
||||
|
||||
if (payload.customerBranch?.length) {
|
||||
for (let i = 0; i < payload.customerBranch?.length; i++) {
|
||||
delete payload.customerBranch[i].file;
|
||||
|
|
@ -240,7 +235,7 @@ const useCustomerStore = defineStore('api-customer', () => {
|
|||
const attachment = payload.customerBranch?.map((v) => v.file);
|
||||
|
||||
payload.customerBranch = payload.customerBranch?.map((v) => {
|
||||
const { code, ...rest } = v;
|
||||
const { code: _code, ...rest } = v;
|
||||
return { ...rest };
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ export type CustomerBranchCreate = {
|
|||
};
|
||||
|
||||
export type CustomerCreate = {
|
||||
code: string;
|
||||
customerBranch?: (CustomerBranchCreate & { id?: string })[];
|
||||
taxNo?: string | null;
|
||||
customerNameEN: string;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue