| | |
| | | import PropTypes from 'prop-types' |
| | | import {connect} from 'react-redux' |
| | | import { is, fromJS } from 'immutable' |
| | | import {Tabs, Icon} from 'antd' |
| | | import {Tabs, Icon, ConfigProvider} from 'antd' |
| | | import {modifyTabview, toggleIsiframe} from '@/store/action' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import NotFount from '@/components/404' |
| | | import enUS from 'antd/es/locale/en_US' |
| | | import zhCN from 'antd/es/locale/zh_CN' |
| | | import moment from 'moment' |
| | | import 'moment/locale/zh-cn' |
| | | import './index.scss' |
| | | |
| | | |
| | | let Comps = {} |
| | | |
| | | class Header extends Component { |
| | | static propTpyes = { |
| | | collapse: PropTypes.bool, |
| | | tabviews: PropTypes.array // 标签页数组 |
| | | } |
| | | |
| | | state = { |
| | | selectedTabId: '', // 当前选中tab页面 |
| | | iFrameHeight: 0 |
| | | iFrameHeight: 0, |
| | | locale: (!sessionStorage.getItem('lang') || sessionStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS |
| | | } |
| | | |
| | | handleTabview (menu) { |
| | |
| | | } |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | if (!sessionStorage.getItem('lang') || sessionStorage.getItem('lang') === 'zh-CN') { |
| | | moment.locale('zh-cn') |
| | | } else { |
| | | moment.locale('en') |
| | | } |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | if (nextProps.tabviews && !is(fromJS(this.props.tabviews), fromJS(nextProps.tabviews))) { |
| | | // tab窗口页增加或删除 |
| | |
| | | |
| | | render () { |
| | | return ( |
| | | <section className="flex-container content-box"> |
| | | <div className="content-header"> |
| | | {this.props.tabviews && this.props.tabviews.length > 0 && |
| | | <Tabs activeKey={this.state.selectedTabId}> |
| | | {this.props.tabviews.map(view => { |
| | | return ( |
| | | <Tabs.TabPane |
| | | className="test" |
| | | tab={ |
| | | <span> |
| | | <span className="tab-name" onClick={() => {this.changeTab(view)}}> |
| | | {view.MenuName} |
| | | <section className={'flex-container content-box' + (this.props.collapse ? ' collapsed' : '')}> |
| | | <ConfigProvider locale={this.state.locale}> |
| | | <div className="content-header"> |
| | | {this.props.tabviews && this.props.tabviews.length > 0 && |
| | | <Tabs activeKey={this.state.selectedTabId}> |
| | | {this.props.tabviews.map(view => { |
| | | return ( |
| | | <Tabs.TabPane |
| | | className="test" |
| | | tab={ |
| | | <span> |
| | | <span className="tab-name" onClick={() => {this.changeTab(view)}}> |
| | | {view.MenuName} |
| | | </span> |
| | | <Icon type="close" onClick={() => {this.handleTabview(view)}}/> |
| | | </span> |
| | | <Icon type="close" onClick={() => {this.handleTabview(view)}}/> |
| | | </span> |
| | | } |
| | | key={view.MenuID} |
| | | > |
| | | {this.selectcomponent(view)} |
| | | </Tabs.TabPane> |
| | | ) |
| | | })} |
| | | </Tabs> |
| | | } |
| | | </div> |
| | | } |
| | | key={view.MenuID} |
| | | > |
| | | {this.selectcomponent(view)} |
| | | </Tabs.TabPane> |
| | | ) |
| | | })} |
| | | </Tabs> |
| | | } |
| | | </div> |
| | | </ConfigProvider> |
| | | </section> |
| | | ) |
| | | } |
| | |
| | | const mapStateToProps = (state) => { |
| | | return { |
| | | tabviews: state.tabviews, |
| | | collapse: state.collapse, |
| | | isiframe: state.isiframe |
| | | } |
| | | } |