From fa1389401a5052edbda5ef5ee9150c4d6490d35f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E8=AF=9A?= Date: Wed, 7 Jan 2026 19:55:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E9=A2=84=E7=AE=97?= =?UTF-8?q?=E7=B1=BB=E5=88=AB=E5=90=8D=E7=A7=B0=E6=9B=B4=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E4=BC=98=E5=8C=96=E7=9B=B8=E5=85=B3=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=99=A8=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Repository/BudgetRepository.cs | 29 +++++++++++++++++++ Web/src/components/Bill/BillForm.vue | 4 +-- Web/src/components/Budget/BudgetEditPopup.vue | 2 +- Web/src/components/PopupContainer.vue | 1 + Web/src/views/PeriodicRecord.vue | 6 ++-- Web/src/views/StatisticsView.vue | 2 +- .../TransactionCategoryController.cs | 4 ++- 7 files changed, 40 insertions(+), 8 deletions(-) diff --git a/Repository/BudgetRepository.cs b/Repository/BudgetRepository.cs index 377ce2a..deeaae9 100644 --- a/Repository/BudgetRepository.cs +++ b/Repository/BudgetRepository.cs @@ -3,6 +3,8 @@ public interface IBudgetRepository : IBaseRepository { Task GetCurrentAmountAsync(BudgetRecord budget, DateTime startDate, DateTime endDate); + + Task UpdateBudgetCategoryNameAsync(string oldName, string newName, TransactionType type); } public class BudgetRepository(IFreeSql freeSql) : BaseRepository(freeSql), IBudgetRepository @@ -33,4 +35,31 @@ public class BudgetRepository(IFreeSql freeSql) : BaseRepository(f return await query.SumAsync(t => t.Amount); } + + public async Task UpdateBudgetCategoryNameAsync(string oldName, string newName, TransactionType type) + { + var records = await FreeSql.Select() + .Where(b => b.SelectedCategories.Contains(oldName) && + ((type == TransactionType.Expense && b.Category == BudgetCategory.Expense) || + (type == TransactionType.Income && b.Category == BudgetCategory.Income) || + (type == TransactionType.None && b.Category == BudgetCategory.Savings))) + .ToListAsync(); + + foreach (var record in records) + { + var categories = record.SelectedCategories.Split(',').ToList(); + for (int i = 0; i < categories.Count; i++) + { + if (categories[i] == oldName) + { + categories[i] = newName; + } + } + record.SelectedCategories = string.Join(',', categories); + } + + await FreeSql.Update() + .SetSource(records) + .ExecuteAffrowsAsync(); + } } diff --git a/Web/src/components/Bill/BillForm.vue b/Web/src/components/Bill/BillForm.vue index b05ee4d..5d4fbd6 100644 --- a/Web/src/components/Bill/BillForm.vue +++ b/Web/src/components/Bill/BillForm.vue @@ -90,7 +90,7 @@ /> - + - + diff --git a/Web/src/components/PopupContainer.vue b/Web/src/components/PopupContainer.vue index d7cc4c4..a9e3e6c 100644 --- a/Web/src/components/PopupContainer.vue +++ b/Web/src/components/PopupContainer.vue @@ -6,6 +6,7 @@ :style="{ height: height }" round :closeable="closeable" + teleport="body" >