code refactor

This commit is contained in:
MaysWind
2021-03-28 20:22:03 +08:00
parent f9066cb81d
commit b7ffe191f2
10 changed files with 205 additions and 228 deletions
+21 -21
View File
@@ -171,27 +171,6 @@ export default {
password
});
},
getTransactionOverview: ({ today, thisWeek, thisMonth, thisYear }) => {
const queryParams = [];
if (today) {
queryParams.push(`today_${today.startTime}_${today.endTime}`);
}
if (thisWeek) {
queryParams.push(`thisWeek_${thisWeek.startTime}_${thisWeek.endTime}`);
}
if (thisMonth) {
queryParams.push(`thisMonth_${thisMonth.startTime}_${thisMonth.endTime}`);
}
if (thisYear) {
queryParams.push(`thisYear_${thisYear.startTime}_${thisYear.endTime}`);
}
return axios.get('v1/overviews/transaction.json' + (queryParams.length ? '?query=' + queryParams.join('|') : ''));
},
getAllAccounts: ({ visibleOnly }) => {
return axios.get('v1/accounts/list.json?visible_only=' + !!visibleOnly);
},
@@ -255,6 +234,27 @@ export default {
return axios.get('v1/transactions/statistics.json' + (queryParams.length ? '?' + queryParams.join('&') : ''));
},
getTransactionAmounts: ({ today, thisWeek, thisMonth, thisYear }) => {
const queryParams = [];
if (today) {
queryParams.push(`today_${today.startTime}_${today.endTime}`);
}
if (thisWeek) {
queryParams.push(`thisWeek_${thisWeek.startTime}_${thisWeek.endTime}`);
}
if (thisMonth) {
queryParams.push(`thisMonth_${thisMonth.startTime}_${thisMonth.endTime}`);
}
if (thisYear) {
queryParams.push(`thisYear_${thisYear.startTime}_${thisYear.endTime}`);
}
return axios.get('v1/transactions/amounts.json' + (queryParams.length ? '?query=' + queryParams.join('|') : ''));
},
getTransaction: ({ id }) => {
return axios.get(`v1/transactions/get.json?id=${id}&trim_account=true&trim_category=true&trim_tag=true`);
},
+1 -1
View File
@@ -17,7 +17,7 @@ export function loadTransactionOverview(context, { defaultCurrency, dateRange, f
}
return new Promise((resolve, reject) => {
services.getTransactionOverview({
services.getTransactionAmounts({
today: dateRange.today,
thisWeek: dateRange.thisWeek,
thisMonth: dateRange.thisMonth,