import{r as e,s,o as t,j as a}from"./app-eaa32a4a.js";import{f as i,S as r,t as o,n as l,g as d,u as n,i as m}from"./local-bd07797b.js";import{C as c}from"./index-fae09989.js";import{C as h}from"./index-a5b8701f.js";import{C as p}from"./index-fbd6c2c0.js";import{S as u,a as _}from"./submit-0e3cabc6.js";import{S as v}from"./trade-8bf27581.js";import{i as j}from"./dom-ce105537.js";import{D as y}from"./index-949930cc.js";import"./auth-e5508dcf.js";import"./Dialog-c56752ef.js";const f="user_ids",x="symbols";class g 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=[f,x,v.spot_strategy_id,v.direction,v.order_type];if(!i(e,this.state))return void s("请填写必填项");if("LIMIT"===this.state[v.order_type]&&!this.state[v.limit_price])return void s("限价单价格必填");let a=null;try{a=t();0==(await r(this.state)).code&&(s("提交成功","success"),this.onClose()),a&&a.hide()}catch(o){a&&a.hide()}},this.onValueChange=(e,s)=>{s&&this.setState({[s]:e})},this.getStrategy=async()=>{try{const e=await o();0==e.code&&(this.strategyOptions=e.data)}catch(e){}},this.SymbolList=async()=>{try{this.symbolOptions=await l()}catch(e){}},this.onClose=()=>{const{onClose:e}=this.props;e&&e()},this.state={[f]:[],[x]:[],[v.direction]:"",[v.order_type]:"",[v.limit_price]:""},this.symbolOptions=[],this.strategyOptions=[],this.userOptions=d(!0,!1),this.positionSideOptions=n("direction",!1),this.orderTypeOptions=n("order_type",!1)}componentDidMount(){this.getStrategy(),this.SymbolList()}render(){const{visible:e}=this.props,s=this.state;return a.jsx(y,{visible:e,placement:"center",onClose:this.onClose,footer:!1,className:[m()?"trade-dialog__mobile":""].join(" "),children:a.jsxs("div",{className:"custom-trade-form",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(c,{value:s[f],name:f,options:this.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(c,{value:s[x],name:x,options:this.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(c,{value:s[v.spot_strategy_id],name:v.spot_strategy_id,options:this.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(c,{value:s[v.direction],name:v.direction,options:this.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(c,{value:s[v.order_type],name:v.order_type,options:this.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:j("LIMIT"===s[v.order_type])},children:[a.jsx("div",{className:"trade-form-item__label required",children:"限价价格"}),a.jsx("div",{className:"trade-form-item__value",children:a.jsx(h,{type:"number",value:s[v.limit_price],align:"center",name:v.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(p,{icon:a.jsx(u,{}),onClick:this.onReset,children:"重置"}),a.jsx(p,{icon:a.jsx(_,{}),onClick:this.onSubmit,children:"提交"})]})})})]})})}}export{g as default};
