import{r as e,s,o as t,j as a}from"./app-eaa32a4a.js";import{f as i,o as r,p as o,S as l,s as d,F as n,t as m,n as c,r as p,g as h,u}from"./local-bd07797b.js";import{C as _}from"./index-fae09989.js";import{C as y}from"./index-a5b8701f.js";import{C as v}from"./index-fbd6c2c0.js";import{S as j,a as f}from"./submit-0e3cabc6.js";import{S as g}from"./trade-8bf27581.js";import{i as x}from"./dom-ce105537.js";import"./auth-e5508dcf.js";const N="user_ids",b="symbols",C=["symbolOptions","strategyOptions","userOptions","positionSideOptions","orderTypeOptions"];class O extends e.Component{constructor(e){super(e),this.onReset=()=>{Object.keys(this.state).forEach((e=>{"string"==typeof this.state[e]?this.setState({[e]:""}):"number"==typeof this.state[e]?this.setState({[e]:0}):this.setState({[e]:[]})}))},this.onSubmit=async()=>{const e=[N,b,g.spot_strategy_id,g.direction,g.order_type];if(!i(e,this.state))return void s("请填写必填项");if("LIMIT"===this.state[g.order_type]&&!this.state[g.limit_price])return void s("限价单价格必填");let a=r(this.state,C);a=o(a);let m=null;try{m=t();0==(await l(a)).code&&(s("提交成功","success"),d(n,a)),m&&m.hide()}catch(c){m&&m.hide()}},this.onValueChange=(e,s)=>{s&&this.setState({[s]:e})},this.getStrategy=async()=>{try{const e=await m();0==e.code&&this.setState({strategyOptions:e.data})}catch(e){}},this.SymbolList=async()=>{try{const e=await c();this.setState({symbolOptions:e})}catch(e){}},this.state=(()=>{let e={};const s=p(n);return e=s||{[N]:[],[b]:[],[g.direction]:"",[g.order_type]:"",[g.limit_price]:""},e.symbolOptions=[],e.strategyOptions=[],e.userOptions=h(!0,!1),e.positionSideOptions=u("direction",!1),e.orderTypeOptions=u("order_type",!1),e})()}componentDidMount(){this.getStrategy(),this.SymbolList()}currentElement(){const e=this.state;return a.jsxs("div",{className:"custom-trade-form",style:this.props.style,children:[a.jsxs("div",{className:"trade-form-item",children:[a.jsx("div",{className:"trade-form-item__label required",children:"用户"}),a.jsx("div",{className:"trade-form-item__value",children:a.jsx(_,{value:e[N],name:N,options:e.userOptions,className:"trade-dialog-select",clearable:!0,multiple:!0,autoWidth:!1,popupProps:{overlayClassName:"trade-dialog-select__overlay"},onChange:this.onValueChange})})]}),a.jsxs("div",{className:"trade-form-item",children:[a.jsx("div",{className:"trade-form-item__label required",children:"交易对"}),a.jsx("div",{className:"trade-form-item__value",children:a.jsx(_,{value:e[b],name:b,options:e.symbolOptions,filterable:!0,className:"trade-dialog-select",clearable:!0,multiple:!0,autoWidth:!1,popupProps:{overlayClassName:"trade-dialog-select__overlay"},onChange:this.onValueChange})})]}),a.jsxs("div",{className:"trade-form-item",children:[a.jsx("div",{className:"trade-form-item__label",children:"策略"}),a.jsx("div",{className:"trade-form-item__value",children:a.jsx(_,{value:e[g.spot_strategy_id],name:g.spot_strategy_id,options:e.strategyOptions,className:"trade-dialog-select",clearable:!0,autoWidth:!1,popupProps:{overlayClassName:"trade-dialog-select__overlay"},onChange:this.onValueChange})})]}),a.jsxs("div",{className:"trade-form-item",children:[a.jsx("div",{className:"trade-form-item__label required",children:"买卖类型"}),a.jsx("div",{className:"trade-form-item__value",children:a.jsx(_,{value:e[g.direction],name:g.direction,options:e.positionSideOptions,className:"trade-dialog-select",clearable:!0,autoWidth:!1,popupProps:{overlayClassName:"trade-dialog-select__overlay"},onChange:this.onValueChange})})]}),a.jsxs("div",{className:"trade-form-item",children:[a.jsx("div",{className:"trade-form-item__label required",children:"交易类型"}),a.jsx("div",{className:"trade-form-item__value",children:a.jsx(_,{value:e[g.order_type],name:g.order_type,options:e.orderTypeOptions,className:"trade-dialog-select",clearable:!0,autoWidth:!1,popupProps:{overlayClassName:"trade-dialog-select__overlay"},onChange:this.onValueChange})})]}),a.jsxs("div",{className:"trade-form-item",style:{display:x("LIMIT"===e[g.order_type])},children:[a.jsx("div",{className:"trade-form-item__label required",children:"限价价格"}),a.jsx("div",{className:"trade-form-item__value",children:a.jsx(y,{type:"number",value:e[g.limit_price],align:"center",name:g.limit_price,onChange:this.onValueChange})})]}),a.jsx("div",{className:"trade-form-item",children:a.jsx("div",{className:"trade-form-item__value",children:a.jsxs("div",{className:"trade-form-submit",children:[a.jsx(v,{icon:a.jsx(j,{}),onClick:this.onReset,children:"重置"}),a.jsx(v,{icon:a.jsx(f,{}),onClick:this.onSubmit,children:"提交"})]})})})]})}render(){return this.props["v-if"]?this.currentElement():a.jsx(a.Fragment,{})}}export{O as default};
