diff --git a/Service/BudgetService.cs b/Service/BudgetService.cs index c3ec652..6dc5141 100644 --- a/Service/BudgetService.cs +++ b/Service/BudgetService.cs @@ -693,6 +693,7 @@ public class BudgetService( var totalExpense = expenseLimitAtPeriod + noLimitExpenseAtPeriod; description.Append($"

计划收入 = 预算 {incomeLimitAtPeriod:N0} + 不记额 {noLimitIncomeAtPeriod:N0} = {totalIncome:N0}

"); description.Append($"

计划支出 = 预算 {expenseLimitAtPeriod:N0} + 不记额 {noLimitExpenseAtPeriod:N0} = {totalExpense:N0}

"); + description.Append($"

计划盈余 = 计划收入 {totalIncome:N0} - 计划支出 {totalExpense:N0} = {totalIncome - totalExpense:N0}

"); decimal historicalSurplus = 0; if (periodType == BudgetPeriodType.Year) @@ -744,11 +745,12 @@ public class BudgetService( """); } var finalGoal = totalIncome - totalExpense + historicalSurplus; - description.Append($"

动态目标 = 计划盈余 {totalIncome - totalExpense:N0} + 历史盈亏 {historicalSurplus:N0} = {finalGoal:N0}

"); - } - else - { - description.Append($"

最终目标:{totalIncome - totalExpense:N0}

"); + description.Append($""" +

+ 动态目标 = 计划盈余 {totalIncome - totalExpense:N0} + + 年度历史盈亏 {historicalSurplus:N0} + = {finalGoal:N0}

+ """); } var finalLimit = periodType == BudgetPeriodType.Year ? (totalIncome - totalExpense + historicalSurplus) : (totalIncome - totalExpense); diff --git a/Web/src/views/BudgetView.vue b/Web/src/views/BudgetView.vue index 3fefa76..ddcd567 100644 --- a/Web/src/views/BudgetView.vue +++ b/Web/src/views/BudgetView.vue @@ -180,7 +180,6 @@ type="primary" @click.stop="handleSavingsNav(budget, -1)" > - {{ budget.type === BudgetPeriodType.Year ? '上一年' : '上一月' }} {{ getSavingsDateLabel(budget) }} @@ -191,9 +190,9 @@ plain type="primary" icon-position="right" + :disabled="disabledSavingsNextNav(budget)" @click.stop="handleSavingsNav(budget, 1)" > - {{ budget.type === BudgetPeriodType.Year ? '下一年' : '下一月' }} @@ -613,6 +612,17 @@ const handleSavingsNav = async (budget, offset) => { showToast('切换日期失败') } } + +const disabledSavingsNextNav = (budget) => { + if (!budget.periodStart) return true + const date = new Date(budget.periodStart) + const now = new Date() + if (budget.type === BudgetPeriodType.Year) { + return date.getFullYear() === now.getFullYear() + } else { + return date.getFullYear() === now.getFullYear() && date.getMonth() === now.getMonth() + } +}