import{r as t,s as e,j as s}from"./app-a12cf07d.js";import i from"./index-ec1e97f4.js";import a from"./index-d8d2c40b.js";import r from"./index-9a9fca5f.js";import{g as n,i as o}from"./dom-ce105537.js";import{t as l,a as u,b as h}from"./trade-8bf27581.js";import c from"./index-6c72fcb5.js";import{b as d,i as p}from"./local-6367da78.js";import{C as m}from"./index-34595b79.js";import{C as b}from"./multipleUse-a63bb38b.js";import g from"./index-e2b04dbb.js";import"./index-3e8617f2.js";import"./index-6dbbb2c5.js";import"./auth-d668f6b9.js";import"./trade-281a8bb7.js";import"./index-49b11c8b.js";import"./index-85d1a89a.js";import"./index-49740479.js";import"./index-0a85991c.js";import"./submit-75ff44aa.js";const j="contract-trade",x="start-trade";class f extends t.Component{constructor(t){super(t),this.changeTableStatus=t=>{const e=Object.keys(this.state.tableStatus);for(let s=0;s<e.length;s++){const i=e[s];if(i===t){this.state.tableStatus[i]||(this.state.tableStatus[i]=!0);break}}},this.changeGroupButton=t=>{this.changeTableStatus(t),this.setState({currentGroupButton:t});const e=this.tradeSelectRef.getFilterParams(t);this.setState({filter:e}),"1"===t?this.holdingPositionRef.getTableList(e):"2"===t?this.currentConsignment.getTableList(e):"3"===t&&this.historyTransaction.getTableList(e)},this.getTableHeight=()=>{const t=document.getElementById(j);if(t){const e=n(t),s=document.documentElement.clientHeight-e.top;this.setState({minHeight:s+"px"})}},this.storeChange=()=>{e.dispatch({type:"count",data:1})},this.onCancelEntrust=()=>{this.currentConsignment.tableContractRevoke()},this.FilterChange=t=>{this.setState({filter:t}),this.getChildTableList(t)},this.getChildTableList=t=>{"1"===this.state.currentGroupButton?this.holdingPositionRef.getTableList(t):"2"===this.state.currentGroupButton?this.currentConsignment.getTableList(t):"3"===this.state.currentGroupButton&&this.historyTransaction.getTableList(t)},this.updateTotal=t=>{this.setState({currentEntrustNum:t})},this.state={dialog_visible:!1,minHeight:"",currentEntrustNum:0,currentGroupButton:"4",tableStatus:{[x]:!0,[l]:!1,[u]:!1,[h]:!1},filter:{},HelpData:{}}}get ComputedGroupButtons(){return[{label:"开始交易",value:"4"},{label:"持有仓位",value:"1"},{label:`当前委托(${this.state.currentEntrustNum})`,value:"2"},{label:"历史成交",value:"3"}]}async componentDidMount(){this.getTableHeight();const t=await d();t&&this.setState({HelpData:t})}onClosePosition(){b({ids:[]})}getTableClass(){return["spread-out-table",p()?"spread-out-table__mobile":""].join(" ")}currentExtensionButtons(){switch(this.state.currentGroupButton){case l:return s.jsx("div",{className:"hold-position-extension",children:s.jsx(m,{onClick:this.onClosePosition,children:"一键平仓"})});case u:return s.jsx("div",{className:"hold-position-extension",children:s.jsx(m,{onClick:this.onCancelEntrust,children:"多选撤销"})});case h:return""}}render(){return e.getState(),s.jsxs("div",{className:"contract-trade-table",id:this.props.id,style:this.props.style,children:[s.jsx("div",{className:"contract-trade-label",children:"合约交易"}),s.jsx("div",{className:"contract-trade-group",children:this.ComputedGroupButtons.map(((t,e)=>s.jsx("div",{className:t.value===this.state.currentGroupButton?"group-active":"",onClick:this.changeGroupButton.bind(this,t.value),children:t.label},t.value)))}),s.jsx(c,{ref:t=>this.tradeSelectRef=t,FilterChange:this.FilterChange,currentGroupButton:this.state.currentGroupButton,children:this.currentExtensionButtons()}),s.jsxs("div",{className:["contract-trade-table-box",p()?"contract-trade-table__mobile":""].join(" "),id:j,style:{minHeight:this.state.minHeight},children:[s.jsx(g,{"v-if":this.state.tableStatus[x],className:this.getTableClass(),HelpData:this.state.HelpData,style:{display:o("4"===this.state.currentGroupButton)}}),s.jsx(i,{"v-if":this.state.tableStatus[l],className:this.getTableClass(),ref:t=>this.holdingPositionRef=t,style:{display:o(this.state.currentGroupButton===l)}}),s.jsx(a,{"v-if":this.state.tableStatus[u],className:this.getTableClass(),filterParams:this.state.filter,ref:t=>this.currentConsignment=t,style:{display:o(this.state.currentGroupButton===u)},updateTotal:this.updateTotal}),s.jsx(r,{"v-if":this.state.tableStatus[h],className:this.getTableClass(),ref:t=>this.historyTransaction=t,style:{display:o(this.state.currentGroupButton===h)}})]})]})}}export{f as default};
