king
2020-08-20 3683e1475e8d74f690172a468518d88d91a69ccc
src/components/header/index.jsx
@@ -4,7 +4,7 @@
import {connect} from 'react-redux'
import { is, fromJS } from 'immutable'
import moment from 'moment'
import {Dropdown, Menu, Icon, Modal, Form, notification, Switch, Button, Input } from 'antd'
import { Dropdown, Menu, Icon, Modal, Form, notification, Switch, Button, Input, Badge } from 'antd'
import asyncComponent from '@/utils/asyncComponent'
import {
@@ -55,7 +55,9 @@
    avatar: avatar,
    systems: [],
    searchkey: '',
    thdMenuList: []
    thdMenuList: [],
    oriVersion: '',
    newVersion: ''
  }
  handleCollapse = () => {
@@ -579,7 +581,10 @@
          result.UserRoles.forEach(role => {
            role.RoleMenu.forEach(menu => {
              if (!menu.MenuID) return
              if (menukeys.includes(menu.MenuID)) return
              if (menukeys.includes(menu.MenuID)) {
                console.warn('s_Get_TrdMenu_Role重复的菜单ID:' + menu.MenuID)
                return
              }
              _permMenus[menu.MenuID] = true
              let _type = ''
@@ -630,10 +635,54 @@
        })
      }
    })
    // 获取系统的版本信息
    new Promise((resolve, reject) => {
      Api.getAppVersion(resolve, reject)
    }).then(res => {
      this.setState({
        oriVersion: res.oldVersion,
        newVersion: res.newVersion
      })
    })
  }
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
  }
  verup = () => {
    const { oriVersion, newVersion } = this.state
    const _this = this
    confirm({
      title: this.state.dict['main.verup'],
      content: `最新版本${newVersion},当前版本${oriVersion}`,
      okText: this.state.dict['main.confirm'],
      cancelText: this.state.dict['main.cancel'],
      onOk() {
        return new Promise(resolve => {
          Api.updateAppVersion(newVersion).then(res => {
            if (res.status) {
              notification.success({
                top: 92,
                message: '升级成功!',
                duration: 2
              })
              _this.setState({oriVersion: newVersion})
            } else {
              notification.warning({
                top: 92,
                message: '升级失败,请刷新页面重试!',
                duration: 2
              })
            }
            resolve()
          })
        })
      },
      onCancel() {}
    })
  }
  gotoDoc = () => {
@@ -647,22 +696,25 @@
  }
  render () {
    const { thdMenuList, searchkey } = this.state
    const { thdMenuList, searchkey, oriVersion, newVersion } = this.state
    const menu = (
      <Menu overlayclassname="header-dropdown">
        {this.props.debug && <Menu.Item key="0">
      <Menu className="header-dropdown">
        {this.props.debug && <Menu.Item key="switch">
          {this.state.dict['main.edit']}
          <Switch size="small" className="edit-switch" disabled={!!this.props.editLevel} checked={this.props.editState} onChange={this.changeEditState} />
        </Menu.Item>}
        {!this.props.editState ? <Menu.Item key="1" onClick={this.changePassword}>{this.state.dict['main.password']}</Menu.Item> : null}
        {!this.props.editState ? <Menu.Item key="password" onClick={this.changePassword}>{this.state.dict['main.password']}</Menu.Item> : null}
        {/* {this.state.systems.length > 0 ? <Menu.SubMenu title="切换系统">
          {this.state.systems.map((system, index) => (
            <Menu.Item className="header-subSystem" key={'sub' + index} onClick={() => {this.changeSystem(system)}}> {system.AppName} </Menu.Item>
          ))}
        </Menu.SubMenu> : null} */}
        <Menu.Item key="2" onClick={this.gotoDoc}>{this.state.dict['main.doc']}</Menu.Item>
        <Menu.Item key="3" onClick={this.logout}>{this.state.dict['main.logout']}</Menu.Item>
        <Menu.Item key="doc" onClick={this.gotoDoc}>{this.state.dict['main.doc']}</Menu.Item>
        {oriVersion ? <Menu.Item key="verup" onClick={this.verup}>
          <Badge dot={oriVersion !== newVersion}>{this.state.dict['main.verup']}</Badge>
        </Menu.Item> : null}
        <Menu.Item key="logout" onClick={this.logout}>{this.state.dict['main.logout']}</Menu.Item>
      </Menu>
    )
@@ -692,9 +744,9 @@
        {this.props.editLevel === 'HS' ? <Button className="level4-close" type="primary" onClick={this.exitManage}>退出</Button> : null}
        {/* 进入编辑按钮 */}
        {this.props.editState && !this.props.editLevel ? <Icon onClick={this.enterEdit} className="edit-check" type="edit" /> : null}
        {/* {this.props.editState && !this.props.editLevel && options.sysType === 'local' && window.GLOB.systemType !== 'production' ?
        {this.props.editState && !this.props.editLevel && options.sysType === 'local' && window.GLOB.systemType !== 'production' ?
          <a href="#/mobmanage" target="_blank" className="mobile" type="edit"> 应用管理 <Icon type="arrow-right" /></a> : null
        } */}
        }
        {/* 编辑菜单 */}
        {this.props.editLevel === 'level1' ? <EditMenu menulist={this.state.menulist} reload={this.reload} exitEdit={this.exitEdit}/> : null}
        {/* 头像、用户名 */}