ListTab.js 1.6 KB
Newer Older
王绍森's avatar
王绍森 committed
1 2 3 4 5 6 7 8 9 10
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 {
11 12 13 14 15 16 17 18 19
	constructor(props) {
		super(props);
		const { tabList } = this.props;
		const tabKeys = Object.keys(tabList);
		this.state = {
			activeKey: tabKeys[0],
			tabKeys: tabKeys,
		};
	}
王绍森's avatar
王绍森 committed
20

21 22 23 24 25 26 27 28 29 30 31 32 33 34
	handleChangeTab = (activeKey) => {
		this.setState(
			{
				activeKey: '-111111',
			},
			() => {
				setTimeout(() => {
					this.setState({
						activeKey: activeKey,
					});
				}, 30);
			},
		);
	};
王绍森's avatar
王绍森 committed
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 71 72 73
	render() {
		const {
			tabList,
			pageSearch,
			pageButton,
			workId,
			dataBaseId,
			addFields,
			searchCondition,
		} = this.props;
		const { activeKey, tabKeys } = this.state;
		return (
			<Fragment>
				<Shell styleShell={{ marginTop: 0 }}>
					{/*<SearchDom />*/}
					<Tabs activeKey={activeKey} className={styles.ListTab} onChange={this.handleChangeTab}>
						{tabKeys.map((item) => {
							return <TabPane tab={tabList[item].name} key={item} />;
						})}
					</Tabs>
				</Shell>
				{tabKeys.map((item) => {
					return activeKey === item ? (
						<List
							listConfig={tabList[item].listConfig}
							key={item}
							workId={workId}
							addFields={addFields}
							searchCondition={searchCondition}
							dataBaseId={dataBaseId}
							pageSearch={pageSearch[item]}
							pageButton={pageButton[item]}
						/>
					) : null;
				})}
			</Fragment>
		);
	}
王绍森's avatar
王绍森 committed
74 75 76 77 78
}

ListTab.propTypes = {};

ListTab.defaultProps = {};