| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import {connect} from 'react-redux' |
| | | import { fromJS } from 'immutable' |
| | | import {Tabs, BackTop, notification} from 'antd' |
| | | import { RedoOutlined, CloseOutlined } from '@ant-design/icons' |
| | |
| | | |
| | | import asyncComponent from '@/utils/asyncLoadComponent' |
| | | import NotFount from '@/components/404' |
| | | import options from '@/store/options.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import Api from '@/api' |
| | | import './index.scss' |
| | |
| | | moment.locale('zh-cn') |
| | | |
| | | class TabViews extends Component { |
| | | static propTpyes = { |
| | | collapse: PropTypes.bool |
| | | } |
| | | |
| | | state = { |
| | | activeId: '', |
| | | tabviews: null, // 标签集 |
| | | tabviews: [], |
| | | iFrameHeight: 0, |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | if (!window.GLOB.mkHS) { |
| | | this.setState({ |
| | | activeId: 'home_page_id', |
| | | tabviews: [{ |
| | | MenuID: 'home_page_id', |
| | | MenuName: '首页', |
| | | type: 'Home' |
| | | }] |
| | | }) |
| | | } |
| | | } |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('modifyTabs', this.modifyTabs) |
| | | MKEmitter.addListener('closeTabView', this.closeTabView) |
| | | } |
| | | |
| | | /** |
| | | * @description 组件销毁,清除state更新 |
| | | */ |
| | | componentWillUnmount () { |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('modifyTabs', this.modifyTabs) |
| | | MKEmitter.removeListener('closeTabView', this.closeTabView) |
| | | } |
| | | |
| | | // 关闭tab页,重新选择显示页 |
| | |
| | | e.stopPropagation() |
| | | window.GLOB.CacheMap = new Map() |
| | | |
| | | if (options.sysType === 'local' && window.GLOB.systemType !== 'production') { |
| | | if (window.GLOB.sysType === 'local' && window.GLOB.systemType !== 'production') { |
| | | let roledefer = new Promise(resolve => { |
| | | Api.getSystemConfig({ |
| | | func: 's_Get_TrdMenu_Role', |
| | |
| | | } |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | if (sessionStorage.getItem('isEditState') !== 'true') { |
| | | this.setState({ |
| | | activeId: 'home_page_id', |
| | | tabviews: [{ |
| | | MenuID: 'home_page_id', |
| | | MenuName: '首页', |
| | | type: 'Home' |
| | | }] |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | activeId: '', |
| | | tabviews: [] |
| | | }) |
| | | } |
| | | } |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('modifyTabs', this.modifyTabs) |
| | | MKEmitter.addListener('closeTabView', this.closeTabView) |
| | | } |
| | | |
| | | /** |
| | | * @description 组件销毁,清除state更新 |
| | | */ |
| | | componentWillUnmount () { |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('modifyTabs', this.modifyTabs) |
| | | MKEmitter.removeListener('closeTabView', this.closeTabView) |
| | | } |
| | | |
| | | render () { |
| | | const { tabviews, activeId } = this.state |
| | | |
| | | return ( |
| | | <section className={'mk-tabview-wrap' + (this.props.collapse ? ' collapsed' : '')}> |
| | | <section id="mk-tabgroup-wrap" className="mk-tabview-wrap"> |
| | | <div className="content-header"> |
| | | {tabviews && tabviews.length > 0 && |
| | | {tabviews.length > 0 && |
| | | <Tabs activeKey={activeId}> |
| | | {tabviews.map(view => { |
| | | return ( |
| | |
| | | } |
| | | } |
| | | |
| | | const mapStateToProps = (state) => { |
| | | return { |
| | | collapse: state.collapse, |
| | | } |
| | | } |
| | | |
| | | const mapDispatchToProps = (dispatch) => { |
| | | return {} |
| | | } |
| | | |
| | | export default connect(mapStateToProps, mapDispatchToProps)(TabViews) |
| | | export default TabViews |