add transaction pictures api

This commit is contained in:
MaysWind
2024-08-31 01:09:55 +08:00
parent 636ac974b8
commit 772a22a182
12 changed files with 466 additions and 71 deletions
+36
View File
@@ -864,6 +864,18 @@ export const useTransactionsStore = defineStore('transactions', {
return Promise.reject('An error occurred');
}
if (transaction.pictures && transaction.pictures.length > 0) {
const pictureIds = [];
for (let i = 0; i < transaction.pictures.length; i++) {
if (transaction.pictures[i].pictureId) {
pictureIds.push(transaction.pictures[i].pictureId);
}
}
transaction.pictureIds = pictureIds;
}
if (isEdit) {
submitTransaction.id = transaction.id;
}
@@ -991,6 +1003,30 @@ export const useTransactionsStore = defineStore('transactions', {
});
});
},
uploadTransactionPicture({ pictureFile, clientSessionId }) {
return new Promise((resolve, reject) => {
services.uploadTransactionPicture({ pictureFile, clientSessionId }).then(response => {
const data = response.data;
if (!data || !data.success || !data.result) {
reject({ message: 'Unable to upload transaction picture' });
return;
}
resolve(data.result);
}).catch(error => {
logger.error('Unable to upload transaction picture', error);
if (error.response && error.response.data && error.response.data.errorMessage) {
reject({ error: error.response.data });
} else if (!error.processed) {
reject({ message: 'Unable to upload transaction picture' });
} else {
reject(error);
}
});
});
},
collapseMonthInTransactionList({ month, collapse }) {
if (month) {
month.opened = !collapse;