From 5ec0781a5303b7b50d39d54433f4448c29c7a8fd Mon Sep 17 00:00:00 2001 From: Cxx0822 <1556464090@qq.com> Date: Tue, 11 Nov 2025 09:35:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=9B=B4=E6=96=B0=E8=B4=A6=E5=8D=95?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Bill/BillQuery.vue | 14 +++++---- src/components/Bill/BillSearch.vue | 38 +++++++++++++++++++++++++ src/store/bill.ts | 16 +++++++---- src/styles/home/bill.mobile.module.scss | 7 +++++ src/utils/home/billUtil.ts | 6 ++++ src/views/bill/chart.vue | 2 +- src/views/bill/data.vue | 1 + src/views/bill/detail[id].vue | 1 - src/views/bill/search.vue | 29 +++++-------------- src/views/home/index.vue | 25 +++++----------- 10 files changed, 86 insertions(+), 53 deletions(-) create mode 100644 src/components/Bill/BillSearch.vue diff --git a/src/components/Bill/BillQuery.vue b/src/components/Bill/BillQuery.vue index d080363..e0235e2 100644 --- a/src/components/Bill/BillQuery.vue +++ b/src/components/Bill/BillQuery.vue @@ -1,7 +1,7 @@ + + diff --git a/src/store/bill.ts b/src/store/bill.ts index 0f77afa..5dfb54d 100644 --- a/src/store/bill.ts +++ b/src/store/bill.ts @@ -130,15 +130,21 @@ export const useBillStore = defineStore('bill', { await this.refreshInfo() } }, - async refreshInfo() { - this.isLoading = true - const bookName = this.billQueryForm.billBook === 'all' ? '' : this.billQueryForm.billBook + getBillDateList() { const { billYear, billMonth } = this.billQueryForm const date = this.billDateType === 'year' ? billYear : billMonth this.billDateList = getStartEndDate(date, this.billDateType) + }, + async refreshInfo(isStats = false) { + this.isLoading = true + const bookName = this.billQueryForm.billBook === 'all' ? '' : this.billQueryForm.billBook + this.getBillDateList() - await this.queryBillSummary(bookName) - await this.queryBillStats(bookName) + if (isStats) { + await this.queryBillStats(bookName) + } else { + await this.queryBillSummary(bookName) + } this.isRefresh = !this.isRefresh this.isLoading = false }, diff --git a/src/styles/home/bill.mobile.module.scss b/src/styles/home/bill.mobile.module.scss index dcf4fef..59a507e 100644 --- a/src/styles/home/bill.mobile.module.scss +++ b/src/styles/home/bill.mobile.module.scss @@ -32,5 +32,12 @@ display: flex; flex-direction: column; gap: 10px; + + .search-result-title { + align-self: flex-end; + + display: flex; + gap: 10px; + } } } diff --git a/src/utils/home/billUtil.ts b/src/utils/home/billUtil.ts index 9520d8e..6938802 100644 --- a/src/utils/home/billUtil.ts +++ b/src/utils/home/billUtil.ts @@ -113,3 +113,9 @@ export const getRateColor = (rate: number) => { return '#CD4F39' } } + +export const getTotalAmount = (billRecordList: IBillRecord[], type: IBillType) => { + return billRecordList + .filter((record) => record.type === type) + .reduce((total, record) => total + record.amount, 0) +} diff --git a/src/views/bill/chart.vue b/src/views/bill/chart.vue index 20fe6b7..f97a7f4 100644 --- a/src/views/bill/chart.vue +++ b/src/views/bill/chart.vue @@ -27,7 +27,7 @@ import { useBillStore } from '@/store/bill.ts' const billStore = useBillStore() onMounted(async () => { - await billStore.refreshInfo() + await billStore.refreshInfo(true) }) diff --git a/src/views/bill/data.vue b/src/views/bill/data.vue index d81bcd5..c5c360f 100644 --- a/src/views/bill/data.vue +++ b/src/views/bill/data.vue @@ -37,6 +37,7 @@ onMounted(async () => { billStore.billType = 'expensive' billStore.billDateType = 'month' + await billStore.refreshInfo() }) diff --git a/src/views/bill/detail[id].vue b/src/views/bill/detail[id].vue index 90335cc..3300511 100644 --- a/src/views/bill/detail[id].vue +++ b/src/views/bill/detail[id].vue @@ -129,7 +129,6 @@ const billInfo = reactive({ onMounted(async () => { appStore.isShowMobileBack = true - await billStore.initBillInfo() await initBillRecord() }) diff --git a/src/views/bill/search.vue b/src/views/bill/search.vue index 4a1fa6e..4fc8b7a 100644 --- a/src/views/bill/search.vue +++ b/src/views/bill/search.vue @@ -1,32 +1,16 @@