king
2021-10-12 2b4b1ecca5b6170bcbf3364b7ea81a248d0d6593
src/tabviews/custom/components/tabs/antv-tabs/index.jsx
@@ -22,7 +22,8 @@
  state = {
    tabs: null,
    parentIds: [],
    bids: {}
    bids: {},
    activeIndex: 1
  }
  UNSAFE_componentWillMount () {
@@ -39,7 +40,13 @@
  }
  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)
  }
  /**
@@ -62,12 +69,36 @@
    })
  }
  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}>