beancount-gs/public/static/js/967.25b81fb0.chunk.js

1 line
35 KiB
JavaScript

(self.webpackChunkbeancount_web=self.webpackChunkbeancount_web||[]).push([[967],{3967:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>$e});var s=n(5547),a=n(983),c=n(6411),i=n(6445),r=n(9379),o=n(9284);const l={icon:{tag:"svg",attrs:{viewBox:"0 0 1024 1024",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 1024c-69.1 0-136.2-13.5-199.3-40.2C251.7 958 197 921 150 874c-47-47-84-101.7-109.8-162.7C13.5 648.2 0 581.1 0 512c0-19.9 16.1-36 36-36s36 16.1 36 36c0 59.4 11.6 117 34.6 171.3 22.2 52.4 53.9 99.5 94.3 139.9 40.4 40.4 87.5 72.2 139.9 94.3C395 940.4 452.6 952 512 952c59.4 0 117-11.6 171.3-34.6 52.4-22.2 99.5-53.9 139.9-94.3 40.4-40.4 72.2-87.5 94.3-139.9C940.4 629 952 571.4 952 512c0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.2C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3s-13.5 136.2-40.2 199.3C958 772.3 921 827 874 874c-47 47-101.8 83.9-162.7 109.7-63.1 26.8-130.2 40.3-199.3 40.3z"}}]},name:"loading-3-quarters",theme:"outlined"};var d=n(3768),h=function(e,t){return o.createElement(d.A,(0,r.A)((0,r.A)({},e),{},{ref:t,icon:l}))};const u=o.forwardRef(h);var p=n(5398),m=n(1365);const y={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372zm47.7-395.2l-25.4-5.9V348.6c38 5.2 61.5 29 65.5 58.2.5 4 3.9 6.9 7.9 6.9h44.9c4.7 0 8.4-4.1 8-8.8-6.1-62.3-57.4-102.3-125.9-109.2V263c0-4.4-3.6-8-8-8h-28.1c-4.4 0-8 3.6-8 8v33c-70.8 6.9-126.2 46-126.2 119 0 67.6 49.8 100.2 102.1 112.7l24.7 6.3v142.7c-44.2-5.9-69-29.5-74.1-61.3-.6-3.8-4-6.6-7.9-6.6H363c-4.7 0-8.4 4-8 8.7 4.5 55 46.2 105.6 135.2 112.1V761c0 4.4 3.6 8 8 8h28.4c4.4 0 8-3.6 8-8.1l-.2-31.7c78.3-6.9 134.3-48.8 134.3-124-.1-69.4-44.2-100.4-109-116.4zm-68.6-16.2c-5.6-1.6-10.3-3.1-15-5-33.8-12.2-49.5-31.9-49.5-57.3 0-36.3 27.5-57 64.5-61.7v124zM534.3 677V543.3c3.1.9 5.9 1.6 8.8 2.2 47.3 14.4 63.2 34.4 63.2 65.1 0 39.1-29.4 62.6-72 66.4z"}}]},name:"dollar-circle",theme:"outlined"};var A=function(e,t){return o.createElement(d.A,(0,r.A)((0,r.A)({},e),{},{ref:t,icon:y}))};const f=o.forwardRef(A);const v={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M320 224h-66v-56c0-4.4-3.6-8-8-8h-52c-4.4 0-8 3.6-8 8v56h-66c-4.4 0-8 3.6-8 8v560c0 4.4 3.6 8 8 8h66v56c0 4.4 3.6 8 8 8h52c4.4 0 8-3.6 8-8v-56h66c4.4 0 8-3.6 8-8V232c0-4.4-3.6-8-8-8zm-60 508h-80V292h80v440zm644-436h-66v-96c0-4.4-3.6-8-8-8h-52c-4.4 0-8 3.6-8 8v96h-66c-4.4 0-8 3.6-8 8v416c0 4.4 3.6 8 8 8h66v96c0 4.4 3.6 8 8 8h52c4.4 0 8-3.6 8-8v-96h66c4.4 0 8-3.6 8-8V304c0-4.4-3.6-8-8-8zm-60 364h-80V364h80v296zM612 404h-66V232c0-4.4-3.6-8-8-8h-52c-4.4 0-8 3.6-8 8v172h-66c-4.4 0-8 3.6-8 8v200c0 4.4 3.6 8 8 8h66v172c0 4.4 3.6 8 8 8h52c4.4 0 8-3.6 8-8V620h66c4.4 0 8-3.6 8-8V412c0-4.4-3.6-8-8-8zm-60 145a3 3 0 01-3 3h-74a3 3 0 01-3-3v-74a3 3 0 013-3h74a3 3 0 013 3v74z"}}]},name:"sliders",theme:"outlined"};var x=function(e,t){return o.createElement(d.A,(0,r.A)((0,r.A)({},e),{},{ref:t,icon:v}))};const b=o.forwardRef(x);var C=n(4680),g=n(1357),j=n(9636),w=n(8168),S=n(4467),D=n(5473),T=n(4480),k=n.n(T),N=n(436),I=n(3029),P=n(2901),E=n(5501),O=n(9426),V=n(2284),M=n(4650),z=n(7737),R=n.n(z),q=n(45),$=n(7285),K=n(5544),F=o.forwardRef((function(e,t){var n,s=e.prefixCls,a=e.forceRender,c=e.className,i=e.style,r=e.children,l=e.isActive,d=e.role,h=o.useState(l||a),u=(0,K.A)(h,2),p=u[0],m=u[1];return o.useEffect((function(){(a||l)&&m(!0)}),[a,l]),p?o.createElement("div",{ref:t,className:k()("".concat(s,"-content"),(n={},(0,S.A)(n,"".concat(s,"-content-active"),l),(0,S.A)(n,"".concat(s,"-content-inactive"),!l),n),c),style:i,role:d},o.createElement("div",{className:"".concat(s,"-content-box")},r)):null}));F.displayName="PanelContent";const L=F;var Y=["className","id","style","prefixCls","headerClass","children","isActive","destroyInactivePanel","accordion","forceRender","openMotion","extra","collapsible"],B=function(e){(0,E.A)(n,e);var t=(0,O.A)(n);function n(){var e;(0,I.A)(this,n);for(var s=arguments.length,a=new Array(s),c=0;c<s;c++)a[c]=arguments[c];return(e=t.call.apply(t,[this].concat(a))).onItemClick=function(){var t=e.props,n=t.onItemClick,s=t.panelKey;"function"===typeof n&&n(s)},e.handleKeyPress=function(t){"Enter"!==t.key&&13!==t.keyCode&&13!==t.which||e.onItemClick()},e.renderIcon=function(){var t=e.props,n=t.showArrow,s=t.expandIcon,a=t.prefixCls,c=t.collapsible;if(!n)return null;var i="function"===typeof s?s(e.props):o.createElement("i",{className:"arrow"});return i&&o.createElement("div",{className:"".concat(a,"-expand-icon"),onClick:"header"===c||"icon"===c?e.onItemClick:null},i)},e.renderTitle=function(){var t=e.props,n=t.header,s=t.prefixCls,a=t.collapsible;return o.createElement("span",{className:"".concat(s,"-header-text"),onClick:"header"===a?e.onItemClick:null},n)},e}return(0,P.A)(n,[{key:"shouldComponentUpdate",value:function(e){return!R()(this.props,e)}},{key:"render",value:function(){var e,t,n=this.props,s=n.className,a=n.id,c=n.style,i=n.prefixCls,r=n.headerClass,l=n.children,d=n.isActive,h=n.destroyInactivePanel,u=n.accordion,p=n.forceRender,m=n.openMotion,y=n.extra,A=n.collapsible,f=(0,q.A)(n,Y),v="disabled"===A,x="header"===A,b="icon"===A,C=k()((e={},(0,S.A)(e,"".concat(i,"-item"),!0),(0,S.A)(e,"".concat(i,"-item-active"),d),(0,S.A)(e,"".concat(i,"-item-disabled"),v),e),s),g={className:k()("".concat(i,"-header"),(t={},(0,S.A)(t,r,r),(0,S.A)(t,"".concat(i,"-header-collapsible-only"),x),(0,S.A)(t,"".concat(i,"-icon-collapsible-only"),b),t)),"aria-expanded":d,"aria-disabled":v,onKeyPress:this.handleKeyPress};x||b||(g.onClick=this.onItemClick,g.role=u?"tab":"button",g.tabIndex=v?-1:0);var j=null!==y&&void 0!==y&&"boolean"!==typeof y;return delete f.header,delete f.panelKey,delete f.onItemClick,delete f.showArrow,delete f.expandIcon,o.createElement("div",(0,w.A)({},f,{className:C,style:c,id:a}),o.createElement("div",g,this.renderIcon(),this.renderTitle(),j&&o.createElement("div",{className:"".concat(i,"-extra")},y)),o.createElement($.Ay,(0,w.A)({visible:d,leavedClassName:"".concat(i,"-content-hidden")},m,{forceRender:p,removeOnLeave:h}),(function(e,t){var n=e.className,s=e.style;return o.createElement(L,{ref:t,prefixCls:i,className:n,style:s,isActive:d,forceRender:p,role:u?"tabpanel":null},l)})))}}]),n}(o.Component);B.defaultProps={showArrow:!0,isActive:!1,onItemClick:function(){},headerClass:"",forceRender:!1};const H=B;function U(e){var t=e;if(!Array.isArray(t)){var n=(0,V.A)(t);t="number"===n||"string"===n?[t]:[]}return t.map((function(e){return String(e)}))}var W=function(e){(0,E.A)(n,e);var t=(0,O.A)(n);function n(e){var s;(0,I.A)(this,n),(s=t.call(this,e)).onClickItem=function(e){var t=s.state.activeKey;if(s.props.accordion)t=t[0]===e?[]:[e];else{var n=(t=(0,N.A)(t)).indexOf(e);n>-1?t.splice(n,1):t.push(e)}s.setActiveKey(t)},s.getNewChild=function(e,t){if(!e)return null;var n=s.state.activeKey,a=s.props,c=a.prefixCls,i=a.openMotion,r=a.accordion,l=a.destroyInactivePanel,d=a.expandIcon,h=a.collapsible,u=e.key||String(t),p=e.props,m=p.header,y=p.headerClass,A=p.destroyInactivePanel,f=p.collapsible,v=null!==f&&void 0!==f?f:h,x={key:u,panelKey:u,header:m,headerClass:y,isActive:r?n[0]===u:n.indexOf(u)>-1,prefixCls:c,destroyInactivePanel:null!==A&&void 0!==A?A:l,openMotion:i,accordion:r,children:e.props.children,onItemClick:"disabled"===v?null:s.onClickItem,expandIcon:d,collapsible:v};return"string"===typeof e.type?e:(Object.keys(x).forEach((function(e){"undefined"===typeof x[e]&&delete x[e]})),o.cloneElement(e,x))},s.getItems=function(){var e=s.props.children;return(0,M.A)(e).map(s.getNewChild)},s.setActiveKey=function(e){"activeKey"in s.props||s.setState({activeKey:e}),s.props.onChange(s.props.accordion?e[0]:e)};var a=e.activeKey,c=e.defaultActiveKey;return"activeKey"in e&&(c=a),s.state={activeKey:U(c)},s}return(0,P.A)(n,[{key:"shouldComponentUpdate",value:function(e,t){return!R()(this.props,e)||!R()(this.state,t)}},{key:"render",value:function(){var e,t=this.props,n=t.prefixCls,s=t.className,a=t.style,c=t.accordion,i=k()((e={},(0,S.A)(e,n,!0),(0,S.A)(e,s,!!s),e));return o.createElement("div",{className:i,style:a,role:c?"tablist":null},this.getItems())}}],[{key:"getDerivedStateFromProps",value:function(e){var t={};return"activeKey"in e&&(t.activeKey=U(e.activeKey)),t}}]),n}(o.Component);W.defaultProps={prefixCls:"rc-collapse",onChange:function(){},accordion:!1,destroyInactivePanel:!1},W.Panel=H;const Q=W;W.Panel;var _=n(37),J=n(3135),G=n(259),X=n(7458);var Z=function(e){var t=o.useContext(J.QO),n=t.getPrefixCls,s=t.direction,a=e.prefixCls,c=e.className,i=void 0===c?"":c,r=e.bordered,l=void 0===r||r,d=e.ghost,h=e.expandIconPosition,u=void 0===h?"start":h,p=n("collapse",a),m=o.useMemo((function(){return"left"===u?"start":"right"===u?"end":u}),[u]),y=k()("".concat(p,"-icon-position-").concat(m),(0,S.A)((0,S.A)((0,S.A)({},"".concat(p,"-borderless"),!l),"".concat(p,"-rtl"),"rtl"===s),"".concat(p,"-ghost"),!!d),i),A=(0,w.A)((0,w.A)({},G.Ay),{motionAppear:!1,leavedClassName:"".concat(p,"-content-hidden")});return o.createElement(Q,(0,w.A)({openMotion:A},e,{expandIcon:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.expandIcon,s=n?n(t):o.createElement(D.A,{rotate:t.isActive?90:void 0});return(0,X.Ob)(s,(function(){return{className:k()(s.props.className,"".concat(p,"-arrow"))}}))},prefixCls:p,className:y}),function(){var t=e.children;return(0,M.A)(t).map((function(e,t){var n;if(null===(n=e.props)||void 0===n?void 0:n.disabled){var s=e.key||String(t),a=e.props,c=a.disabled,i=a.collapsible,r=(0,w.A)((0,w.A)({},(0,_.A)(e.props,["disabled"])),{key:s,collapsible:null!==i&&void 0!==i?i:c?"disabled":void 0});return(0,X.Ob)(e,r)}return e}))}())};Z.Panel=function(e){var t=o.useContext(J.QO).getPrefixCls,n=e.prefixCls,s=e.className,a=void 0===s?"":s,c=e.showArrow,i=void 0===c||c,r=t("collapse",n),l=k()((0,S.A)({},"".concat(r,"-no-arrow"),!i),a);return o.createElement(Q.Panel,(0,w.A)({},e,{prefixCls:r,className:l}))};const ee=Z;var te=n(7691),ne=n(9492),se=n(8037),ae=n(1961),ce=n(6749),ie=n(4412),re=n(1896),oe=n(1619),le=n(6668),de=n(2942),he=n(1516),ue=n(4258),pe=n(8409),me=n.n(pe),ye=n(3981),Ae=n(943),fe=n(9470),ve=n(4760),xe=n(712);const be={required:"${label} \u4e0d\u80fd\u4e3a\u7a7a\uff01"};class Ce extends o.Component{constructor(){super(...arguments),this.formRef=o.createRef(),this.state={transactions:[],loading:!1},this.handleSyncPriceAccount=e=>{const t=this.props.account;t&&(this.setState({loading:!0}),(0,ve.hd)("/api/auth/commodity/price",{method:"POST",body:{commodity:t.currency,...e}}).then((()=>{this.props.onClose(),this.formRef.current.resetFields()})).catch(console.error).finally((()=>{this.setState({loading:!1})})))}}render(){const e=this.props.account,{loading:t}=this.state;return(0,xe.jsx)(oe.A,{title:(0,xe.jsx)("div",{children:e.account}),placement:"bottom",closable:!0,className:"page-drawer",height:"60vh",bodyStyle:{display:"flex",justifyContent:"center"},...this.props,children:(0,xe.jsx)("div",{className:"page-form",children:(0,xe.jsxs)(le.A,{name:"sync-price-form",className:"page-form",size:"large",style:{textAlign:"left"},ref:this.formRef,onFinish:this.handleSyncPriceAccount,validateMessages:be,children:[(0,xe.jsx)(le.A.Item,{name:"date",initialValue:me()().format("YYYY-MM-DD"),rules:[{required:!0}],children:(0,xe.jsx)(de.A,{type:"date",placeholder:"\u65f6\u95f4"})}),(0,xe.jsx)(le.A.Item,{name:"price",rules:[{required:!0}],children:(0,xe.jsx)(de.A,{type:"number",step:"0.01",addonBefore:`1 ${e.currency}\u2248`,addonAfter:e.marketCurrency,placeholder:"\u51c0\u503c/\u6c47\u7387"})}),(0,xe.jsx)(le.A.Item,{children:(0,xe.jsx)(re.A,{type:"primary",htmlType:"submit",loading:t,className:"submit-button",children:"\u786e\u8ba4"})})]})})})}}const ge=Ce;var je=n(1410),we=n(6806);class Se extends o.Component{constructor(){super(...arguments),this.state={loading:!1,commodityPrices:[]},this.queryCommodityPrices=()=>{this.setState({loading:!0}),(0,ve.hd)("/api/auth/stats/commodity/price").then((e=>{const t=[];e.forEach((e=>{t.push({date:(0,ve.Yq)(e.date),commodity:e.commodity,value:Number(e.value)})})),this.setState({commodityPrices:t})})).finally((()=>{this.setState({loading:!1})}))}}componentWillReceiveProps(e){e.visible&&0===this.state.commodityPrices.length&&this.queryCommodityPrices()}render(){return(0,xe.jsx)(oe.A,{title:(0,xe.jsx)("div",{style:{fontSize:14},children:(0,xe.jsx)("div",{children:"\u6c47\u7387\u66f2\u7ebf"})}),placement:"bottom",closable:!0,className:"page-drawer",height:"530px",bodyStyle:{display:"flex",justifyContent:"center"},...this.props,children:(0,xe.jsx)("div",{className:"page-form",style:{maxWidth:"100%"},children:(0,xe.jsx)(ne.A,{spinning:this.state.loading,children:(0,xe.jsxs)(we.Chart,{animate:!1,padding:[10,80,80,80],autoFit:!0,height:400,data:this.state.commodityPrices,children:[(0,xe.jsx)(we.Legend,{}),(0,xe.jsx)(we.LineAdvance,{point:!0,position:"date*value",color:"commodity"})]})})})})}}const De=Se;var Te=n(2475),ke=n(2069),Ne=n(8415),Ie=n(56);class Pe extends o.Component{constructor(){super(...arguments),this.state={loading:!1,currencies:[]},this.queryCommodityCurrencies=()=>{this.setState({loading:!0}),(0,ve.hd)("/api/auth/commodity/currencies").then((e=>{this.setState({currencies:e})})).finally((()=>{this.setState({loading:!1})}))}}componentWillReceiveProps(e){e.visible&&this.queryCommodityCurrencies()}render(){return(0,xe.jsx)(oe.A,{title:(0,xe.jsx)("div",{style:{fontSize:14},children:(0,xe.jsx)("div",{children:"\u5168\u90e8\u8d27\u5e01"})}),placement:"bottom",closable:!0,className:"page-drawer",height:"530px",bodyStyle:{display:"flex",justifyContent:"center"},...this.props,children:(0,xe.jsx)("div",{className:"page-form",style:{maxWidth:"100%"},children:(0,xe.jsx)(ne.A,{spinning:this.state.loading,children:(0,xe.jsx)(se.Ay,{className:"multi-commodity-list-component",loading:!1,itemLayout:"horizontal",dataSource:this.state.currencies,renderItem:e=>(0,xe.jsx)(se.Ay.Item,{children:(0,xe.jsx)(se.Ay.Item.Meta,{avatar:(0,xe.jsx)(Ie.A,{style:{color:"#f56a00",backgroundColor:"#fde3cf"},children:e.symbol}),title:e.name,description:e.price?`1${e.currency}=${e.price}${this.props.sysCurrency} (${e.priceDate})`:"\u6c47\u7387\u672a\u5b9a\u4e49"})})})})})})}}const Ee=Pe,{Option:Oe}=j.A,{Panel:Ve}=ee,{TabPane:Me}=te.A,ze={required:"${label} \u4e0d\u80fd\u4e3a\u7a7a\uff01"},Re=e=>{let{hideMoney:t,loading:n,accounts:i,onEdit:r,commodity:o,onAddTransaction:l}=e;const d={};return i.forEach((e=>{const t=e.type.key,n=e.type.name,s=d[n];s?s.children.push(e):d[n]={id:t,name:n,children:[e]}})),(0,xe.jsx)(ne.A,{spinning:n,tip:"\u52a0\u8f7d\u4e2d...",children:(0,xe.jsx)("div",{style:{minHeight:"240px"},children:(0,xe.jsx)(ee,{ghost:!0,children:Object.values(d).map((e=>{let n;if(e&&e.children.length>0){const t=e.children.filter((e=>e.marketNumber));t&&t.length>0&&(n=t.map((e=>(0,ye.A)(e.marketNumber||0))).reduce(((e,t)=>e.plus(t))))}return(0,xe.jsx)(Ve,{header:`${e.children.length}\u4e2a${e.name}\u8d26\u6237 ${n&&!t?`(${(0,ve.vv)(n,o,e.id)})`:""}`,children:(0,xe.jsx)(se.Ay,{itemLayout:"horizontal",dataSource:e.children,renderItem:e=>{const n=[];if(t)n.push("***");else if(e.marketNumber){const t=(e.positions||[]).filter((t=>t.currency!==e.marketCurrency));t.length>0?(n.push((0,xe.jsx)("span",{children:t.map((t=>(0,ve.vv)(t.number,t.currencySymbol,e.account)))})),n.push((0,xe.jsx)("div",{children:(0,ve.vv)(e.marketNumber,e.marketCurrencySymbol,e.account)}))):n.push((0,xe.jsx)("div",{children:(0,ve.vv)(e.marketNumber,e.marketCurrencySymbol,e.account)}))}return e.loading?n.push((0,xe.jsx)(s.A,{})):(n.push((0,xe.jsx)(ae.A,{title:"\u65b0\u589e\u4ea4\u6613",children:(0,xe.jsx)(a.A,{onClick:()=>{l(e)}},"list-more")})),n.push((0,xe.jsx)(ae.A,{title:"\u66f4\u591a\u64cd\u4f5c",children:(0,xe.jsx)(c.A,{onClick:()=>{r(e,e.currency==o.currency)}},"list-more")}))),(0,xe.jsx)(se.Ay.Item,{actions:n,children:(0,xe.jsx)(se.Ay.Item.Meta,{avatar:(0,xe.jsx)(fe.A,{iconType:(0,ve.fe)(e.account)}),title:(0,xe.jsxs)("div",{children:[e.endDate&&(0,xe.jsx)(ce.A,{color:"#f50",children:"\u5df2\u5173\u95ed"}),(0,xe.jsx)("span",{children:(0,ve.Pt)(e.account)})]}),description:(0,xe.jsxs)("div",{children:[e.startDate,e.endDate?"~"+e.endDate:"","\xa0",e.currencies&&e.currencies.map((e=>(0,xe.jsxs)("span",{children:[(0,xe.jsx)("span",{children:e.currency}),e.isAnotherCurrency&&e.price&&(0,xe.jsx)(ae.A,{title:e.priceDate,children:(0,xe.jsxs)("span",{children:["\u2248",e.price]})}),"\xa0"]})))]})})})}})},e.id)}))})})})};class qe extends o.Component{constructor(){super(...arguments),this.theme=this.context.theme,this.formRef=o.createRef(),this.balanceFormRef=o.createRef(),this.state={loading:!1,drawerVisible:!1,balanceDrawerVisible:!1,accountDrawerVisible:!1,accounts:[],fetchAccountTypeloading:!1,accountTypes:[],selectedAccountType:"",iconType:"",selectedAccountTypePrefix:"Assets",balanceAccount:null,editAccount:{},transactionDrawerVisible:!1,syncPriceAccount:null,syncPriceDrawerVisible:!1,editAccountDiffCommodity:!1,refreshLoading:!1,commodityPriceDrawerVisible:!1,addTransactionAccount:null,addTransactionDrawerVisible:!1,multiCommodityDrawerVisible:!1,hideMoney:JSON.parse(window.localStorage.getItem("hideMoney")||"false")},this.queryAllAccounts=()=>{this.setState({loading:!0}),(0,ve.hd)("/api/auth/account/all").then((e=>{this.setState({accounts:e})})).catch(console.error).finally((()=>{this.setState({loading:!1})}))},this.queryAllAccountTypes=()=>{this.setState({fetchAccountTypeloading:!0}),(0,ve.hd)("/api/auth/account/type").then((e=>{this.setState({accountTypes:e})})).catch(console.error).finally((()=>{this.setState({fetchAccountTypeloading:!1})}))},this.handleHideMoney=()=>{const e=!this.state.hideMoney;this.setState({hideMoney:e}),window.localStorage.setItem("hideMoney",e)},this.handleChangeAccountType=e=>{this.setState({selectedAccountType:e})},this.handleChangeAccountTypePrefix=e=>{this.setState({selectedAccountTypePrefix:e})},this.handleAddAccount=e=>{this.setState({loading:!0});const{account:t,date:n,accountType:s,accountTypeName:a,currency:c}=e;if("Undefined"===this.state.selectedAccountType){const e=`${this.state.selectedAccountTypePrefix}:${s}`;(0,ve.hd)("/api/auth/account/type",{method:"POST",body:{type:e,name:a}}).then((e=>{this.setState({drawerVisible:!1,accountTypes:[e,...this.state.accountTypes]}),this.formRef.current.resetFields(),ie.Ay.success("\u6dfb\u52a0\u6210\u529f")})).catch(console.error).finally((()=>{this.setState({loading:!1})}))}else{const e=`${this.state.selectedAccountType}:${t}`;(0,ve.hd)("/api/auth/account",{method:"POST",body:{account:e,date:n,currency:c}}).then((e=>{this.setState({drawerVisible:!1,accounts:[e,...this.state.accounts]}),this.formRef.current.resetFields(),ie.Ay.success("\u6dfb\u52a0\u6210\u529f")})).catch(console.error).finally((()=>{this.setState({loading:!1})}))}},this.handleCloseAccount=()=>{const e=this.state.editAccount.account,t=this.state.accounts.map((t=>t.account===e?Object.assign({loading:!0},t):t));this.setState({accounts:t});const n=me()().format("YYYY-MM-DD");(0,ve.hd)("/api/auth/account/close",{method:"POST",body:{account:e,date:n}}).then((t=>{const n=this.state.accounts.filter((t=>t.account!==e));this.setState({accounts:n})})).catch(console.error).finally((()=>{this.setState({accountDrawerVisible:!1,accounts:this.state.accounts.map((e=>(delete e.loading,e)))})}))},this.handleBalanceAccount=e=>{this.setState({loading:!0});const t=this.state.balanceAccount;(0,ve.hd)("/api/auth/account/balance",{method:"POST",body:{...e,account:t}}).then((e=>{const t=this.state.accounts.map((t=>t.account===e.account?(t.marketNumber=e.marketNumber,t.marketCurrency=e.marketCurrency,t.marketCurrencySymbol=e.marketCurrencySymbol,t):t));this.setState({accounts:t}),this.handleCloseBalanceDrawer(),this.balanceFormRef.current.resetFields()})).catch(console.error).finally((()=>{this.setState({loading:!1})}))},this.handleEditAccountInput=e=>{const t=`${this.state.selectedAccountType}:${e.target.value}`;this.setState({iconType:(0,ve.fe)(t)})},this.handleOpenDrawer=()=>{this.setState({drawerVisible:!0},(()=>{this.formRef.current.setFieldsValue({date:me()().format("YYYY-MM-DD")})}))},this.handleCloseDrawer=()=>{this.setState({drawerVisible:!1})},this.handleOpenBalanceDrawer=()=>{this.setState({balanceDrawerVisible:!0,balanceAccount:this.state.editAccount.account},(()=>{this.balanceFormRef.current.setFieldsValue({date:me()().format("YYYY-MM-DD")})}))},this.handleCloseBalanceDrawer=()=>{this.setState({balanceDrawerVisible:!1,accountDrawerVisible:!1,balanceAccount:null})},this.handleOpenSyncPriceDrawer=()=>{this.setState({syncPriceDrawerVisible:!0,syncPriceAccount:this.state.editAccount})},this.handleCloseSyncPriceDrawer=()=>{this.setState({syncPriceDrawerVisible:!1,accountDrawerVisible:!1,syncPriceAccount:null})},this.handleOpenAccountDrawer=(e,t)=>{this.setState({accountDrawerVisible:!0,editAccount:e,editAccountDiffCommodity:t})},this.handleCloseAccountDrawer=()=>{this.setState({accountDrawerVisible:!1})},this.handleChangeFile=e=>{"done"===e.file.status?(ie.Ay.success(`${e.file.name} \u4e0a\u4f20\u6210\u529f`),this.setState({accountDrawerVisible:!1})):"error"===e.file.status&&ie.Ay.error(`${e.file.name} \u4e0a\u4f20\u5931\u8d25`)},this.handleOpenTransactionDrawer=()=>{this.setState({transactionDrawerVisible:!0})},this.handleCloseTransactionDrawer=()=>{this.setState({transactionDrawerVisible:!1,accountDrawerVisible:!1,transactions:[]})},this.handleOpenCommodityPriceDrawer=()=>{this.setState({commodityPriceDrawerVisible:!0})},this.handleCloseCommodityPriceDrawer=()=>{this.setState({commodityPriceDrawerVisible:!1})},this.handleCloseMultiCommodityDrawer=()=>{this.setState({multiCommodityDrawerVisible:!1})},this.handleOpenAddTransactionDrawer=e=>{this.setState({addTransactionDrawerVisible:!0,addTransactionAccount:e})},this.handleCloseAddTransactionDrawer=()=>{this.setState({addTransactionDrawerVisible:!1,addTransactionAccount:null})},this.handleRefreshAccountCache=()=>{this.setState({refreshLoading:!0}),(0,ve.hd)("/api/auth/account/refresh",{method:"POST"}).then((()=>{ie.Ay.success("\u7f13\u5b58\u5df2\u66f4\u65b0"),this.queryAllAccounts(),this.queryAllAccountTypes()})).finally((()=>{this.setState({refreshLoading:!1})}))},this.handleAfterAddTransaction=()=>{this.handleCloseAddTransactionDrawer()}}componentDidMount(){this.queryAllAccounts(),this.queryAllAccountTypes()}render(){this.context.theme!==this.theme&&(this.theme=this.context.theme);const{accounts:e,loading:t,drawerVisible:n,balanceDrawerVisible:s,accountTypes:a,iconType:c,selectedAccountType:r,selectedAccountTypePrefix:o,accountDrawerVisible:l,editAccount:d,transactionDrawerVisible:h,syncPriceDrawerVisible:y}=this.state;return(0,xe.jsxs)("div",{className:"account-page",children:[(0,xe.jsxs)("div",{className:"button-wrapper",children:[(0,xe.jsxs)("div",{children:[(0,xe.jsx)(re.A,{type:"primary",size:"small",icon:(0,xe.jsx)(i.A,{}),onClick:this.handleOpenDrawer,children:"\u6dfb\u52a0\u8d26\u6237"}),"\xa0\xa0",(0,xe.jsx)(re.A,{size:"small",loading:this.state.refreshLoading,icon:(0,xe.jsx)(u,{}),onClick:this.handleRefreshAccountCache,children:"\u5237\u65b0"}),"\xa0\xa0",this.state.hideMoney?(0,xe.jsx)(re.A,{size:"small",icon:(0,xe.jsx)(p.A,{}),onClick:this.handleHideMoney}):(0,xe.jsx)(re.A,{size:"small",icon:(0,xe.jsx)(m.A,{}),onClick:this.handleHideMoney})]}),(0,xe.jsxs)("div",{children:[(0,xe.jsx)(re.A,{type:"text",size:"small",icon:(0,xe.jsx)(f,{}),onClick:()=>{this.setState({multiCommodityDrawerVisible:!0})},children:"\u5168\u90e8\u8d27\u5e01"}),(0,xe.jsx)(re.A,{type:"text",size:"small",icon:(0,xe.jsx)(b,{}),onClick:()=>{this.setState({commodityPriceDrawerVisible:!0})},children:"\u6c47\u7387\u66f2\u7ebf"}),(0,xe.jsx)(re.A,{type:"text",size:"small",icon:(0,xe.jsx)(C.A,{}),onClick:()=>{this.props.history.push("/edit")},children:"\u7f16\u8f91\u6e90\u6587\u4ef6"})]})]}),(0,xe.jsx)(oe.A,{title:"\u65b0\u589e\u8d26\u6237",placement:"bottom",closable:!0,onClose:this.handleCloseDrawer,open:n,height:"540",className:"page-drawer",bodyStyle:{display:"flex",justifyContent:"center"},children:(0,xe.jsxs)(le.A,{name:"add-account-form",className:"page-form",size:"large",style:{textAlign:"left"},ref:this.formRef,onFinish:this.handleAddAccount,validateMessages:ze,children:[(0,xe.jsx)(le.A.Item,{name:"type",label:" \u5206\u7c7b",rules:[{required:!0}],children:(0,xe.jsxs)(j.A,{showSearch:!0,placeholder:"\u5206\u7c7b",optionFilterProp:"children",onChange:this.handleChangeAccountType,children:[(0,xe.jsx)(Oe,{value:"Undefined",children:"+ \u65b0\u589e\u8d26\u6237\u5206\u7c7b"}),a.map((e=>(0,xe.jsx)(Oe,{value:e.key,children:`${e.key.slice(0,e.key.indexOf(":"))}:${e.name}`},e.key)))]})}),"Undefined"===r?(0,xe.jsx)(le.A.Item,{name:"accountTypeName",label:"\u5206\u7c7b\u540d\u79f0",rules:[{required:!0}],children:(0,xe.jsx)(de.A,{placeholder:"\u8d26\u6237\u5206\u7c7b\u7684\u540d\u79f0\uff0c\u5982\u8d2d\u7269\uff0c\u7f8e\u98df\uff0c\u8ba2\u9605"})}):(0,xe.jsx)(le.A.Item,{name:"date",label:"\u65e5\u671f",rules:[{required:!0}],children:(0,xe.jsx)(de.A,{type:"date",placeholder:"\u65f6\u95f4"})}),"Undefined"===r?(0,xe.jsx)(le.A.Item,{name:"accountType",label:"\u8d26\u6237\u5206\u7c7b",rules:[{required:!0}],children:(0,xe.jsx)(de.A,{addonBefore:(0,xe.jsxs)(j.A,{defaultValue:o,onChange:this.handleChangeAccountTypePrefix,children:[(0,xe.jsx)(Oe,{value:"Assets",children:"\u8d44\u4ea7"}),(0,xe.jsx)(Oe,{value:"Income",children:"\u6536\u5165"}),(0,xe.jsx)(Oe,{value:"Expenses",children:"\u652f\u51fa"}),(0,xe.jsx)(Oe,{value:"Liabilities",children:"\u8d1f\u503a"}),(0,xe.jsx)(Oe,{value:"Equity",children:"\u6743\u76ca"})]}),placeholder:"\u8d26\u6237\u5206\u7c7b\uff0c\u5982 Shopping"})}):(0,xe.jsx)(le.A.Item,{name:"account",label:"\u8d26\u6237",rules:[{required:!0}],children:(0,xe.jsx)(de.A,{placeholder:"\u8d26\u6237\u540d\u79f0\uff0c\u5982 ICBC:\u5de5\u5546\u94f6\u884c",addonBefore:r,onChange:this.handleEditAccountInput})}),"Undefined"!==r&&(0,xe.jsx)(le.A.Item,{name:"currency",label:"\u5e01\u79cd",rules:[{required:!0}],initialValue:this.props.commodity.currency,children:(0,xe.jsx)(de.A,{placeholder:"\u8d26\u6237\u4f7f\u7528\u7684\u8d27\u5e01\u5355\u4f4d"})}),(0,xe.jsx)(le.A.Item,{children:(0,xe.jsx)(re.A,{type:"primary",htmlType:"submit",loading:t,className:"submit-button",children:"\u6dfb\u52a0\u8d26\u6237"})})]})}),(0,xe.jsx)("div",{children:(0,xe.jsxs)(te.A,{defaultActiveKey:"Assets",children:[(0,xe.jsx)(Me,{tab:"\u8d44\u4ea7\u8d26\u6237",children:(0,xe.jsx)(Re,{loading:t,...this.props,hideMoney:this.state.hideMoney,accounts:e.filter((e=>"Assets"===(0,ve.b9)(e.account))),onEdit:this.handleOpenAccountDrawer,onAddTransaction:this.handleOpenAddTransactionDrawer})},"1"),(0,xe.jsx)(Me,{tab:"\u6536\u5165\u8d26\u6237",children:(0,xe.jsx)(Re,{loading:t,...this.props,hideMoney:this.state.hideMoney,accounts:e.filter((e=>"Income"===(0,ve.b9)(e.account))),onEdit:this.handleOpenAccountDrawer,onAddTransaction:this.handleOpenAddTransactionDrawer})},"Income"),(0,xe.jsx)(Me,{tab:"\u652f\u51fa\u8d26\u6237",children:(0,xe.jsx)(Re,{loading:t,...this.props,hideMoney:this.state.hideMoney,accounts:e.filter((e=>"Expenses"===(0,ve.b9)(e.account))),onEdit:this.handleOpenAccountDrawer,onAddTransaction:this.handleOpenAddTransactionDrawer})},"Expenses"),(0,xe.jsx)(Me,{tab:"\u8d1f\u503a\u8d26\u6237",children:(0,xe.jsx)(Re,{loading:t,...this.props,hideMoney:this.state.hideMoney,accounts:e.filter((e=>"Liabilities"===(0,ve.b9)(e.account))),onEdit:this.handleOpenAccountDrawer,onAddTransaction:this.handleOpenAddTransactionDrawer})},"Liabilities"),(0,xe.jsx)(Me,{tab:"\u6743\u76ca\u8d26\u6237",children:(0,xe.jsx)(Re,{loading:t,...this.props,hideMoney:this.state.hideMoney,accounts:e.filter((e=>"Equity"===(0,ve.b9)(e.account))),onEdit:this.handleOpenAccountDrawer,onAddTransaction:this.handleOpenAddTransactionDrawer})},"Equity")]})}),(0,xe.jsxs)("div",{children:[(0,xe.jsx)(oe.A,{title:`\u6838\u7b97\u8d26\u6237\uff1a${this.state.balanceAccount}`,placement:"bottom",closable:!0,onClose:this.handleCloseBalanceDrawer,open:s,className:"page-drawer",height:"60vh",bodyStyle:{display:"flex",justifyContent:"center"},children:(0,xe.jsxs)(le.A,{name:"balance-account-form",className:"page-form",size:"large",style:{textAlign:"left"},ref:this.balanceFormRef,onFinish:this.handleBalanceAccount,validateMessages:ze,children:[(0,xe.jsx)(le.A.Item,{name:"date",rules:[{required:!0}],children:(0,xe.jsx)(de.A,{type:"date",placeholder:"\u65f6\u95f4"})}),(0,xe.jsx)(le.A.Item,{name:"number",rules:[{required:!0}],children:(0,xe.jsx)(de.A,{type:"number",step:"0.01",placeholder:"\u91d1\u989d",addonAfter:this.state.editAccount.currency})}),(0,xe.jsx)(le.A.Item,{children:(0,xe.jsx)(he.A,{type:"info",message:"\u6838\u7b97\u8d26\u6237\u524d\uff0c\u8bf7\u786e\u4fdd Equity:OpeningBalances \u8d26\u6237\u5b58\u5728",showIcon:!0})}),(0,xe.jsx)(le.A.Item,{children:(0,xe.jsx)(re.A,{type:"primary",htmlType:"submit",loading:t,className:"submit-button",children:"\u6838\u7b97"})})]})}),(0,xe.jsx)(oe.A,{title:`\u8d26\u6237\uff1a${this.state.editAccount.account}`,placement:"bottom",closable:!0,onClose:this.handleCloseAccountDrawer,open:l,className:"page-drawer",height:"60vh",bodyStyle:{display:"flex",justifyContent:"center"},children:(0,xe.jsxs)("div",{className:"page-form",children:[(0,xe.jsx)(ue.A,{style:{display:"block"},name:"file",action:`/api/auth/account/icon?account=${d.account}`,headers:{ledgerId:window.localStorage.getItem("ledgerId")},onChange:this.handleChangeFile,children:(0,xe.jsx)(re.A,{size:"large",loading:t,icon:(0,xe.jsx)(g.A,{}),style:{width:"100%"},children:"\u66f4\u6362ICON"})}),(0,xe.jsx)("div",{style:{height:"1rem"}}),(0,xe.jsx)(re.A,{size:"large",style:{width:"100%"},onClick:this.handleOpenTransactionDrawer,children:"\u4ea4\u6613\u8bb0\u5f55"}),(0,xe.jsx)("div",{style:{height:"1rem"}}),(0,xe.jsx)(re.A,{size:"large",style:{width:"100%"},onClick:this.handleOpenBalanceDrawer,children:"\u6838\u7b97\u8d26\u6237"}),!this.state.editAccountDiffCommodity&&(0,xe.jsxs)(Ae.Fragment,{children:[(0,xe.jsx)("div",{style:{height:"1rem"}}),(0,xe.jsx)(re.A,{size:"large",style:{width:"100%"},onClick:this.handleOpenSyncPriceDrawer,children:"\u540c\u6b65\u51c0\u503c/\u6c47\u7387"})]}),(0,xe.jsx)("div",{style:{height:"1rem"}}),(0,xe.jsx)(re.A,{size:"large",type:"danger",loading:t,className:"submit-button",onClick:this.handleCloseAccount,children:"\u5173\u95ed\u8d26\u6237"})]})})]}),(0,xe.jsx)(je.A,{account:this.state.editAccount.account,visible:h,onClose:this.handleCloseTransactionDrawer}),(0,xe.jsx)(ge,{account:this.state.editAccount,visible:y,onClose:this.handleCloseSyncPriceDrawer}),(0,xe.jsx)(De,{visible:this.state.commodityPriceDrawerVisible,onClose:this.handleCloseCommodityPriceDrawer}),(0,xe.jsx)(Ee,{visible:this.state.multiCommodityDrawerVisible,sysCurrency:this.props.commodity.currency,onClose:this.handleCloseMultiCommodityDrawer}),(0,xe.jsx)(Ne.A,{...this.props,defaultAccounts:this.state.addTransactionAccount?[this.state.addTransactionAccount]:null,visible:this.state.addTransactionDrawerVisible,onClose:this.handleCloseAddTransactionDrawer,onSubmit:this.handleAfterAddTransaction})]})}}qe.contextType=Te.A;const $e=(0,ke.A)(qe)},1516:(e,t,n)=>{"use strict";n.d(t,{A:()=>M});var s=n(8168),a=n(5544),c=n(4467),i=n(9335),r=n(5185),o=n(5252),l=n(8943),d=n(5691),h=n(8994),u=n(8380),p=n(9708),m=n(8713),y=n(4480),A=n.n(y),f=n(7285),v=n(9284),x=n(3135),b=n(4923),C=n(7458),g=n(3029),j=n(2901),w=n(6822),S=n(2176),D=n(3954),T=n(5501);const k=function(e){function t(){var e,n,s,a;return(0,g.A)(this,t),n=this,s=t,a=arguments,s=(0,D.A)(s),(e=(0,w.A)(n,(0,S.A)()?Reflect.construct(s,a||[],(0,D.A)(n).constructor):s.apply(n,a))).state={error:void 0,info:{componentStack:""}},e}return(0,T.A)(t,e),(0,j.A)(t,[{key:"componentDidCatch",value:function(e,t){this.setState({error:e,info:t})}},{key:"render",value:function(){var e=this.props,t=e.message,n=e.description,s=e.children,a=this.state,c=a.error,i=a.info,r=i&&i.componentStack?i.componentStack:null,o="undefined"===typeof t?(c||"").toString():t,l="undefined"===typeof n?r:n;return c?v.createElement(M,{type:"error",message:o,description:v.createElement("pre",null,l)}):s}}]),t}(v.Component);var N=function(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(null!=e&&"function"===typeof Object.getOwnPropertySymbols){var a=0;for(s=Object.getOwnPropertySymbols(e);a<s.length;a++)t.indexOf(s[a])<0&&Object.prototype.propertyIsEnumerable.call(e,s[a])&&(n[s[a]]=e[s[a]])}return n},I={success:i.A,info:p.A,error:o.A,warning:h.A},P={success:r.A,info:m.A,error:l.A,warning:u.A},E=function(e){var t=e.description,n=e.icon,s=e.prefixCls,a=e.type,i=(t?P:I)[a]||null;return n?(0,C.fx)(n,v.createElement("span",{className:"".concat(s,"-icon")},n),(function(){return{className:A()("".concat(s,"-icon"),(0,c.A)({},n.props.className,n.props.className))}})):v.createElement(i,{className:"".concat(s,"-icon")})},O=function(e){var t=e.isClosable,n=e.closeText,s=e.prefixCls,a=e.closeIcon,c=e.handleClose;return t?v.createElement("button",{type:"button",onClick:c,className:"".concat(s,"-close-icon"),tabIndex:0},n?v.createElement("span",{className:"".concat(s,"-close-text")},n):a):null},V=function(e){var t=e.description,n=e.prefixCls,i=e.message,r=e.banner,o=e.className,l=void 0===o?"":o,h=e.style,u=e.onMouseEnter,p=e.onMouseLeave,m=e.onClick,y=e.afterClose,C=e.showIcon,g=e.closable,j=e.closeText,w=e.closeIcon,S=void 0===w?v.createElement(d.A,null):w,D=e.action,T=N(e,["description","prefixCls","message","banner","className","style","onMouseEnter","onMouseLeave","onClick","afterClose","showIcon","closable","closeText","closeIcon","action"]),k=v.useState(!1),I=(0,a.A)(k,2),P=I[0],V=I[1],M=v.useRef(),z=v.useContext(x.QO),R=z.getPrefixCls,q=z.direction,$=R("alert",n),K=function(e){var t;V(!0),null===(t=T.onClose)||void 0===t||t.call(T,e)},F=!!j||g,L=function(){var e=T.type;return void 0!==e?e:r?"warning":"info"}(),Y=!(!r||void 0!==C)||C,B=A()($,"".concat($,"-").concat(L),(0,c.A)((0,c.A)((0,c.A)((0,c.A)({},"".concat($,"-with-description"),!!t),"".concat($,"-no-icon"),!Y),"".concat($,"-banner"),!!r),"".concat($,"-rtl"),"rtl"===q),l),H=(0,b.A)(T);return v.createElement(f.Ay,{visible:!P,motionName:"".concat($,"-motion"),motionAppear:!1,motionEnter:!1,onLeaveStart:function(e){return{maxHeight:e.offsetHeight}},onLeaveEnd:y},(function(e){var n=e.className,a=e.style;return v.createElement("div",(0,s.A)({ref:M,"data-show":!P,className:A()(B,n),style:(0,s.A)((0,s.A)({},h),a),onMouseEnter:u,onMouseLeave:p,onClick:m,role:"alert"},H),Y?v.createElement(E,{description:t,icon:T.icon,prefixCls:$,type:L}):null,v.createElement("div",{className:"".concat($,"-content")},i?v.createElement("div",{className:"".concat($,"-message")},i):null,t?v.createElement("div",{className:"".concat($,"-description")},t):null),D?v.createElement("div",{className:"".concat($,"-action")},D):null,v.createElement(O,{isClosable:!!F,closeText:j,prefixCls:$,closeIcon:S,handleClose:K}))}))};V.ErrorBoundary=k;const M=V},7737:e=>{e.exports=function(e,t,n,s){var a=n?n.call(s,e,t):void 0;if(void 0!==a)return!!a;if(e===t)return!0;if("object"!==typeof e||!e||"object"!==typeof t||!t)return!1;var c=Object.keys(e),i=Object.keys(t);if(c.length!==i.length)return!1;for(var r=Object.prototype.hasOwnProperty.bind(t),o=0;o<c.length;o++){var l=c[o];if(!r(l))return!1;var d=e[l],h=t[l];if(!1===(a=n?n.call(s,d,h,l):void 0)||void 0===a&&d!==h)return!1}return!0}}}]);