import{r as e,j as s}from"./app-61e75031.js";import{f as t,S as a,s as i,E as r,q as o,r as l,g as d,t as m,p as n}from"./local-95ab843f.js";import{C as c}from"./index-0af180fb.js";import{C as h}from"./index-1db4bfc2.js";import{C as p}from"./index-33422928.js";import{S as u,a as _}from"./submit-fbaa0812.js";import{S as v}from"./trade-8bf27581.js";import{s as y,o as j}from"./auth-db23b820.js";import{i as f}from"./dom-ce105537.js";const x="user_ids",g="symbols";class N 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=[x,g,v.spot_strategy_id,v.direction,v.order_type];if(!t(e,this.state))return void y("请填写必填项");if("LIMIT"===this.state[v.order_type]&&!this.state[v.limit_price])return void y("限价单价格必填");let s=null;try{s=j();0==(await a(this.state)).code&&(y("提交成功","success"),i(r,this.state)),s&&s.hide()}catch(o){s&&s.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.state=n(r)||{[x]:[],[g]:[],[v.direction]:"",[v.order_type]:"",[v.limit_price]:""},this.symbolOptions=[],this.strategyOptions=[],this.userOptions=d(!0,!1),this.positionSideOptions=m("direction",!1),this.orderTypeOptions=m("order_type",!1)}componentDidMount(){this.getStrategy(),this.SymbolList()}currentElement(){const e=this.state;return s.jsxs("div",{className:"custom-trade-form",style:this.props.style,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(c,{value:e[x],name:x,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(c,{value:e[g],name:g,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(c,{value:e[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})})]}),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(c,{value:e[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})})]}),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(c,{value:e[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})})]}),s.jsxs("div",{className:"trade-form-item",style:{display:f("LIMIT"===e[v.order_type])},children:[s.jsx("div",{className:"trade-form-item__label required",children:"限价价格"}),s.jsx("div",{className:"trade-form-item__value",children:s.jsx(h,{type:"number",value:e[v.limit_price],align:"center",name:v.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(p,{icon:s.jsx(u,{}),onClick:this.onReset,children:"重置"}),s.jsx(p,{icon:s.jsx(_,{}),onClick:this.onSubmit,children:"提交"})]})})})]})}render(){return this.props["v-if"]?this.currentElement():s.jsx(s.Fragment,{})}}export{N as default};
