ListTab.js 1.7 KB
Newer Older
王绍森's avatar
王绍森 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
import React, { Component, Fragment } from 'react';
import { Tabs } from 'antd';
import styles from '@/baseComponent/index.less';
import PropTypes from 'prop-types';
import Shell from '@/baseComponent/Shell';
import List from './List';

const TabPane = Tabs.TabPane;

export default class ListTab extends Component {
  constructor(props) {
    super(props);
    const { tabList } = this.props;
    const tabKeys = Object.keys(tabList);
    this.state = {
      activeKey: tabKeys[0],
      tabKeys: tabKeys,
    };
  }

  handleChangeTab = (activeKey) => {

    this.setState({
      activeKey: '-111111',
    },()=>{
      setTimeout(()=>{
        this.setState({
          activeKey: activeKey,
        })
      } ,30);
    });
  };

  render() {
    const { tabList, pageSearch, pageButton, workId, dataBaseId, addFields } = this.props;
    const { activeKey, tabKeys } = this.state;
    return (
      <Fragment>
        <Shell>
          <Tabs activeKey={activeKey}
                className={styles.ListTab}
                onChange={this.handleChangeTab}>
            {tabKeys.map((item) => {
             return <TabPane tab={tabList[item].name} key={item}>

              </TabPane>
            })}
          </Tabs>
        </Shell>
        {tabKeys.map((item) => {
            return activeKey === item ?
              <List listConfig={tabList[item].listConfig}
                    key={item}
                    workId={workId}
                    addFields={addFields}
                    dataBaseId={dataBaseId}
                    pageSearch={pageSearch[item]}
                    pageButton={pageButton[item]}
              /> : null;

          })}
      </Fragment>
    );
  }
}

ListTab.propTypes = {};

ListTab.defaultProps = {};