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;
|
||||
},
|
||||
) {
|
||||
const { qrCodeImage, ...payload } = branch;
|
||||
const { qrCodeImage, imageUrl, ...payload } = branch;
|
||||
|
||||
const res = await api.post<
|
||||
Branch & { qrCodeImageUrl: string; qrCodeImageUploadUrl: string }
|
||||
Branch & {
|
||||
qrCodeImageUrl: string;
|
||||
qrCodeImageUploadUrl: string;
|
||||
imageUploadUrl: string;
|
||||
}
|
||||
>('/branch', payload, {
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
|
|
@ -143,6 +147,16 @@ const useBranchStore = defineStore('api-branch', () => {
|
|||
onUploadProgress: (e) => console.log(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;
|
||||
|
||||
return res.data;
|
||||
|
|
@ -151,7 +165,8 @@ const useBranchStore = defineStore('api-branch', () => {
|
|||
async function editById(
|
||||
id: string,
|
||||
data: Partial<BranchCreate & { status: 'ACTIVE' | 'INACTIVE' }>,
|
||||
qrCodeImage?: File,
|
||||
qrCodeImage?: File | undefined,
|
||||
imageHq?: File | undefined,
|
||||
flow?: {
|
||||
sessionId: string;
|
||||
refTransactionId: string;
|
||||
|
|
@ -159,17 +174,15 @@ const useBranchStore = defineStore('api-branch', () => {
|
|||
},
|
||||
) {
|
||||
const { ...payload } = data;
|
||||
const res = await api.put<Branch & { qrCodeImageUploadUrl: string }>(
|
||||
`/branch/${id}`,
|
||||
payload,
|
||||
{
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
const res = await api.put<
|
||||
Branch & { qrCodeImageUploadUrl: string; imageUploadUrl: string }
|
||||
>(`/branch/${id}`, payload, {
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
if (qrCodeImage) {
|
||||
await axios
|
||||
|
|
@ -180,6 +193,15 @@ const useBranchStore = defineStore('api-branch', () => {
|
|||
.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;
|
||||
|
||||
return res.data;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue