1 line
4.2 KiB
JavaScript
1 line
4.2 KiB
JavaScript
|
|
(this["webpackJsonpbeancount-web"]=this["webpackJsonpbeancount-web"]||[]).push([[16],{265:function(t,e,n){},460:function(t,e,n){"use strict";n.r(e);var i=n(11),r=n(12),s=n(14),a=n(13),o=n(347),c=n(348),l=n(452),u=n(115),d=n.n(u),h=n(0),b=n(82),p=n(15),f=n(70),j=(n(265),n(1)),g=function(t){Object(s.a)(n,t);var e=Object(a.a)(n);function n(){var t;Object(i.a)(this,n);for(var r=arguments.length,s=new Array(r),a=0;a<r;a++)s[a]=arguments[a];return(t=e.call.apply(e,[this].concat(s))).theme=t.context.theme,t.ledgerId=window.localStorage.getItem("ledgerId"),t.state={loading:!1,Assets:0,Income:0,Expenses:0,Liabilities:0},t.queryStatsTotalAmount=function(){t.setState({loading:!0}),d()("/api/auth/stats/total",{headers:{ledgerId:t.ledgerId}}).then((function(t){return t.json()})).then((function(e){if(200===e.code){var n=e.data,i=n.Income,r=n.Expenses,s=n.Liabilities,a=n.Assets;t.setState({Assets:a,Income:i,Expenses:r,Liabilities:s})}})).catch(console.error).finally((function(){t.setState({loading:!1})}))},t.navigateTo=function(e){t.props.history.push(e)},t}return Object(r.a)(n,[{key:"componentDidMount",value:function(){this.queryStatsTotalAmount()}},{key:"render",value:function(){var t=this;this.context.theme!==this.theme&&(this.theme=this.context.theme);var e=this.state.loading;return Object(j.jsxs)("div",{className:"stats-page",children:[Object(j.jsx)("div",{style:{textAlign:"center"},children:Object(j.jsx)(o.a,{gutter:16,children:Object(j.jsx)(c.a,{span:8,onClick:function(){t.navigateTo("/stats/assets")},children:Object(j.jsx)(l.a,{style:{cursor:"pointer"},title:"".concat(b.a.Assets,"\u603b\u989d"),value:this.state.Assets||0,loading:e})})})}),Object(j.jsx)("div",{style:{textAlign:"center",marginTop:"1rem"},children:Object(j.jsxs)(o.a,{gutter:16,children:[Object(j.jsx)(c.a,{span:8,children:Object(j.jsx)(l.a,{title:"\u7d2f\u8ba1".concat(b.a.Income),value:-this.state.Income||0,loading:e,prefix:"+",valueStyle:{color:"#cf1322"}})}),Object(j.jsx)(c.a,{span:8,children:Object(j.jsx)(l.a,{title:"\u7d2f\u8ba1".concat(b.a.Expenses),value:this.state.Expenses||0,loading:e,prefix:"-",valueStyle:{color:"#3f8600"}})}),Object(j.jsx)(c.a,{span:8,children:Object(j.jsx)(l.a,{title:"\u7d2f\u8ba1".concat(b.a.Liabilities),value:-this.state.Liabilities||0,loading:e,prefix:"-",valueStyle:{color:"#3f8600"}})})]})})]})}}]),n}(h.Component);g.contextType=p.a,e.default=Object(f.a)(g)},70:function(t,e,n){"use strict";var i=n(94),r=n(11),s=n(12),a=n(14),o=n(13),c=n(0),l=n(1);e.a=function(t){return function(e){Object(a.a)(c,e);var n=Object(o.a)(c);function c(){return Object(r.a)(this,c),n.apply(this,arguments)}return Object(s.a)(c,[{key:"render",value:function(){return Object(l.jsx)(t,Object(i.a)({},this.props))}}]),c}(c.Component)}},82:function(t,e,n){"use strict";n.d(e,"c",(function(){return a})),n.d(e,"e",(function(){return o})),n.d(e,"d",(function(){return c})),n.d(e,"a",(function(){return l})),n.d(e,"b",(function(){return d}));var i=n(456),r=n(115),s=n.n(r),a=function(t){var e=t.split(":");return e&&e.length>=1?t.split(":")[0]:""},o=function(t){var e=t.split(":");return e&&2===e.length?t.split(":")[1]:e&&e.length>=3?t.split(":")[e.length-2]:""},c=function(t){var e=t.split(":");return e&&e.length>=2?t.split(":")[e.length-1]:""},l={Income:"\u6536\u5165",Expenses:"\u652f\u51fa",Liabilities:"\u8d1f\u503a",Assets:"\u8d44\u4ea7"},u=function(t){return t},d=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.method,r=e.headers,a=e.body,o={"Content-Type":"application/json",ledgerId:window.localStorage.getItem("ledgerId")};return new Promise((function(e,c){s()(t,{method:n,headers:Object.assign({},o,r),body:JSON.stringify(a)}).then(u).then((function(t){return t.json()})).then((function(t){var n=t.code;200===n?e(t.data):200!==n&&(400===n?i.b.error("\u8bf7\u6c42\u53c2\u6570\u9519\u8bef"):1001===n?i.b.error("\u8d26\u76ee\u4e0d\u5e73\u8861"):1003===n?i.b.error("\u65e0\u6548\u8d26\u6237"):1005===n?i.b.error("\u65e0\u6548\u547d\u4ee4"):1006===n?i.b.error("\u5bc6\u7801\u9519\u8bef"):1010===n?window.location.href="/#/ledger":i.b.error("\u8bf7\u6c42\
|