feat: customer form code abbrev

This commit is contained in:
Methapon2001 2024-08-13 12:52:25 +07:00
parent 0af5d049c3
commit 560e9dc272
5 changed files with 52 additions and 10 deletions

View file

@ -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