fix:function ให้ อัปโหลดภาพ hq ได้
This commit is contained in:
parent
1db1ae0296
commit
f84d280685
1 changed files with 35 additions and 13 deletions
|
|
@ -124,10 +124,14 @@ const useBranchStore = defineStore('api-branch', () => {
|
||||||
transactionId: string;
|
transactionId: string;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const { qrCodeImage, ...payload } = branch;
|
const { qrCodeImage, imageUrl, ...payload } = branch;
|
||||||
|
|
||||||
const res = await api.post<
|
const res = await api.post<
|
||||||
Branch & { qrCodeImageUrl: string; qrCodeImageUploadUrl: string }
|
Branch & {
|
||||||
|
qrCodeImageUrl: string;
|
||||||
|
qrCodeImageUploadUrl: string;
|
||||||
|
imageUploadUrl: string;
|
||||||
|
}
|
||||||
>('/branch', payload, {
|
>('/branch', payload, {
|
||||||
headers: {
|
headers: {
|
||||||
'X-Session-Id': flow?.sessionId,
|
'X-Session-Id': flow?.sessionId,
|
||||||
|
|
@ -143,6 +147,16 @@ const useBranchStore = defineStore('api-branch', () => {
|
||||||
onUploadProgress: (e) => console.log(e),
|
onUploadProgress: (e) => console.log(e),
|
||||||
})
|
})
|
||||||
.catch((e) => console.error(e)));
|
.catch((e) => console.error(e)));
|
||||||
|
|
||||||
|
if (imageUrl) {
|
||||||
|
await axios
|
||||||
|
.put(res.data.imageUploadUrl, imageUrl, {
|
||||||
|
headers: { 'Content-Type': imageUrl.type },
|
||||||
|
onUploadProgress: (e) => console.log(e),
|
||||||
|
})
|
||||||
|
.catch((e) => console.error(e));
|
||||||
|
}
|
||||||
|
|
||||||
if (!res) return false;
|
if (!res) return false;
|
||||||
|
|
||||||
return res.data;
|
return res.data;
|
||||||
|
|
@ -151,7 +165,8 @@ const useBranchStore = defineStore('api-branch', () => {
|
||||||
async function editById(
|
async function editById(
|
||||||
id: string,
|
id: string,
|
||||||
data: Partial<BranchCreate & { status: 'ACTIVE' | 'INACTIVE' }>,
|
data: Partial<BranchCreate & { status: 'ACTIVE' | 'INACTIVE' }>,
|
||||||
qrCodeImage?: File,
|
qrCodeImage?: File | undefined,
|
||||||
|
imageHq?: File | undefined,
|
||||||
flow?: {
|
flow?: {
|
||||||
sessionId: string;
|
sessionId: string;
|
||||||
refTransactionId: string;
|
refTransactionId: string;
|
||||||
|
|
@ -159,17 +174,15 @@ const useBranchStore = defineStore('api-branch', () => {
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const { ...payload } = data;
|
const { ...payload } = data;
|
||||||
const res = await api.put<Branch & { qrCodeImageUploadUrl: string }>(
|
const res = await api.put<
|
||||||
`/branch/${id}`,
|
Branch & { qrCodeImageUploadUrl: string; imageUploadUrl: string }
|
||||||
payload,
|
>(`/branch/${id}`, payload, {
|
||||||
{
|
headers: {
|
||||||
headers: {
|
'X-Session-Id': flow?.sessionId,
|
||||||
'X-Session-Id': flow?.sessionId,
|
'X-Rtid': flow?.refTransactionId,
|
||||||
'X-Rtid': flow?.refTransactionId,
|
'X-Tid': flow?.transactionId,
|
||||||
'X-Tid': flow?.transactionId,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
});
|
||||||
|
|
||||||
if (qrCodeImage) {
|
if (qrCodeImage) {
|
||||||
await axios
|
await axios
|
||||||
|
|
@ -180,6 +193,15 @@ const useBranchStore = defineStore('api-branch', () => {
|
||||||
.catch((e) => console.error(e));
|
.catch((e) => console.error(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (imageHq) {
|
||||||
|
await axios
|
||||||
|
.put(res.data.imageUploadUrl, imageHq, {
|
||||||
|
headers: { 'Content-Type': imageHq.type },
|
||||||
|
onUploadProgress: (e) => console.log(e),
|
||||||
|
})
|
||||||
|
.catch((e) => console.error(e));
|
||||||
|
}
|
||||||
|
|
||||||
if (!res) return false;
|
if (!res) return false;
|
||||||
|
|
||||||
return res.data;
|
return res.data;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue