king
2021-11-30 81c3fd3ac5017591d987d9c9fe42042fae5c7d7d
src/views/design/header/index.jsx
@@ -2,13 +2,12 @@
import { withRouter } from 'react-router-dom'
import {connect} from 'react-redux'
import { is, fromJS } from 'immutable'
import { Dropdown, Menu, Icon, Modal, Form, notification, Switch, Button } from 'antd'
import { Dropdown, Menu, Icon, Modal, notification, Switch, Button } from 'antd'
import asyncComponent from '@/utils/asyncComponent'
import {
  modifyMenuTree,
  modifyMainMenu,
  modifyTabview,
  resetEditLevel,
  logout
} from '@/store/action'
@@ -19,9 +18,11 @@
import Utils from '@/utils/utils.js'
import avatar from '@/assets/img/avatar.jpg'
import MainLogo from '@/assets/img/main-logo.png'
import MKEmitter from '@/utils/events.js'
import './index.scss'
const EditMenu = asyncComponent(() => import('@/templates/menuconfig/editfirstmenu'))
const VersionsUp = asyncComponent(() => import('./versions'))
const { confirm } = Modal
class Header extends Component {
@@ -91,6 +92,7 @@
  getMenulist = (result) => {
    let iframes = ['Main/Index', 'bda/rdt', 'Home/rdt']
    let menulist = []
    let thdMenuList = []
    result.fst_menu && result.fst_menu.forEach(fst => {
      let fstItem = {
        MenuID: fst.MenuID,
@@ -139,7 +141,7 @@
  
              if (trd.LinkUrl && iframes.includes(trd.LinkUrl.split('?')[0])) {
                trdItem.type = 'iframe'
                trdItem.LinkUrl = trd.LinkUrl
                trdItem.LinkUrl = trd.LinkUrl.replace('&', '&')
                trdItem.forbidden = true
              } else {
                try {
@@ -156,6 +158,8 @@
                }
              }
              thdMenuList.push(trdItem)
              return trdItem
            })
          }
@@ -167,6 +171,7 @@
      menulist.push(fstItem)
    })
    sessionStorage.setItem('thdMenuList', JSON.stringify(thdMenuList))
    return { menulist }
  }
@@ -209,7 +214,8 @@
    this.props.modifyMainMenu(menulist[0] || null)
    this.props.resetEditLevel(false)
    this.props.modifyTabview([])
    MKEmitter.emit('modifyTabs', null, 'replace')
  }
  
  exitEdit = () => {
@@ -235,34 +241,36 @@
  componentDidMount () {
    if (window.GLOB.systemType !== 'production') {
      Api.getSystemConfig({func: 'sPC_Get_Roles_sModular'}).then(res => {
        if (res.status) {
          let _permFuncField = []
          let _sysRoles = []
          if (res.Roles && res.Roles.length > 0) {
            _sysRoles = res.Roles.map(role => {
              return {
                uuid: Utils.getuuid(),
                value: role.RoleID,
                text: role.RoleName
              }
            })
      setTimeout(() => {
        Api.getSystemConfig({func: 'sPC_Get_Roles_sModular'}).then(res => {
          if (res.status) {
            let _permFuncField = []
            let _sysRoles = []
            if (res.Roles && res.Roles.length > 0) {
              _sysRoles = res.Roles.map(role => {
                return {
                  uuid: Utils.getuuid(),
                  value: role.RoleID,
                  text: role.RoleName
                }
              })
            }
            if (res.sModular && res.sModular.length > 0) {
              res.sModular.forEach(field => {
                if (field.ModularNo) {
                  _permFuncField.push(field.ModularNo)
                }
              })
              _permFuncField = _permFuncField.sort()
            }
            sessionStorage.setItem('sysRoles', JSON.stringify(_sysRoles))
            sessionStorage.setItem('permFuncField', JSON.stringify(_permFuncField))
          }
          if (res.sModular && res.sModular.length > 0) {
            res.sModular.forEach(field => {
              if (field.ModularNo) {
                _permFuncField.push(field.ModularNo)
              }
            })
            _permFuncField = _permFuncField.sort()
          }
          sessionStorage.setItem('sysRoles', JSON.stringify(_sysRoles))
          sessionStorage.setItem('permFuncField', JSON.stringify(_permFuncField))
        }
      })
        })
      }, 50)
    } else if (window.GLOB.systemType === 'production') {
      this.props.resetEditLevel('HS')
      this.props.modifyMainMenu({
@@ -323,15 +331,47 @@
        }
        {editLevel === 'HS' ? <Button className="level4-close" type="primary" onClick={this.exitManage}>退出</Button> : null}
        {/* 进入编辑按钮 */}
        {!editLevel ? <Icon onClick={this.enterEdit} className="edit-check" type="edit" /> : null}
        {!editLevel && options.sysType === 'local' && window.GLOB.systemType !== 'production' && this.props.memberLevel >= 30 ?
          <span onClick={() => {window.open('#/appmanage')}} className="mobile" type="edit"> 应用管理 <Icon type="arrow-right" /></span> : null
        {!editLevel && menulist ? <Icon onClick={this.enterEdit} className="edit-check" type="edit" /> : null}
        {!editLevel && options.sysType === 'local' && window.GLOB.systemType !== 'production' && this.props.memberLevel >= 20 ?
          <div className="app-entrance entrance">
            <div className="icon"><Icon type="appstore" /></div>
            <div className="title">应用管理</div>
            <div className="detail">可创建及管理PC、pad及移动端等不同设备的应用,实现明科云APP、微信公众号、小程序等多平台的应用共享。</div>
            <Button type="primary" onClick={() => {window.open('#/appmanage')}}>
              编辑
            </Button>
          </div> : null
        }
        {editLevel === 'HS' && options.sysType === 'local' && window.GLOB.systemType === 'production' && this.props.memberLevel >= 20 ?
          <div className="app-prod-entrance entrance">
            <div className="icon"><Icon type="appstore" /></div>
            <div className="title">应用管理</div>
            <div className="detail">可创建及管理PC、pad及移动端等不同设备的应用,实现明科云APP、微信公众号、小程序等多平台的应用共享。</div>
            <Button type="primary" onClick={() => {window.open('#/appcheck')}}>
              查看
            </Button>
          </div> : null
        }
        {!editLevel && options.sysType === 'local' && this.props.memberLevel >= 20 ?
          <div className="api-entrance entrance">
            <div className="icon"><Icon type="api" /></div>
            <div className="title">接口调试</div>
            <div className="detail">可自动处理登录接口的参数加密,以及业务接口的签名计算,方便开发人员的接口测试工作。</div>
            <Button type="primary" onClick={() => {window.open('#/interface')}}>
              编辑
            </Button>
          </div> : null
        }
        {/* window.btoa(window.encodeURIComponent(JSON.stringify({ MenuType: 'home', MenuId: 'home_page_id', MenuName: '首页' }))) */}
        {!editLevel && window.GLOB.systemType !== 'production' && this.props.memberLevel >= 20 ?
          <span className="home-edit" onClick={() => {window.open('#/menudesign/JTdCJTIyTWVudVR5cGUlMjIlM0ElMjJob21lJTIyJTJDJTIyTWVudUlkJTIyJTNBJTIyaG9tZV9wYWdlX2lkJTIyJTJDJTIyTWVudU5hbWUlMjIlM0ElMjIlRTklQTYlOTYlRTklQTElQjUlMjIlN0Q=')}}>
            首页 <Icon type="arrow-right" />
          </span> : null
          <div className="home-entrance entrance">
            <div className="icon"><Icon type="home" /></div>
            <div className="title">首页</div>
            <div className="detail">基于自定义页面的首页设计,可实现灵活的元素配置及样式调整,展现当前系统的风格。</div>
            <Button type="primary" onClick={() => {window.open('#/menudesign/JTdCJTIyTWVudVR5cGUlMjIlM0ElMjJob21lJTIyJTJDJTIyTWVudUlkJTIyJTNBJTIyaG9tZV9wYWdlX2lkJTIyJTJDJTIyTWVudU5hbWUlMjIlM0ElMjIlRTklQTYlOTYlRTklQTElQjUlMjIlN0Q=')}}>
              编辑
            </Button>
          </div> : null
        }
        {/* 编辑菜单 */}
        {editLevel === 'level1' ? <EditMenu menulist={this.state.menulist} reload={this.reload} exitEdit={this.exitEdit}/> : null}
@@ -343,10 +383,13 @@
              <Switch size="small" style={{marginLeft: '7px'}} disabled={!!editLevel} checked={true} onChange={this.changeEditState} />
            </Menu.Item>
            <Menu.Item key="doc" onClick={this.gotoDoc}>{this.state.dict['main.doc']}</Menu.Item>
            {options.sysType !== 'cloud' ? <Menu.Item style={{padding: 0}} key="verup">
              <VersionsUp />
            </Menu.Item> : null}
            <Menu.Item key="logout" onClick={this.logout}>{this.state.dict['main.logout']}</Menu.Item>
          </Menu>
        }>
          <div>
          <div style={{zIndex: 1, position: 'relative'}}>
            <img src={this.state.avatar || avatar} alt=""/>
            <span>
              <span className="username">{this.state.userName}</span> <Icon type="down" />
@@ -360,7 +403,6 @@
const mapStateToProps = (state) => {
  return {
    tabviews: state.tabviews,
    menuTree: state.menuTree,
    mainMenu: state.mainMenu,
    editLevel: state.editLevel,
@@ -371,7 +413,6 @@
const mapDispatchToProps = (dispatch) => {
  return {
    modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)),
    modifyMenuTree: (menuTree) => dispatch(modifyMenuTree(menuTree)),
    modifyMainMenu: (mainMenu) => dispatch(modifyMainMenu(mainMenu)),
    resetEditLevel: (level) => dispatch(resetEditLevel(level)),
@@ -379,4 +420,4 @@
  }
}
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Form.create()(Header)))
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Header))