import{r as e,j as s}from"./app-61e75031.js";import{f as t,S as a,q as i,r,g as o,t as l,i as d}from"./local-95ab843f.js";import{C as m}from"./index-0af180fb.js";import{C as n}from"./index-1db4bfc2.js";import{C as c}from"./index-33422928.js";import{S as h,a as p}from"./submit-fbaa0812.js";import{S as u}from"./trade-8bf27581.js";import{s as _,o as v}from"./auth-db23b820.js";import{i as j}from"./dom-ce105537.js";import{D as y}from"./index-d8c9eb3f.js";import"./Dialog-8239776d.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,u.spot_strategy_id,u.direction,u.order_type];if(!t(e,this.state))return void _("请填写必填项");if("LIMIT"===this.state[u.order_type]&&!this.state[u.limit_price])return void _("限价单价格必填");let s=null;try{s=v();0==(await a(this.state)).code&&(_("提交成功","success"),this.onClose()),s&&s.hide()}catch(i){s&&s.hide()}},this.onValueChange=(e,s)=>{s&&this.setState({[s]:e})},this.getStrategy=async()=>{try{const e=await i();0==e.code&&(this.strategyOptions=e.data)}catch(e){}},this.SymbolList=async()=>{try{this.symbolOptions=await r()}catch(e){}},this.onClose=()=>{const{onClose:e}=this.props;e&&e()},this.state={[f]:[],[x]:[],[u.direction]:"",[u.order_type]:"",[u.limit_price]:""},this.symbolOptions=[],this.strategyOptions=[],this.userOptions=o(!0,!1),this.positionSideOptions=l("direction",!1),this.orderTypeOptions=l("order_type",!1)}componentDidMount(){this.getStrategy(),this.SymbolList()}render(){const{visible:e}=this.props,t=this.state;return s.jsx(y,{visible:e,placement:"center",onClose:this.onClose,footer:!1,className:[d()?"trade-dialog__mobile":""].join(" "),children:s.jsxs("div",{className:"custom-trade-form",children:[s.jsxs("div",{className:"trade-form-item",children:[s.jsx("div",{className:"trade-form-item__label required",children:"用户"}),s.jsx("div",{className:"trade-form-item__value",children:s.jsx(m,{value:t[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})})]}),s.jsxs("div",{className:"trade-form-item",children:[s.jsx("div",{className:"trade-form-item__label required",children:"交易对"}),s.jsx("div",{className:"trade-form-item__value",children:s.jsx(m,{value:t[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})})]}),s.jsxs("div",{className:"trade-form-item",children:[s.jsx("div",{className:"trade-form-item__label",children:"策略"}),s.jsx("div",{className:"trade-form-item__value",children:s.jsx(m,{value:t[u.spot_strategy_id],name:u.spot_strategy_id,options:this.strategyOptions,className:"trade-dialog-select",clearable:!0,autoWidth:!1,popupProps:{overlayClassName:"trade-dialog-select__overlay"},onChange:this.onValueChange})})]}),s.jsxs("div",{className:"trade-form-item",children:[s.jsx("div",{className:"trade-form-item__label required",children:"买卖类型"}),s.jsx("div",{className:"trade-form-item__value",children:s.jsx(m,{value:t[u.direction],name:u.direction,options:this.positionSideOptions,className:"trade-dialog-select",clearable:!0,autoWidth:!1,popupProps:{overlayClassName:"trade-dialog-select__overlay"},onChange:this.onValueChange})})]}),s.jsxs("div",{className:"trade-form-item",children:[s.jsx("div",{className:"trade-form-item__label required",children:"交易类型"}),s.jsx("div",{className:"trade-form-item__value",children:s.jsx(m,{value:t[u.order_type],name:u.order_type,options:this.orderTypeOptions,className:"trade-dialog-select",clearable:!0,autoWidth:!1,popupProps:{overlayClassName:"trade-dialog-select__overlay"},onChange:this.onValueChange})})]}),s.jsxs("div",{className:"trade-form-item",style:{display:j("LIMIT"===t[u.order_type])},children:[s.jsx("div",{className:"trade-form-item__label required",children:"限价价格"}),s.jsx("div",{className:"trade-form-item__value",children:s.jsx(n,{type:"number",value:t[u.limit_price],align:"center",name:u.limit_price,onChange:this.onValueChange})})]}),s.jsx("div",{className:"trade-form-item",children:s.jsx("div",{className:"trade-form-item__value",children:s.jsxs("div",{className:"trade-form-submit",children:[s.jsx(c,{icon:s.jsx(h,{}),onClick:this.onReset,children:"重置"}),s.jsx(c,{icon:s.jsx(p,{}),onClick:this.onSubmit,children:"提交"})]})})})]})})}}export{g as default};
