transaction list page supports displaying transaction of specific account

This commit is contained in:
MaysWind
2021-01-02 15:48:45 +08:00
parent 7d3e05c548
commit b3eb239478
7 changed files with 104 additions and 33 deletions
+2 -2
View File
@@ -219,8 +219,8 @@ export default {
id
});
},
getTransactions: ({ maxTime }) => {
return axios.get('v1/transactions/list.json?max_time=' + maxTime + '&count=20');
getTransactions: ({ maxTime, type, categoryId, accountId }) => {
return axios.get(`v1/transactions/list.json?max_time=${maxTime}&type=${type}&category_id=${categoryId}&account_id=${accountId}&count=20`);
},
getTransaction: ({ id }) => {
return axios.get('v1/transactions/get.json?id=' + id);
+2 -2
View File
@@ -129,7 +129,7 @@
:key="account.id" :id="account | accountDomId"
:class="{ 'nested-list-item': true, 'has-child-list-item': account.type === $constants.account.allAccountTypes.MultiSubAccounts }"
:after="accountBalance(account) | currency(account.currency)"
:link="account.type === $constants.account.allAccountTypes.SingleAccount ? '#' : null"
:link="account.type === $constants.account.allAccountTypes.SingleAccount ? '/transaction/list?accountId=' + account.id : null"
swipeout @taphold.native="setSortable()"
>
<f7-block slot="title" class="no-padding">
@@ -147,7 +147,7 @@
<f7-list-item class="no-sortable nested-list-item-child" v-for="subAccount in account.subAccounts" v-show="showHidden || !subAccount.hidden"
:key="subAccount.id" :id="subAccount | accountDomId"
:title="subAccount.name" :after="accountBalance(subAccount) | currency(subAccount.currency)"
link="#"
:link="'/transaction/list?accountId=' + subAccount.id"
>
<f7-icon slot="media" :icon="subAccount.icon | accountIcon"
:style="subAccount.color | accountIconStyle('var(--default-icon-color)')">
+42 -4
View File
@@ -130,7 +130,7 @@
<f7-list-item class="transaction-info" chevron-center
v-for="(transaction, idx) in transactionMonthList.items"
:key="transaction.id" :id="transaction | transactionDomId"
:link="'/transaction/detail?id=' + transaction.id"
:link="transaction.type !== $constants.transaction.allTransactionTypes.ModifyBalance ? '/transaction/detail?id=' + transaction.id : null"
swipeout
>
<div slot="media" class="display-flex no-padding-horizontal">
@@ -147,6 +147,9 @@
:icon="transaction.category.icon | categoryIcon"
:style="transaction.category.color | categoryIconStyle('var(--category-icon-color)')">
</f7-icon>
<f7-icon v-else-if="!transaction.category || !transaction.category.color"
f7="pencil_ellipsis_rectangle">
</f7-icon>
</div>
</div>
<div slot="title" class="no-padding">
@@ -176,7 +179,10 @@
</span>
</div>
<f7-swipeout-actions right>
<f7-swipeout-button color="orange" close :text="$t('Edit')" @click="edit(transaction)"></f7-swipeout-button>
<f7-swipeout-button color="orange" close
:text="$t('Edit')"
v-if="transaction.type !== $constants.transaction.allTransactionTypes.ModifyBalance"
@click="edit(transaction)"></f7-swipeout-button>
<f7-swipeout-button color="red" class="padding-left padding-right" @click="remove(transaction, false)">
<f7-icon f7="trash"></f7-icon>
</f7-swipeout-button>
@@ -215,6 +221,11 @@ export default {
data() {
return {
transactions: [],
query: {
type: 0,
categoryId: 0,
accountId: 0
},
allAccounts: {},
allCategories: {},
allTags: {},
@@ -245,6 +256,21 @@ export default {
}
},
created() {
const self = this;
const query = self.$f7route.query;
if (query.type) {
self.query.type = query.type;
}
if (query.categoryId) {
self.query.categoryId = query.categoryId;
}
if (query.accountId) {
self.query.accountId = query.accountId;
}
this.reload(null);
},
methods: {
@@ -263,7 +289,10 @@ export default {
self.$services.getAllTransactionCategories({}),
self.$services.getAllTransactionTags(),
self.$services.getTransactions({
maxTime: self.maxTime
maxTime: self.maxTime,
type: self.query.type,
categoryId: self.query.categoryId,
accountId: self.query.accountId
})
];
@@ -384,7 +413,10 @@ export default {
self.loadingMore = true;
self.$services.getTransactions({
maxTime: self.maxTime
maxTime: self.maxTime,
type: self.query.type,
categoryId: self.query.categoryId,
accountId: self.query.accountId
}).then(response => {
self.loadingMore = false;
@@ -595,6 +627,12 @@ export default {
totalExpense += amount;
} else if (transaction.type === this.$constants.transaction.allTransactionTypes.Income) {
totalIncome += amount;
} else if (transaction.type === this.$constants.transaction.allTransactionTypes.Transfer && this.query.accountId) {
if (this.query.accountId === transaction.sourceAccountId) {
totalExpense += amount;
} else if (this.query.accountId === transaction.destinationAccountId) {
totalIncome += amount;
}
}
}