| | |
| | | state = { |
| | | tabs: null, |
| | | parentIds: [], |
| | | bids: {} |
| | | bids: {}, |
| | | activeIndex: 1 |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { config } = this.props |
| | | |
| | | if (config.setting.autoSwitch === 'true' && config.subtabs.length > 1 && config.setting.interval) { |
| | | this.autoSwitch(config.setting.interval) |
| | | } |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | }) |
| | | } |
| | | |
| | | autoSwitch = (interval) => { |
| | | const { tabs, activeIndex } = this.state |
| | | |
| | | if (!tabs) return |
| | | |
| | | let index = activeIndex |
| | | |
| | | if (!tabs.subtabs[index]) { |
| | | index = 0 |
| | | } |
| | | |
| | | let id = 'tab' + tabs.subtabs[index].uuid |
| | | |
| | | this.setState({activeIndex: ++index}) |
| | | |
| | | setTimeout(() => { |
| | | let node = document.getElementById(id) |
| | | if (node) { |
| | | node.click() |
| | | this.autoSwitch(interval) |
| | | } |
| | | }, interval * 1000) |
| | | } |
| | | |
| | | render() { |
| | | const { mainSearch, BID } = this.props |
| | | const { tabs, bids } = this.state |
| | | |
| | | return ( |
| | | <div className="menu-antv-tabs-wrap" style={tabs.style}> |
| | | <div className={'menu-antv-tabs-wrap ' + tabs.setting.tabLabel} style={tabs.style}> |
| | | <Tabs defaultActiveKey="1" tabPosition={tabs.setting.position} type={tabs.setting.tabStyle}> |
| | | {tabs.subtabs.map(tab => ( |
| | | <TabPane tab={<span id={'tab' + tab.uuid}>{tab.icon ? <Icon type={tab.icon} /> : null}{tab.label}</span>} key={tab.uuid}> |