beancount-gs/public/static/js/16.e1595fcb.chunk.js

1 line
6.4 KiB
JavaScript

(this["webpackJsonpbeancount-web"]=this["webpackJsonpbeancount-web"]||[]).push([[16],{473:function(e,t,n){"use strict";n.r(t);var a=n(12),i=n(13),r=n(15),c=n(14),o=n(461),s=n(271),l=n(475),u=n(476),d=n(464),h=n(124),b=n(0),f=n.n(b),j=n(59),m=n(16),p=n(70),g=n(1),O={required:"${label} \u4e0d\u80fd\u4e3a\u7a7a\uff01"},y=function(e){Object(r.a)(n,e);var t=Object(c.a)(n);function n(){var e;Object(a.a)(this,n);for(var i=arguments.length,r=new Array(i),c=0;c<i;c++)r[c]=arguments[c];return(e=t.call.apply(t,[this].concat(r))).formRef=f.a.createRef(),e.state={loading:!1,checkStatus:"loading",showForm:!1,config:{}},e.checkReq=function(){e.setState({loading:!0}),Object(j.b)("/api/check",{method:"POST"}).then((function(t){e.setState({checkStatus:"ok"})})).catch((function(){e.setState({checkStatus:"error"})})).finally((function(){e.setState({loading:!1})}))},e.handleNextStep=function(){e.setState({loading:!0}),Object(j.b)("/api/config",{method:"GET"}).then((function(t){e.setState({config:t,showForm:!0})})).finally((function(){e.setState({loading:!1})}))},e.handleReCheck=function(){e.checkReq()},e.handleSubmitServerConfig=function(t){e.setState({loading:!0}),Object(j.b)("/api/config",{method:"POST",body:t}).then((function(){e.props.history.replace("/ledger")})).finally((function(){e.setState({loading:!1})}))},e}return Object(i.a)(n,[{key:"componentDidMount",value:function(){this.checkReq()}},{key:"render",value:function(){return"error"===this.state.checkStatus?Object(g.jsxs)("div",{children:[Object(g.jsx)(o.a,{message:"\u68c0\u6d4b\u5931\u8d25",description:"\u4f9d\u8d56\u672a\u5b89\u88c5\uff0c\u8bf7\u5148\u5b89\u88c5 beancount",type:"error",showIcon:!0}),Object(g.jsx)("div",{style:{marginTop:"1rem"},children:Object(g.jsx)(s.a,{block:!0,type:"danger",loading:this.state.loading,onClick:this.handleReCheck,children:"\u91cd\u65b0\u68c0\u6d4b"})}),Object(g.jsx)("div",{style:{marginTop:"1rem"},children:Object(g.jsx)("a",{href:"https://www.yuque.com/chuyi-ble7p/beancount-ns/sqwwqa#RwqnF",target:"_blank",children:"\u600e\u4e48\u5b89\u88c5 beancount ?"})})]}):"ok"===this.state.checkStatus?this.state.showForm?Object(g.jsx)("div",{children:Object(g.jsxs)(l.a,{name:"init-form",className:"page-form",size:"middle",layout:"vertical",style:{textAlign:"left"},ref:this.formRef,onFinish:this.handleSubmitServerConfig,validateMessages:O,children:[Object(g.jsx)(l.a.Item,{label:"\u8d26\u672c\u5b58\u50a8\u4f4d\u7f6e",name:"dataPath",initialValue:this.state.config.dataPath,rules:[{required:!0}],children:Object(g.jsx)(u.a,{placeholder:"\u8d26\u672c\u5b58\u50a8\u4f4d\u7f6e"})}),Object(g.jsx)(l.a.Item,{label:"\u521d\u59cb\u5316\u65e5\u671f",name:"startDate",initialValue:this.state.config.startDate,rules:[{required:!0}],children:Object(g.jsx)(u.a,{type:"date",placeholder:"\u521d\u59cb\u5316\u65e5\u671f"})}),Object(g.jsx)(l.a.Item,{label:"\u672c\u5e01\u4f4d",name:"operatingCurrency",initialValue:this.state.config.operatingCurrency,rules:[{required:!0}],children:Object(g.jsx)(u.a,{placeholder:"\u672c\u5e01\u4f4d"})}),Object(g.jsx)(l.a.Item,{label:"\u5e73\u8861\u8d26\u6237",name:"openingBalances",initialValue:this.state.config.openingBalances,rules:[{required:!0}],children:Object(g.jsx)(u.a,{placeholder:"\u5e73\u8861\u8d26\u6237"})}),Object(g.jsx)(l.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(g.jsx)(d.a,{})}),Object(g.jsx)(l.a.Item,{children:Object(g.jsx)(s.a,{block:!0,type:"primary",htmlType:"submit",loading:this.state.loading,className:"submit-button",children:"\u786e\u8ba4"})})]})}):Object(g.jsxs)("div",{children:[Object(g.jsx)(o.a,{message:"\u68c0\u6d4b\u901a\u8fc7",description:"beancount\u5df2\u5b89\u88c5\uff0c\u70b9\u51fb\u4e0b\u4e00\u6b65\u6765\u5b8c\u6210\u521d\u59cb\u914d\u7f6e",type:"success",showIcon:!0}),Object(g.jsx)("div",{style:{marginTop:"1rem"}}),Object(g.jsx)(s.a,{type:"primary",block:!0,onClick:this.handleNextStep,children:"\u4e0b\u4e00\u6b65"})]}):Object(g.jsx)(h.a,{tip:"Loading...",children:Object(g.jsx)(o.a,{message:"\u68c0\u6d4b\u4e2d",description:"\u6b63\u5728\u68c0\u6d4b beancount \u662f\u5426\u5df2\u5b89\u88c5",type:"info",showIcon:!0})})}}]),n}(b.Component);y.contextType=m.a,t.default=Object(p.a)(y)},59:function(e,t,n){"use strict";n.d(t,"c",(function(){return s})),n.d(t,"d",(function(){return l})),n.d(t,"e",(function(){return u})),n.d(t,"a",(function(){return d})),n.d(t,"b",(function(){return b})),n.d(t,"f",(function(){return f}));var a=n(463),i=n(73),r=n.n(i),c=n(112),o=n.n(c),s=function(e){var t=e.split(":");return t&&t.length>=1?e.split(":")[0]:""},l=function(e){return e.split(":").join("_")},u=function(e){var t=e.split(":");return t&&t.length>=2?e.split(":")[t.length-1]:""},d={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,i=t.headers,r=t.body,c={"Content-Type":"application/json",ledgerId:window.localStorage.getItem("ledgerId")};return new Promise((function(t,s){o()(e,{method:n,headers:Object.assign({},c,i),body:JSON.stringify(r)}).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"),s(e))})).catch((function(e){a.b.error("\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u5237\u65b0\u9875\u9762\u91cd\u8bd5"),s(e)}))}))},f=function(){return r()().format("YYYY-M")}},70:function(e,t,n){"use strict";var a=n(61),i=n(12),r=n(13),c=n(15),o=n(14),s=n(0),l=n(1);t.a=function(e){return function(t){Object(c.a)(s,t);var n=Object(o.a)(s);function s(){var e;Object(i.a)(this,s);for(var t=arguments.length,a=new Array(t),r=0;r<t;r++)a[r]=arguments[r];return(e=n.call.apply(n,[this].concat(a))).defaultCommodity={currency:"CNY",symbol:"\uffe5"},e.currentCommodity=window.localStorage.getItem("ledgerCurrency"),e}return Object(r.a)(s,[{key:"render",value:function(){return Object(l.jsx)(e,Object(a.a)(Object(a.a)({},this.props),{},{commodity:this.currentCommodity?JSON.parse(this.currentCommodity):this.defaultCommodity}))}}]),s}(s.Component)}}}]);