| | |
| | | import moment from 'moment' |
| | | import 'moment/locale/zh-cn' |
| | | |
| | | import { toggleIsiframe, initActionPermission } from '@/store/action' |
| | | import { initActionPermission } from '@/store/action' |
| | | import asyncComponent from '@/utils/asyncLoadComponent' |
| | | import NotFount from '@/components/404' |
| | | import options from '@/store/options.js' |
| | |
| | | |
| | | if (index > -1) { |
| | | let activeId = '' |
| | | if (index > 0) { |
| | | if (id !== this.state.activeId) { |
| | | activeId = this.state.activeId |
| | | } else if (index > 0) { |
| | | activeId = tabs[index - 1].MenuID || '' |
| | | } else if (tabs[index]) { |
| | | activeId = tabs[index].MenuID || '' |
| | |
| | | activeId, |
| | | tabviews: tabs |
| | | }) |
| | | |
| | | if (this.props.isiframe) { |
| | | this.props.toggleIsiframe(false) |
| | | } |
| | | |
| | | let node = document.getElementById('root').parentNode.parentNode |
| | | if (node) { |
| | |
| | | } |
| | | } |
| | | |
| | | modifyTabs = (tab, type) => { |
| | | const { tabviews } = this.state |
| | | modifyTabs = (tab, type, fixed) => { |
| | | const { tabviews, activeId } = this.state |
| | | |
| | | if (type === 'plus') { |
| | | if (type === 'plus' && fixed) { |
| | | let _tabs = tabviews.filter(item => item.MenuID !== tab.MenuID) |
| | | let index = _tabs.findIndex(item => item.MenuID === activeId) |
| | | |
| | | this.setState({ |
| | | tabviews: _tabs |
| | | }, () => { |
| | | if (index > -1) { |
| | | _tabs.splice(index + 1, 0, tab) |
| | | } else { |
| | | _tabs.push(tab) |
| | | } |
| | | this.setState({ |
| | | tabviews: _tabs, |
| | | activeId: tab.MenuID |
| | | }) |
| | | }) |
| | | } else if (type === 'plus') { |
| | | if (tabviews.findIndex(item => item.MenuID === tab.MenuID) > -1) { |
| | | let _tabs = tabviews.filter(item => item.MenuID !== tab.MenuID) |
| | | this.setState({ |
| | |
| | | changeTab = (e, menu) => { |
| | | e.stopPropagation() |
| | | // 窗口切换 |
| | | let _isiframe = this.props.isiframe |
| | | if (menu.type === 'iframe') { |
| | | _isiframe = true |
| | | } else { |
| | | _isiframe = false |
| | | } |
| | | |
| | | if (_isiframe !== this.props.isiframe) { |
| | | this.props.toggleIsiframe(_isiframe) |
| | | } |
| | | |
| | | this.setState({ |
| | | activeId: menu.MenuID || '' |
| | |
| | | MKEmitter.addListener('closeTabView', this.closeTabView) |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | |
| | | } |
| | | |
| | | /** |
| | | * @description 组件销毁,清除state更新 |
| | | */ |
| | |
| | | const { tabviews, activeId } = this.state |
| | | |
| | | return ( |
| | | <section id="mk-tabview-wrap" className={'mk-tabview-wrap' + (this.props.collapse ? ' collapsed' : '')}> |
| | | <section id="mk-tabview-wrap" className={'mk-tabview-wrap' + (this.props.collapse ? ' collapsed' : '') + (tabviews && tabviews.length > 0 ? ' hastab' : '')}> |
| | | <div className="content-header"> |
| | | {tabviews && tabviews.length > 0 && |
| | | <Tabs activeKey={activeId}> |
| | |
| | | const mapStateToProps = (state) => { |
| | | return { |
| | | collapse: state.collapse, |
| | | isiframe: state.isiframe |
| | | } |
| | | } |
| | | |
| | | const mapDispatchToProps = (dispatch) => { |
| | | return { |
| | | initActionPermission: (permAction) => dispatch(initActionPermission(permAction)), |
| | | toggleIsiframe: (isiframe) => dispatch(toggleIsiframe(isiframe)) |
| | | initActionPermission: (permAction) => dispatch(initActionPermission(permAction)) |
| | | } |
| | | } |
| | | |