import{r as e,s,o as t,j as a}from"./app-8896f7a4.js";import{f as i,S as r,s as o,F as l,t as d,n as m,g as n,u as c,r as h}from"./local-685d41f4.js";import{C as p}from"./index-287324dd.js";import{C as u}from"./index-ac7476df.js";import{C as _}from"./index-7a8bd1fb.js";import{S as v,a as y}from"./submit-af8b0881.js";import{S as j}from"./trade-8bf27581.js";import{i as f}from"./dom-ce105537.js";import"./auth-6ae50961.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,j.spot_strategy_id,j.direction,j.order_type];if(!i(e,this.state))return void s("请填写必填项");if("LIMIT"===this.state[j.order_type]&&!this.state[j.limit_price])return void s("限价单价格必填");let a=null;try{a=t();0==(await r(this.state)).code&&(s("提交成功","success"),o(l,this.state)),a&&a.hide()}catch(d){a&&a.hide()}},this.onValueChange=(e,s)=>{s&&this.setState({[s]:e})},this.getStrategy=async()=>{try{const e=await d();0==e.code&&(this.strategyOptions=e.data)}catch(e){}},this.SymbolList=async()=>{try{this.symbolOptions=await m()}catch(e){}},this.state=h(l)||{[x]:[],[g]:[],[j.direction]:"",[j.order_type]:"",[j.limit_price]:""},this.symbolOptions=[],this.strategyOptions=[],this.userOptions=n(!0,!1),this.positionSideOptions=c("direction",!1),this.orderTypeOptions=c("order_type",!1)}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(p,{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})})]}),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(p,{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})})]}),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(p,{value:e[j.spot_strategy_id],name:j.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(p,{value:e[j.direction],name:j.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(p,{value:e[j.order_type],name:j.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:f("LIMIT"===e[j.order_type])},children:[a.jsx("div",{className:"trade-form-item__label required",children:"限价价格"}),a.jsx("div",{className:"trade-form-item__value",children:a.jsx(u,{type:"number",value:e[j.limit_price],align:"center",name:j.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(_,{icon:a.jsx(v,{}),onClick:this.onReset,children:"重置"}),a.jsx(_,{icon:a.jsx(y,{}),onClick:this.onSubmit,children:"提交"})]})})})]})}render(){return this.props["v-if"]?this.currentElement():a.jsx(a.Fragment,{})}}export{N as default};
