第一次上传

This commit is contained in:
xxk
2026-06-11 09:53:11 +08:00
commit e257f2009e
89 changed files with 4336 additions and 0 deletions
@@ -0,0 +1 @@
"use strict";const e=require("../../common/vendor.js"),t=require("../../utils/store.js"),a=require("../../utils/date.js"),u=require("../../utils/money.js");Math||(r+n)();const r=()=>"../../components/SectionCard.js",n=()=>"../../components/AppTabBar.js",o={__name:"index",setup(r){const n=t.useAppStore(),o=e.computed((()=>a.toMonthKey())),s=e.computed((()=>"dark"===n.state.settings.theme?"theme-dark":"")),l=e.ref(String(n.state.budgets.total||"")),d=e.reactive({}),c=e.computed((()=>n.state.bills.filter((e=>"expense"===e.type&&a.isSameMonth(e.date,o.value))))),i=e.computed((()=>c.value.reduce(((e,t)=>e+Number(t.amount)),0))),m=e.computed((()=>Number(n.state.budgets.total)||0)),p=e.computed((()=>m.value-i.value)),v=e.computed((()=>Math.max(p.value,0)/Math.max(1,a.getDaysLeftInMonth(o.value)))),g=e.computed((()=>m.value?u.formatPercent(i.value/Math.max(m.value,1)):"未设置")),f=e.computed((()=>u.clampPercent(i.value/Math.max(m.value||1,1)))),b=e.computed((()=>n.state.categories.expense.map((e=>{const t=c.value.filter((t=>t.categoryId===e.id)).reduce(((e,t)=>e+Number(t.amount)),0),a=Number(n.state.budgets.categoryBudgets[e.id]||0);return{...e,spent:t,budget:a,progressLabel:a?u.formatPercent(t/Math.max(a,1)):"未设置",progressWidth:u.clampPercent(t/Math.max(a||1,1))}})))),h=e.computed((()=>b.value.filter((e=>e.budget>0&&e.spent>e.budget))));function y(){n.setBudgetTotal(l.value),e.index.showToast({title:"总预算已保存",icon:"none"})}return e.watch((()=>n.state.budgets.total),(e=>{l.value=String(e||"")}),{immediate:!0}),e.watch(b,(e=>{e.forEach((e=>{d[e.id]=String(e.budget||"")}))}),{immediate:!0}),(t,a)=>e.e({a:e.t(e.unref(u.formatCurrency)(m.value)),b:e.t(e.unref(u.formatCurrency)(i.value)),c:f.value,d:e.t(g.value),e:e.t(p.value>=0?`剩余 ${e.unref(u.formatCurrency)(p.value)}`:`已超支 ${e.unref(u.formatCurrency)(Math.abs(p.value))}`),f:e.t(m.value?`日均可用 ${e.unref(u.formatCurrency)(v.value)}`:"设置预算后可查看剩余额度分配"),g:l.value,h:e.o((e=>l.value=e.detail.value)),i:e.o(y),j:e.p({title:"月度预算",subtitle:"设置总预算与分类预算,控制消费节奏"}),k:h.value.length},h.value.length?{l:e.f(h.value,((t,a,r)=>({a:e.t(t.name),b:e.t(e.unref(u.formatCurrency)(t.budget)),c:e.t(e.unref(u.formatCurrency)(t.spent)),d:t.id}))),m:e.p({title:"超支提醒",subtitle:"当前分类预算已被突破,建议尽快调整"})}:{},{n:e.f(b.value,((t,a,r)=>({a:t.color,b:e.t(t.name),c:e.t(e.unref(u.formatCurrency)(t.spent)),d:t.progressWidth,e:e.t(e.unref(u.formatCurrency)(t.budget)),f:e.t(t.progressLabel),g:e.n(t.budget>0&&t.spent>t.budget?"negative":""),h:d[t.id],i:e.o((e=>d[t.id]=e.detail.value),t.id),j:e.o((a=>{return u=t.id,n.setCategoryBudget(u,d[u]),void e.index.showToast({title:"分类预算已保存",icon:"none"});var u}),t.id),k:t.id}))),o:e.p({title:"分类预算",subtitle:"为高频分类分别设置预算,减少超支风险"}),p:e.p({current:"budget"}),q:e.n(s.value)})}},s=e._export_sfc(o,[["__scopeId","data-v-a56ca0c4"]]);wx.createPage(s);