king
14 小时以前 c06e58c80240afd703d289bb1c584e08b9783383
src/components/breadview/index.jsx
@@ -1,12 +1,11 @@
import React, {Component} from 'react'
import { BackTop, Breadcrumb, notification} from 'antd'
import { HomeOutlined, RightOutlined, RedoOutlined } from '@ant-design/icons'
import { BackTop, Breadcrumb, notification, Modal } from 'antd'
import { HomeOutlined, RightOutlined, RedoOutlined, 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'
@@ -19,19 +18,49 @@
const Iframe = asyncComponent(() => import('@/tabviews/iframe'))
const RoleManage = asyncComponent(() => import('@/tabviews/rolemanage'))
moment.locale('zh-cn')
if (sessionStorage.getItem('lang') === 'zh-CN') {
  moment.locale('zh-cn')
}
class BreadView extends Component {
  state = {
    tabview: null, // 标签
    hasNavBar: window.GLOB.navBar === 'linkage_navigation'
    tabview: null,
    hasNavBar: window.GLOB.navBar === 'linkage_navigation',
    visible: false
  }
  reloading = false
  UNSAFE_componentWillMount () {
    let home = {
      MenuID: 'home_page_id',
      MenuName: window.GLOB.dict['home'] || '首页',
      type: 'Home'
    }
    this.setState({tabview: home})
  }
  componentDidMount () {
    MKEmitter.addListener('modifyTabs', this.modifyTabs)
    MKEmitter.addListener('reloadTabs', this.reloadTabs)
  }
  /**
   * @description 组件销毁,清除state更新
   */
  componentWillUnmount () {
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('reloadTabs', this.reloadTabs)
    MKEmitter.removeListener('modifyTabs', this.modifyTabs)
  }
  refreshTabview = () => {
    const { tabview } = this.state
    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',
@@ -106,19 +135,10 @@
    }
  }
  UNSAFE_componentWillMount () {
    let home = {
      MenuID: 'home_page_id',
      MenuName: '首页',
      type: 'Home'
    }
    this.setState({tabview: home})
  }
  gotoHome = () => {
    let home = {
      MenuID: 'home_page_id',
      MenuName: '首页',
      MenuName: window.GLOB.dict['home'] || '首页',
      type: 'Home'
    }
    this.setState({tabview: home})
@@ -135,25 +155,57 @@
    }
  }
  componentDidMount () {
    MKEmitter.addListener('modifyTabs', this.modifyTabs)
  }
  reloadTabs = () => {
    if (this.reloading) return
  /**
   * @description 组件销毁,清除state更新
   */
  componentWillUnmount () {
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('modifyTabs', this.modifyTabs)
    let time = new Date().getTime()
    let oldTime = sessionStorage.getItem('mk_reloadTabs')
    if (oldTime && time - oldTime < 180000) return
    sessionStorage.setItem('mk_reloadTabs', time)
    this.reloading = true
    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 && list.includes(this.state.tabview.MenuID)) {
          MKEmitter.emit('reloadMenuView', this.state.tabview.MenuID)
        }
      }, 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)
    })
  }
  render () {
    const { tabview, hasNavBar } = this.state
    const { tabview, hasNavBar, visible } = this.state
    return (
      <section id="mk-breadview-wrap" className="mk-breadview-wrap">
      <section id="mk-tabgroup-wrap" className="mk-breadview-wrap">
        {hasNavBar && tabview ? <Breadcrumb separator="">
          <Breadcrumb.Item>
            <HomeOutlined onClick={this.gotoHome} />
@@ -176,6 +228,21 @@
            </div>
          </div>
        </BackTop>
        <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>
    )
  }