fix: customer
This commit is contained in:
parent
cfaf1467a6
commit
4bf1a4a346
11 changed files with 1569 additions and 533 deletions
|
|
@ -333,15 +333,24 @@ const useCustomerStore = defineStore('api-customer', () => {
|
|||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
const { code, customerBranch, image, ...payload } = data;
|
||||
if (data.customerBranch) {
|
||||
if (data.customerBranch[0].citizenId) {
|
||||
console.log('1');
|
||||
delete data.customerBranch[0]['authorizedNameEN'];
|
||||
delete data.customerBranch[0]['authorizedName'];
|
||||
delete data.customerBranch[0]['authorizedCapital'];
|
||||
delete data.customerBranch[0]['registerDate'];
|
||||
delete data.customerBranch[0]['registerNameEN'];
|
||||
delete data.customerBranch[0]['registerName'];
|
||||
delete data.customerBranch[0]['legalPersonNo'];
|
||||
} else {
|
||||
delete data.customerBranch[0]['citizenId'];
|
||||
}
|
||||
if (!data.customerBranch[0].birthDate)
|
||||
delete data.customerBranch[0]['birthDate'];
|
||||
}
|
||||
|
||||
// const attachment = payload.customerBranch?.map((v) => v.file);
|
||||
|
||||
// if (payload.customerBranch?.length) {
|
||||
// for (let i = 0; i < payload.customerBranch?.length; i++) {
|
||||
// delete payload.customerBranch[i].file;
|
||||
// }
|
||||
// }
|
||||
const { customerBranch, image, ...payload } = data;
|
||||
|
||||
const res = await api.post<
|
||||
Customer & {
|
||||
|
|
@ -351,7 +360,18 @@ const useCustomerStore = defineStore('api-customer', () => {
|
|||
}
|
||||
>(
|
||||
'/customer',
|
||||
{ ...payload, selectedImage: imgList.selectedImage },
|
||||
{
|
||||
...payload,
|
||||
branch: data.customerBranch?.map((v) => ({
|
||||
...v,
|
||||
file: undefined,
|
||||
branchCode: undefined,
|
||||
id: undefined,
|
||||
customerId: undefined,
|
||||
customerCode: undefined,
|
||||
})),
|
||||
selectedImage: imgList.selectedImage,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
|
|
@ -361,21 +381,6 @@ const useCustomerStore = defineStore('api-customer', () => {
|
|||
},
|
||||
);
|
||||
|
||||
// await Promise.allSettled([
|
||||
// ...res.data.branch.map(async (v, i) => {
|
||||
// const fileList = attachment?.[i];
|
||||
// if (fileList)
|
||||
// return await addBranchAttachment(v.id, { file: fileList });
|
||||
// }),
|
||||
// image &&
|
||||
// (await api
|
||||
// .put(`/customer/${res.data.id}/image`, image, {
|
||||
// headers: { 'Content-Type': image?.type },
|
||||
// onUploadProgress: (e) => console.log(e),
|
||||
// })
|
||||
// .catch((e) => console.error(e)));
|
||||
// ]);
|
||||
|
||||
if (imgList.list.length > 0 && res.data.id) {
|
||||
for (let index = 0; index < imgList.list.length; index++) {
|
||||
const imgFile = imgList.list[index].imgFile;
|
||||
|
|
|
|||
|
|
@ -34,20 +34,16 @@ export type CustomerBranch = {
|
|||
contactName: string;
|
||||
wageRate: number;
|
||||
payDate: string;
|
||||
saleEmployee: string;
|
||||
payDateEN: string;
|
||||
jobDescription: string;
|
||||
jobPositionEN: string;
|
||||
jobPosition: string;
|
||||
businessTypeEN: string;
|
||||
businessType: string;
|
||||
employmentOffice: string;
|
||||
workplaceEN: string;
|
||||
workplace: string;
|
||||
authorizedCapital: string;
|
||||
registerDate: string;
|
||||
registerDate: Date | null;
|
||||
registerNameEN: string;
|
||||
registerName: string;
|
||||
legalPersonNo: string;
|
||||
legalPersonNo?: string;
|
||||
citizenId: string;
|
||||
updatedByUserId: string;
|
||||
createdByUserId: string;
|
||||
|
|
@ -76,101 +72,81 @@ export type CustomerBranch = {
|
|||
};
|
||||
|
||||
export type CustomerBranchCreate = {
|
||||
code?: string;
|
||||
customerCode?: string;
|
||||
|
||||
contactName: string;
|
||||
|
||||
customerId: string;
|
||||
legalPersonNo?: string;
|
||||
citizenId?: string;
|
||||
namePrefix?: string;
|
||||
firstName?: string;
|
||||
lastName?: string;
|
||||
firstNameEN?: string;
|
||||
lastNameEN?: string;
|
||||
telephoneNo?: string;
|
||||
gender?: string;
|
||||
birthDate?: string;
|
||||
businessType: string;
|
||||
jobPosition: string;
|
||||
jobDescription: string;
|
||||
payDate?: string;
|
||||
payDateEN?: string;
|
||||
wageRate: number;
|
||||
wageRateText: string;
|
||||
homeCode: string;
|
||||
employmentOffice: string;
|
||||
employmentOfficeEN?: string;
|
||||
address: string;
|
||||
addressEN?: string;
|
||||
street: string;
|
||||
streetEN?: string;
|
||||
moo?: string;
|
||||
mooEN?: string;
|
||||
soi?: string;
|
||||
soiEN?: string;
|
||||
provinceId: string;
|
||||
districtId: string;
|
||||
subDistrictId: string;
|
||||
wageRate: number;
|
||||
payDate: Date | null;
|
||||
saleEmployee: string;
|
||||
jobDescription: string;
|
||||
jobPositionEN: string;
|
||||
jobPosition: string;
|
||||
businessTypeEN: string;
|
||||
businessType: string;
|
||||
employmentOffice: string;
|
||||
telephoneNo: string;
|
||||
contactName: string;
|
||||
email: string;
|
||||
addressEN: string;
|
||||
address: string;
|
||||
workplaceEN: string;
|
||||
workplace: string;
|
||||
status: Status | undefined;
|
||||
customerId: string;
|
||||
citizenId?: string;
|
||||
authorizedCapital?: string;
|
||||
registerDate?: Date | null;
|
||||
registerNameEN?: string;
|
||||
contactTel?: string;
|
||||
officeTel?: string;
|
||||
agent?: string;
|
||||
status: Status;
|
||||
customerName?: string;
|
||||
registerName?: string;
|
||||
legalPersonNo?: string;
|
||||
registerCompanyName: string;
|
||||
|
||||
statusSave?: boolean;
|
||||
registerNameEN?: string;
|
||||
registerDate?: Date | null;
|
||||
authorizedCapital?: string;
|
||||
authorizedName?: string;
|
||||
authorizedNameEN?: string;
|
||||
file?: {
|
||||
name?: string;
|
||||
group?: string;
|
||||
url?: string;
|
||||
file?: File;
|
||||
}[];
|
||||
|
||||
// id?: string;
|
||||
// code?: string;
|
||||
// provinceId?: string | null;
|
||||
// branchNo?: number;
|
||||
// address: string;
|
||||
// addressEN: string;
|
||||
// districtId?: string | null;
|
||||
// subDistrictId?: string | null;
|
||||
// zipCode: string;
|
||||
// email: string;
|
||||
// telephoneNo: string;
|
||||
// status?: Status;
|
||||
// name: string;
|
||||
// taxNo?: string | null;
|
||||
// nameEN: string;
|
||||
// legalPersonNo: string;
|
||||
// registerName: string;
|
||||
// registerDate: Date | null;
|
||||
// authorizedCapital: string;
|
||||
// employmentOffice: string;
|
||||
// bussinessType: string;
|
||||
// bussinessTypeEN: string;
|
||||
// jobPosition: string;
|
||||
// jobPositionEN: string;
|
||||
// jobDescription: string;
|
||||
// saleEmployee: string;
|
||||
// payDate: Date;
|
||||
// wageRate: number;
|
||||
// file?: File[];
|
||||
// statusSave?: boolean;
|
||||
};
|
||||
|
||||
export type CustomerCreate = {
|
||||
customerBranch?: (CustomerBranchCreate & {
|
||||
id?: string;
|
||||
branchCode?: string;
|
||||
customerCode?: string;
|
||||
})[];
|
||||
selectedImage?: string;
|
||||
code: string;
|
||||
customerBranch?: (CustomerBranchCreate & { id?: string })[];
|
||||
customerType: CustomerType;
|
||||
status?: Status;
|
||||
image: File | null;
|
||||
customerType: CustomerType;
|
||||
registeredBranchId: string;
|
||||
namePrefix: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
firstNameEN: string;
|
||||
lastNameEN: string;
|
||||
gender: string;
|
||||
birthDate: Date;
|
||||
image: File | null;
|
||||
};
|
||||
|
||||
export type CustomerUpdate = {
|
||||
selectedImage?: string;
|
||||
status?: Status;
|
||||
customerType?: CustomerType;
|
||||
customerBranch?: (CustomerBranchCreate & { id?: string })[];
|
||||
customerBranch?: (CustomerBranchCreate & {
|
||||
id?: string;
|
||||
branchCode?: string;
|
||||
customerCode?: string;
|
||||
})[];
|
||||
image?: File;
|
||||
registeredBranchId: string;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue