From 640f74c6128c43eee1248cb082765b6ee35cba48 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sat, 29 Jun 2024 10:43:20 +0800 Subject: [PATCH] add keyword parameters to the URL when searching for transaction descriptions in the desktop transaction list --- src/router/desktop.js | 3 ++- src/stores/transaction.js | 4 ++++ src/views/desktop/transactions/ListPage.vue | 17 ++++++++++++----- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/router/desktop.js b/src/router/desktop.js index 2e193f95..b4ab7008 100644 --- a/src/router/desktop.js +++ b/src/router/desktop.js @@ -99,7 +99,8 @@ const router = createRouter({ initMinTime: route.query.minTime, initType: route.query.type, initCategoryId: route.query.categoryId, - initAccountId: route.query.accountId + initAccountId: route.query.accountId, + initKeyword: route.query.keyword }) }, { diff --git a/src/stores/transaction.js b/src/stores/transaction.js index 5b55a787..3a7d32c0 100644 --- a/src/stores/transaction.js +++ b/src/stores/transaction.js @@ -473,6 +473,10 @@ export const useTransactionsStore = defineStore('transactions', { querys.push('minTime=' + this.transactionsFilter.minTime); } + if (this.transactionsFilter.keyword) { + querys.push('keyword=' + encodeURIComponent(this.transactionsFilter.keyword)); + } + return querys.join('&'); }, loadTransactions({ reload, count, page, withCount, autoExpand, defaultCurrency }) { diff --git a/src/views/desktop/transactions/ListPage.vue b/src/views/desktop/transactions/ListPage.vue index 75bd8fb1..fef48ec3 100644 --- a/src/views/desktop/transactions/ListPage.vue +++ b/src/views/desktop/transactions/ListPage.vue @@ -405,7 +405,8 @@ export default { 'initMinTime', 'initType', 'initCategoryId', - 'initAccountId' + 'initAccountId', + 'initKeyword' ], data() { const { mdAndUp } = useDisplay(); @@ -636,7 +637,8 @@ export default { maxTime: this.initMaxTime, type: this.initType, categoryId: this.initCategoryId, - accountId: this.initAccountId + accountId: this.initAccountId, + keyword: this.initKeyword }); }, setup() { @@ -663,7 +665,8 @@ export default { maxTime: to.query.maxTime, type: to.query.type, categoryId: to.query.categoryId, - accountId: to.query.accountId + accountId: to.query.accountId, + keyword: to.query.keyword }); } }, @@ -688,9 +691,11 @@ export default { type: parseInt(query.type) > 0 ? parseInt(query.type) : undefined, categoryId: query.categoryId, accountId: query.accountId, - keyword: this.searchKeyword + keyword: query.keyword || '' }); + this.searchKeyword = query.keyword || ''; + this.currentPage = 1; this.reload(false); }, @@ -874,7 +879,9 @@ export default { }); this.currentPage = 1; - this.reload(false); + this.currentPageTransactions = []; + this.transactionsStore.clearTransactions(); + this.$router.push(this.getFilterLinkUrl()); }, add() { const self = this;