feat: add QR code upload functionality and enhance bank management logic
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 7s
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 7s
This commit is contained in:
parent
dfc17e9623
commit
ef81522561
4 changed files with 157 additions and 22 deletions
|
|
@ -75,18 +75,67 @@ export const useInstitution = defineStore('institution-store', () => {
|
|||
}
|
||||
}
|
||||
|
||||
if (res.data.bank && data.bank.length > 0) {
|
||||
for (let i = 0; i < data.bank?.length; i++) {
|
||||
if (data.bank[i].bankQr) {
|
||||
await api
|
||||
.put(
|
||||
`/institution/${res.data.id}/bank-qr/${res.data.bank[i].id}`,
|
||||
data.bank[i].bankQr,
|
||||
{
|
||||
headers: { 'Content-Type': data.bank[i].bankQr?.type },
|
||||
onUploadProgress: (e) => console.log(e),
|
||||
},
|
||||
)
|
||||
.catch((e) => console.error(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (res.status < 400) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async function editInstitution(data: InstitutionPayload & { id: string }) {
|
||||
async function editInstitution(
|
||||
data: InstitutionPayload & { id: string },
|
||||
opts?: { indexDeleteQrCodeBank?: number[] },
|
||||
) {
|
||||
const res = await api.put(`/institution/${data.id}`, {
|
||||
...data,
|
||||
id: undefined,
|
||||
group: undefined,
|
||||
});
|
||||
|
||||
if (!!res.data.bank && !!data.bank.length) {
|
||||
for (let i = 0; i < data.bank?.length; i++) {
|
||||
if (data.bank[i].bankQr) {
|
||||
console.log(i);
|
||||
console.log(data.bank[i].bankQr);
|
||||
await api
|
||||
.put(
|
||||
`/institution/${res.data.id}/bank-qr/${res.data.bank[i].id}`,
|
||||
data.bank[i].bankQr,
|
||||
{
|
||||
headers: { 'Content-Type': data.bank[i].bankQr?.type },
|
||||
onUploadProgress: (e) => console.log(e),
|
||||
},
|
||||
)
|
||||
.catch((e) => console.error(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (opts.indexDeleteQrCodeBank && opts.indexDeleteQrCodeBank.length > 0) {
|
||||
console.log('delete');
|
||||
opts.indexDeleteQrCodeBank.forEach(async (i) => {
|
||||
await api
|
||||
.delete(`/institution/${res.data.id}/bank-qr/${res.data.bank[i].id}`)
|
||||
.catch((e) => console.error(e));
|
||||
});
|
||||
}
|
||||
|
||||
if (res.status < 400) {
|
||||
return res.data;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue