support transaction pictures

This commit is contained in:
MaysWind
2024-08-31 23:57:28 +08:00
parent ae46cd2332
commit 7fbfa71434
15 changed files with 595 additions and 10 deletions
+35 -1
View File
@@ -451,6 +451,7 @@ export const useTransactionsStore = defineStore('transactions', {
destinationAmount: 0,
hideAmount: false,
tagIds: [],
pictures: [],
comment: '',
geoLocation: null
};
@@ -873,7 +874,7 @@ export const useTransactionsStore = defineStore('transactions', {
}
}
transaction.pictureIds = pictureIds;
submitTransaction.pictureIds = pictureIds;
}
if (isEdit) {
@@ -1027,6 +1028,39 @@ export const useTransactionsStore = defineStore('transactions', {
});
});
},
removeUnusedTransactionPicture({ pictureInfo }) {
return new Promise((resolve, reject) => {
services.removeUnusedTransactionPicture({
id: pictureInfo.pictureId
}).then(response => {
const data = response.data;
if (!data || !data.success || !data.result) {
reject({ message: 'Unable to remove transaction picture' });
return;
}
resolve(data.result);
}).catch(error => {
logger.error('failed to remove 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 remove transaction picture' });
} else {
reject(error);
}
});
});
},
getTransactionPictureUrl(pictureInfo, disableBrowserCache) {
if (!pictureInfo || !pictureInfo.originalUrl) {
return null;
}
return services.getTransactionPictureUrlWithToken(pictureInfo.originalUrl, disableBrowserCache);
},
collapseMonthInTransactionList({ month, collapse }) {
if (month) {
month.opened = !collapse;