| | |
| | | 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 { Tabs, BackTop, notification, Modal } from 'antd' |
| | | import { RedoOutlined, CloseOutlined, LoadingOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | import 'moment/locale/zh-cn' |
| | | |
| | | 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: [], |
| | | iFrameHeight: 0, |
| | | visible: false |
| | | } |
| | | |
| | | reloading = false |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | if (!window.GLOB.mkHS) { |
| | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('modifyTabs', this.modifyTabs) |
| | | MKEmitter.addListener('closeTabView', this.closeTabView) |
| | | |
| | | if (window.GLOB.forcedUpdate) { |
| | | MKEmitter.addListener('reloadTabs', this.reloadTabs) |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('modifyTabs', this.modifyTabs) |
| | | MKEmitter.removeListener('reloadTabs', this.reloadTabs) |
| | | MKEmitter.removeListener('closeTabView', this.closeTabView) |
| | | } |
| | | |
| | |
| | | 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', |
| | |
| | | } else { |
| | | MKEmitter.emit('reloadMenuView', menu.MenuID) |
| | | } |
| | | } |
| | | |
| | | reloadTabs = () => { |
| | | if (this.reloading) return |
| | | |
| | | this.reloading = true |
| | | let time = new Date().getTime() |
| | | |
| | | this.setState({visible: true}) |
| | | |
| | | Api.getAppVersion(true).then((list) => { |
| | | let _time = new Date().getTime() |
| | | let delay = _time - time |
| | | delay = delay < 3000 ? 3000 - delay : 0 |
| | | |
| | | setTimeout(() => { |
| | | this.setState({visible: false}) |
| | | this.reloading = false |
| | | |
| | | Modal.success({ |
| | | title: '更新成功。', |
| | | }) |
| | | |
| | | if (list && list.length) { |
| | | let _tabIds = this.state.tabviews.map(item => item.MenuID) |
| | | list.forEach((m, i) => { |
| | | if (_tabIds.includes(m)) { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('reloadMenuView', m) |
| | | }, i * 20) |
| | | } |
| | | }) |
| | | } |
| | | }, delay) |
| | | }, (message) => { |
| | | let _time = new Date().getTime() |
| | | let delay = _time - time |
| | | delay = delay < 3000 ? 3000 - delay : 0 |
| | | |
| | | setTimeout(() => { |
| | | this.setState({visible: false}) |
| | | this.reloading = false |
| | | Modal.error({ |
| | | title: message || '系统配置更新失败!', |
| | | }) |
| | | }, delay) |
| | | }) |
| | | } |
| | | |
| | | modifyTabs = (tab, fixed) => { |
| | |
| | | } |
| | | |
| | | render () { |
| | | const { tabviews, activeId } = this.state |
| | | const { tabviews, activeId, visible } = this.state |
| | | |
| | | return ( |
| | | <section id="mk-tabgroup-wrap" className={'mk-tabview-wrap' + (this.props.collapse ? ' collapsed' : '')}> |
| | | <section id="mk-tabgroup-wrap" className="mk-tabview-wrap"> |
| | | <div className="content-header"> |
| | | {tabviews.length > 0 && |
| | | <Tabs activeKey={activeId}> |
| | |
| | | </Tabs> |
| | | } |
| | | </div> |
| | | <Modal |
| | | visible={visible} |
| | | width={400} |
| | | closable={false} |
| | | centered={true} |
| | | footer={null} |
| | | destroyOnClose |
| | | > |
| | | <div className="mk-menus-update"> |
| | | <div className="tip"> |
| | | 系统更新中,请稍后 |
| | | </div> |
| | | <LoadingOutlined /> |
| | | </div> |
| | | </Modal> |
| | | </section> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | const mapStateToProps = (state) => { |
| | | return { |
| | | collapse: state.collapse, |
| | | } |
| | | } |
| | | |
| | | const mapDispatchToProps = (dispatch) => { |
| | | return {} |
| | | } |
| | | |
| | | export default connect(mapStateToProps, mapDispatchToProps)(TabViews) |
| | | export default TabViews |