mirror of
https://github.com/KarolChang/jm-expense-vue-ts.git
synced 2024-12-25 11:18:36 +00:00
2 lines
3.0 KiB
JavaScript
2 lines
3.0 KiB
JavaScript
var A=Object.defineProperty;var x=(u,a,s)=>a in u?A(u,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):u[a]=s;var v=(u,a,s)=>(x(u,typeof a!="symbol"?a+"":a,s),s);import{r as B}from"./record.727acb18.js";import{_ as C,l as k}from"./CreateRecordModalButton.aa1ff3c2.js";import{C as M}from"./index.6b72a0c0.js";import{S as E}from"./Spinner.9807c4e4.js";import{e as S,x as h,o as F,g as N,h as t,j as P,t as r,O as w,p as V,l as D}from"./vendor.961f4417.js";const Y={key:0},$={class:"d-flex mb-3",style:{width:"100vw"}},I={class:"list-group list-group-checkable"},U={class:"list-group-item py-3 mb-3"},j={class:"row"},z={class:"col-7 text-start"},H=D(" \u672C\u6708\u7E3D\u984D \uFF04"),L={class:"progress mt-2",style:{height:"20px"}},O=["aria-valuenow"],R={class:"col-5 text-start"},T={class:"list-group-item py-3 mb-3"},q={class:"row"},G={class:"col-7 text-start"},J=D(" \u4E0A\u6708\u7E3D\u984D \uFF04"),K={class:"progress mt-2",style:{height:"20px"}},Q=["aria-valuenow"],W={class:"col-5 text-start"},ot=S({setup(u){class a{constructor(){v(this,"total");v(this,"closedAmount");v(this,"rate")}}const s=h(!0),p=h([]),o=h(new a),l=h(new a),y=async function(){try{const{data:e}=await B.getAll();p.value=e.data;const n=new Date().getFullYear(),c=new Date().getMonth()+1;o.value=f(n,c),l.value=f(c-1===0?n-1:n,c-1===0?12:c-1),s.value=!1}catch(e){console.error("error",e)}},f=(e,n)=>{var g;const c=(g=p.value)==null?void 0:g.filter(i=>new Date(i.date).getFullYear()===e&&new Date(i.date).getMonth()+1===n);let d=0,_=0;for(let i of c)d+=i.amount,i.isClosed===!0&&(_+=i.amount);let m;return d===0?m=0:m=Math.round(_/d)*100,{total:d,closedAmount:_,rate:m}};y();const b=async()=>{try{const e={to:["Ub3557f7c812e4e78293959fe4fccd414","Ue5746fb7f35d2322a698d62dc9c9a21d"],messages:{type:"text",text:"\u5361\u6BD4\u89BA\u5F97\u4FC3\u54AA\uFF01"}};await k.push(e),M("Speak","\u6309\u6211\u4E86 \u4F60\u662F\u7B28\u86CB")}catch(e){console.error("error",e)}};return(e,n)=>s.value?(F(),V(E,{key:1})):(F(),N("div",Y,[t("div",$,[P(C,{view:"Home",class:"me-3"}),t("button",{type:"button",class:"btn btn-danger me-3",onClick:b},"\u7B28\u86CB\u624D\u6309\u6211")]),t("div",I,[t("label",U,[t("div",j,[t("div",z,[t("h5",null,[H,t("strong",null,r(o.value.total),1)]),t("div",L,[t("div",{class:"progress-bar",role:"progressbar",style:w(`width: ${o.value.rate}%`),"aria-valuenow":o.value.rate,"aria-valuemin":"0","aria-valuemax":"100"},r(o.value.rate)+"% ",13,O)])]),t("div",R,[t("div",null,"\u672A\u7D50\u7B97\uFF04 "+r(o.value.total-o.value.closedAmount),1),t("div",null,"\u5DF2\u7D50\u7B97\uFF04 "+r(o.value.closedAmount),1)])])]),t("label",T,[t("div",q,[t("div",G,[t("h5",null,[J,t("strong",null,r(l.value.total),1)]),t("div",K,[t("div",{class:"progress-bar",role:"progressbar",style:w(`width: ${l.value.rate}%`),"aria-valuenow":l.value.rate,"aria-valuemin":"0","aria-valuemax":"100"},r(l.value.rate)+"% ",13,Q)])]),t("div",W,[t("div",null,"\u672A\u7D50\u7B97\uFF04 "+r(l.value.total-l.value.closedAmount),1),t("div",null,"\u5DF2\u7D50\u7B97\uFF04 "+r(l.value.closedAmount),1)])])])])]))}});export{ot as default};
|