From 683188f67a2ffda99c70347e13798e1ebce5d8a1 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Mon, 24 Jul 2023 23:25:33 +0800 Subject: [PATCH] code refactor --- src/views/desktop/TransactionsPage.vue | 60 ++++++++------------------ 1 file changed, 19 insertions(+), 41 deletions(-) diff --git a/src/views/desktop/TransactionsPage.vue b/src/views/desktop/TransactionsPage.vue index 456ed385..d87ef5b8 100644 --- a/src/views/desktop/TransactionsPage.vue +++ b/src/views/desktop/TransactionsPage.vue @@ -49,7 +49,7 @@
{{ $t('Transaction List') }} {{ $t('Add') }} + :disabled="loading || !canAddTransaction" @click="add">{{ $t('Add') }} @@ -76,25 +76,23 @@ {{ $t('Date Range') }} {{ $t('All') }} - {{ queryMinTime }} -  -  - {{ queryMaxTime }} + {{ `${queryMinTime} - ${queryMaxTime}` }} -
+
{{ $t('Total Income') }} - {{ monthlyDataTotalIncome }} + {{ monthlyDataTotalAmount.income }} - {{ $t('Total Expense') }} + {{ $t('Total Expense') }} - {{ monthlyDataTotalExpense }} + {{ monthlyDataTotalAmount.expense }}
@@ -304,10 +302,8 @@ {{ transaction.destinationAccount.name }} - -
- {{ transaction.comment }} -
+ + {{ transaction.comment }} @@ -525,45 +521,28 @@ export default { return Number.MAX_SAFE_INTEGER; } }, - monthlyDataTotalIncome() { + monthlyDataTotalAmount() { const recentDateRange = this.recentMonthDateRanges[this.recentDateRangeType]; if (!recentDateRange || !recentDateRange.year || !recentDateRange.month) { - return '-'; + return null; } if (!this.transactions || !this.transactions.length) { - return '-'; + return null; } for (let i = 0; i < this.transactions.length; i++) { if (this.transactions[i].year === recentDateRange.year && this.transactions[i].month === recentDateRange.month) { - return this.getDisplayMonthTotalAmount(this.transactions[i].totalAmount.income, this.defaultCurrency, '', this.transactions[i].totalAmount.incompleteIncome) + return { + income: this.getDisplayMonthTotalAmount(this.transactions[i].totalAmount.income, this.defaultCurrency, '', this.transactions[i].totalAmount.incompleteIncome), + expense: this.getDisplayMonthTotalAmount(this.transactions[i].totalAmount.expense, this.defaultCurrency, '', this.transactions[i].totalAmount.incompleteExpense) + }; } } - return '-'; - }, - monthlyDataTotalExpense() { - const recentDateRange = this.recentMonthDateRanges[this.recentDateRangeType]; - - if (!recentDateRange || !recentDateRange.year || !recentDateRange.month) { - return '-'; - } - - if (!this.transactions || !this.transactions.length) { - return '-'; - } - - for (let i = 0; i < this.transactions.length; i++) { - if (this.transactions[i].year === recentDateRange.year && - this.transactions[i].month === recentDateRange.month) { - return this.getDisplayMonthTotalAmount(this.transactions[i].totalAmount.expense, this.defaultCurrency, '', this.transactions[i].totalAmount.incompleteExpense) - } - } - - return '-'; + return null; }, allTransactionTypes() { return transactionConstants.allTransactionTypes; @@ -922,6 +901,7 @@ export default { } .transaction-list-datetime-range { + height: 28px; overflow-x: auto; white-space: nowrap; } @@ -966,10 +946,8 @@ export default { white-space: nowrap; } -.transaction-table .transaction-table-column-description { - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; +.transaction-table-column-description { + max-width: 300px; } .transaction-table .transaction-table-column-category .v-btn,