1 line
9.2 KiB
JavaScript
1 line
9.2 KiB
JavaScript
(this["webpackJsonpbeancount-web"]=this["webpackJsonpbeancount-web"]||[]).push([[14],{277:function(e,t,n){"use strict";var a=n(42),r=n(0),c={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"}}]},name:"down",theme:"outlined"},i=n(47),o=function(e,t){return r.createElement(i.a,Object(a.a)(Object(a.a)({},e),{},{ref:t,icon:c}))};o.displayName="DownOutlined";t.a=r.forwardRef(o)},464:function(e,t,n){"use strict";var a=n(3),r=n(41),c=n(0),i=n(43),o=n(45),l=n(40),s=n.n(l),d=n(65),u=n(63),h=c.forwardRef((function(e,t){var n,a=e.prefixCls,l=void 0===a?"rc-switch":a,h=e.className,b=e.checked,f=e.defaultChecked,m=e.disabled,j=e.loadingIcon,p=e.checkedChildren,g=e.unCheckedChildren,O=e.onClick,y=e.onChange,v=e.onKeyDown,x=Object(o.a)(e,["prefixCls","className","checked","defaultChecked","disabled","loadingIcon","checkedChildren","unCheckedChildren","onClick","onChange","onKeyDown"]),w=Object(d.a)(!1,{value:b,defaultValue:f}),C=Object(i.a)(w,2),k=C[0],S=C[1];function I(e,t){var n=k;return m||(S(n=e),null===y||void 0===y||y(n,t)),n}var N=s()(l,h,(n={},Object(r.a)(n,"".concat(l,"-checked"),k),Object(r.a)(n,"".concat(l,"-disabled"),m),n));return c.createElement("button",Object.assign({},x,{type:"button",role:"switch","aria-checked":k,disabled:m,className:N,ref:t,onKeyDown:function(e){e.which===u.a.LEFT?I(!1,e):e.which===u.a.RIGHT&&I(!0,e),null===v||void 0===v||v(e)},onClick:function(e){var t=I(!k,e);null===O||void 0===O||O(t,e)}}),j,c.createElement("span",{className:"".concat(l,"-inner")},k?p:g))}));h.displayName="Switch";var b=h,f=n(111),m=n(137),j=n(138),p=n(74),g=n(64),O=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"===typeof Object.getOwnPropertySymbols){var r=0;for(a=Object.getOwnPropertySymbols(e);r<a.length;r++)t.indexOf(a[r])<0&&Object.prototype.propertyIsEnumerable.call(e,a[r])&&(n[a[r]]=e[a[r]])}return n},y=c.forwardRef((function(e,t){var n,i=e.prefixCls,o=e.size,l=e.loading,d=e.className,u=void 0===d?"":d,h=e.disabled,y=O(e,["prefixCls","size","loading","className","disabled"]);Object(g.a)("checked"in y||!("value"in y),"Switch","`value` is not a valid prop, do you mean `checked`?");var v=c.useContext(j.b),x=v.getPrefixCls,w=v.direction,C=c.useContext(p.b),k=x("switch",i),S=c.createElement("div",{className:"".concat(k,"-handle")},l&&c.createElement(f.a,{className:"".concat(k,"-loading-icon")})),I=s()((n={},Object(r.a)(n,"".concat(k,"-small"),"small"===(o||C)),Object(r.a)(n,"".concat(k,"-loading"),l),Object(r.a)(n,"".concat(k,"-rtl"),"rtl"===w),n),u);return c.createElement(m.a,{insertExtraNode:!0},c.createElement(b,Object(a.a)({},y,{prefixCls:k,className:I,disabled:h||l,ref:t,loadingIcon:S})))}));y.__ANT_SWITCH=!0,y.displayName="Switch";t.a=y},479:function(e,t,n){"use strict";n.r(t);var a=n(12),r=n(13),c=n(15),i=n(14),o=n(475),l=n(476),s=n(464),d=n(271),u=n(42),h=n(0),b=n.n(h),f={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M890.5 755.3L537.9 269.2c-12.8-17.6-39-17.6-51.7 0L133.5 755.3A8 8 0 00140 768h75c5.1 0 9.9-2.5 12.9-6.6L512 369.8l284.1 391.6c3 4.1 7.8 6.6 12.9 6.6h75c6.5 0 10.3-7.4 6.5-12.7z"}}]},name:"up",theme:"outlined"},m=n(47),j=function(e,t){return h.createElement(m.a,Object(u.a)(Object(u.a)({},e),{},{ref:t,icon:f}))};j.displayName="UpOutlined";var p=h.forwardRef(j),g=n(277),O=n(16),y=n(70),v=n(59),x=(n(11),n(1)),w={required:"${label} \u4e0d\u80fd\u4e3a\u7a7a\uff01"},C=function(e){Object(c.a)(n,e);var t=Object(i.a)(n);function n(){var e;Object(a.a)(this,n);for(var r=arguments.length,c=new Array(r),i=0;i<r;i++)c[i]=arguments[i];return(e=t.call.apply(t,[this].concat(c))).theme=e.context.theme,e.formRef=b.a.createRef(),e.state={loading:!1,expand:!1,config:{}},e.handleQueryServerConfig=function(){e.setState({loading:!0}),Object(v.b)("/api/config",{method:"GET"}).then((function(t){t.dataPath?e.setState({config:t}):window.location.href="/web/#/init"})).finally((function(){e.setState({loading:!1})}))},e.handleCreateLedger=function(t){e.setState({loading:!0}),Object(v.b)("/api/ledger",{method:"POST",headers:{"Content-Type":"application/json"},body:t}).then((function(t){window.localStorage.setItem("ledgerId",t.ledgerId),t.title&&window.localStorage.setItem("ledgerTitle",t.title),t.currency&&window.localStorage.setItem("ledgerCurrency",JSON.stringify({currency:t.currency,symbol:t.currencySymbol})),e.props.history.replace("/")})).finally((function(){e.setState({loading:!1})}))},e}return Object(r.a)(n,[{key:"componentDidMount",value:function(){this.handleQueryServerConfig()}},{key:"render",value:function(){var e=this;return this.context.theme!==this.theme&&(this.theme=this.context.theme),Object(x.jsx)("div",{className:"ledger-page",children:Object(x.jsx)("div",{children:Object(x.jsxs)(o.a,{name:"add-account-form",size:"middle",layout:"vertical",ref:this.formRef,onFinish:this.handleCreateLedger,validateMessages:w,loading:this.state.loading,children:[Object(x.jsx)(o.a.Item,{name:"ledgerName",label:"\u8d26\u672c\u540d\u79f0",rules:[{required:!0}],children:Object(x.jsx)(l.a,{placeholder:"\u4f60\u53ef\u4ee5\u521b\u5efa\u591a\u4e2a\u7684\u8d26\u672c\uff0c\u8d26\u672c\u4e4b\u95f4\u7684\u6570\u636e\u65e0\u6cd5\u4e92\u901a"})}),Object(x.jsx)(o.a.Item,{name:"secret",label:"\u8d26\u672c\u5bc6\u7801",children:Object(x.jsx)(l.a,{type:"password",placeholder:"\u8d26\u672c\u5bc6\u7801"})}),Object(x.jsx)("div",{style:{fontSize:14,marginBottom:"2rem",textAlign:"center"},children:Object(x.jsxs)("a",{onClick:function(){e.setState({expand:!e.state.expand})},children:[this.state.expand?Object(x.jsx)(p,{}):Object(x.jsx)(g.a,{})," \u66f4\u591a\u8d26\u672c\u8bbe\u7f6e"]})}),this.state.expand&&Object(x.jsxs)(h.Fragment,{children:[Object(x.jsx)(o.a.Item,{label:"\u521d\u59cb\u5316\u65e5\u671f",name:"startDate",initialValue:this.state.config.startDate,rules:[{required:!0}],children:Object(x.jsx)(l.a,{type:"date",placeholder:"\u521d\u59cb\u5316\u65e5\u671f"})}),Object(x.jsx)(o.a.Item,{label:"\u672c\u5e01\u4f4d",name:"operatingCurrency",initialValue:this.state.config.operatingCurrency,rules:[{required:!0}],children:Object(x.jsx)(l.a,{placeholder:"\u672c\u5e01\u4f4d"})}),Object(x.jsx)(o.a.Item,{label:"\u5e73\u8861\u8d26\u6237",name:"openingBalances",initialValue:this.state.config.openingBalances,rules:[{required:!0}],children:Object(x.jsx)(l.a,{placeholder:"\u5e73\u8861\u8d26\u6237"})}),Object(x.jsx)(o.a.Item,{label:"\u4fee\u6539\u6e90\u6587\u4ef6\u65f6\u662f\u5426\u5907\u4efd\u6570\u636e",name:"isBak",valuePropName:"checked",initialValue:this.state.config.isBak,children:Object(x.jsx)(s.a,{})})]}),Object(x.jsx)(o.a.Item,{children:Object(x.jsx)(d.a,{type:"primary",block:!0,htmlType:"submit",children:"\u521b\u5efa/\u8fdb\u5165\u4e2a\u4eba\u8d26\u672c"})})]})})})}}]),n}(h.Component);C.contextType=O.a;t.default=Object(y.a)(C)},59:function(e,t,n){"use strict";n.d(t,"c",(function(){return l})),n.d(t,"d",(function(){return s})),n.d(t,"e",(function(){return d})),n.d(t,"a",(function(){return u})),n.d(t,"b",(function(){return b})),n.d(t,"f",(function(){return f}));var a=n(463),r=n(73),c=n.n(r),i=n(112),o=n.n(i),l=function(e){var t=e.split(":");return t&&t.length>=1?e.split(":")[0]:""},s=function(e){return e.split(":").join("_")},d=function(e){var t=e.split(":");return t&&t.length>=2?e.split(":")[t.length-1]:""},u={Income:"\u6536\u5165",Expenses:"\u652f\u51fa",Liabilities:"\u8d1f\u503a",Assets:"\u8d44\u4ea7"},h=function(e){return e},b=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.method,r=t.headers,c=t.body,i={"Content-Type":"application/json",ledgerId:window.localStorage.getItem("ledgerId")};return new Promise((function(t,l){o()(e,{method:n,headers:Object.assign({},i,r),body:JSON.stringify(c)}).then(h).then((function(e){return e.json()})).then((function(e){var n=e.code;200===n?t(e.data):200!==n&&(400===n?a.b.error("\u8bf7\u6c42\u53c2\u6570\u9519\u8bef"):1001===n?a.b.error("\u8d26\u76ee\u4e0d\u5e73\u8861"):1003===n?a.b.error("\u65e0\u6548\u8d26\u6237"):1005===n?a.b.error("\u65e0\u6548\u547d\u4ee4"):1006===n?a.b.error("\u5bc6\u7801\u9519\u8bef"):1007===n?a.b.error("\u8d26\u6237\u5df2\u5b58\u5728"):1010===n||401===n?window.location.href="/web/#/ledger":a.b.error("\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u5237\u65b0\u9875\u9762\u91cd\u8bd5"),l(e))})).catch((function(e){a.b.error("\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u5237\u65b0\u9875\u9762\u91cd\u8bd5"),l(e)}))}))},f=function(){return c()().format("YYYY-M")}},70:function(e,t,n){"use strict";var a=n(61),r=n(12),c=n(13),i=n(15),o=n(14),l=n(0),s=n(1);t.a=function(e){return function(t){Object(i.a)(l,t);var n=Object(o.a)(l);function l(){var e;Object(r.a)(this,l);for(var t=arguments.length,a=new Array(t),c=0;c<t;c++)a[c]=arguments[c];return(e=n.call.apply(n,[this].concat(a))).defaultCommodity={currency:"CNY",symbol:"\uffe5"},e.currentCommodity=window.localStorage.getItem("ledgerCurrency"),e}return Object(c.a)(l,[{key:"render",value:function(){return Object(s.jsx)(e,Object(a.a)(Object(a.a)({},this.props),{},{commodity:this.currentCommodity?JSON.parse(this.currentCommodity):this.defaultCommodity}))}}]),l}(l.Component)}}}]); |