king
2024-05-23 9a11e62adeb8d435b52a361eb62d5b59e1deef2a
src/components/header/index.jsx
@@ -10,6 +10,7 @@
import MKEmitter from '@/utils/events.js'
import Utils from '@/utils/utils.js'
import avatar from '@/assets/img/avatar.jpg'
import wxicon from '@/assets/img/wx-icon.png'
import './index.scss'
const { confirm } = Modal
@@ -24,6 +25,7 @@
    userName: '',
    fullName: '',
    logourl: window.GLOB.mainlogo,
    wxVisible: false,
    loginVisible: false,
    loginLoading: false,
    avatar: Utils.getrealurl(sessionStorage.getItem('avatar')),
@@ -31,7 +33,8 @@
    searchkey: '',
    thdMenuList: [],
    debug: sessionStorage.getItem('debug') === 'true' && window.GLOB.memberLevel > 0,
    collapse: sessionStorage.getItem('collapse') === 'true'
    collapse: sessionStorage.getItem('collapse') === 'true',
    lang: sessionStorage.getItem('lang') || ''
  }
  UNSAFE_componentWillMount () {
@@ -60,7 +63,7 @@
      if (e.key === 'getSessionStorage' && e.newValue === window.GLOB.appkey) {
        localStorage.setItem('sessionStorage', JSON.stringify(sessionStorage))
      } else if (e.key === 'getSysPermission' && e.newValue === window.GLOB.appkey) {
        localStorage.setItem('sysPermissions', JSON.stringify({mkThdMenus: window.GLOB.mkThdMenus, mkActions: window.GLOB.mkActions}))
        localStorage.setItem('sysPermissions', JSON.stringify({mkThdMenus: this.state.thdMenuList, mkActions: window.GLOB.mkActions}))
      } else if (e.key === 'menuUpdate') {
        let vals = e.newValue.split(',')
        let menuId = vals[1]
@@ -180,13 +183,22 @@
      }
      window.GLOB.mainMenu = mainMenu
      window.GLOB.mkThdMenus = [...thdMenuList, {MenuID: 'home_page_id', EasyCode: '', MenuName: 'home', type: 'CustomPage'}]
      thdMenuList.forEach(item => {
        window.GLOB.mkThdMenus.set(item.MenuID, item)
      })
      window.GLOB.mkThdMenus.set('home_page_id', {MenuID: 'home_page_id', EasyCode: '', MenuName: 'home', type: 'CustomPage'})
      MKEmitter.emit('mainMenuChange')
      if (_menu) {
        this.openTab(_menu, 0)
      }
      setTimeout(() => {
        this.getwork()
      }, 100)
    })
    
    // 获取角色权限, edition_type 接口版本控制 ''、'Y'、'A'
@@ -205,7 +217,7 @@
              _permAction[menu.MenuID] = true
            })
          }
        } else {
        } else if (!/PRIMARY KEY/ig.test(result.message)) {
          notification.error({
            top: 92,
            message: result.message,
@@ -218,6 +230,29 @@
    }, 50)
  }
  getwork = () => {
    if (sessionStorage.getItem('work_grade')) return
    let param = {func: 's_get_local_my_worker_v1'}
    if (window.GLOB.forcedUpdate) {
      param.s_version_up = 'true'
    }
    Api.genericInterface(param).then(result => {
      sessionStorage.setItem('work_grade', result.work_grade || 0)
      sessionStorage.setItem('work_group', result.work_group || '')
      if (!result.status && sessionStorage.getItem('debug') === 'true') {
        notification.error({
          top: 92,
          message: /s_get_local_my_worker_v1/.test(result.message) ? '职员信息获取失败,请联系管理员。' : result.message,
          duration: 10
        })
      }
    })
  }
  openTab = (menu, times) => {
    if (times > 50) return
    times++
@@ -228,7 +263,7 @@
      MKEmitter.emit('modifyTabs', menu)
    } else {
      setTimeout(() => {
        this.openTab(times)
        this.openTab(menu, times)
      }, 200)
    }
  }
@@ -302,6 +337,8 @@
                  trdItem.type = PageParam.Template || 'CommonTable'
                  trdItem.OpenType = PageParam.OpenType || 'newtab'
                  trdItem.hidden = PageParam.hidden || 'false'
                  trdItem.menuColor = PageParam.menuColor || ''
                  trdItem.urlFields = PageParam.urlFields || ''
                  if (trdItem.type === 'NewPage') {
                    trdItem.OpenType = 'newpage'
@@ -401,6 +438,8 @@
          sessionStorage.setItem('CloudAvatar', res.icon)
          sessionStorage.setItem('cloudDataM', res.dataM ? 'true' : '')
          sessionStorage.setItem('cloudRole_id', res.role_id || '')
          sessionStorage.setItem('CloudLogo', res.open_logo || '')
          let _url = window.location.href.split('#')[0] + 'cloud'
          if (param.remember) {
@@ -539,6 +578,8 @@
          } else {
            Api.updateAppVersion()
            Api.delCacheConfig('all')
            localStorage.removeItem(window.location.href.split('#')[0] + 'AuthCode')
            setTimeout(() => {
              notification.success({
                top: 92,
@@ -557,14 +598,6 @@
  about = () => {
    Modal.success({
      title: '系统版本v' + window.GLOB.appVersion
    })
  }
  wxnotice = () => {
    Modal.success({
      className: 'mk-wx-notice',
      title: <QrCode card={{qrWidth: 320, color: '#000000'}} value={window.GLOB.baseurl + 'mob/wxnotice.html?userid=' + sessionStorage.getItem('UserID') + '&loginuid=' + sessionStorage.getItem('LoginUID')}/>,
      okText: '关闭'
    })
  }
@@ -594,7 +627,7 @@
        <Menu.Item key="verup" onClick={this.verup}>
          页面更新
        </Menu.Item>
        {window.GLOB.WXNotice ? <Menu.Item key="wxnotice" onClick={this.wxnotice}>
        {window.GLOB.WXNotice ? <Menu.Item key="wxnotice" onClick={() => this.setState({wxVisible: true})}>
          微信消息
        </Menu.Item> : null}
        {window.GLOB.appVersion ? <Menu.Item key="version" onClick={this.about}>
@@ -680,7 +713,7 @@
                            <div className="title" onClick={e => e.stopPropagation()}>{cell.MenuName}</div>
                            <div className="menu-detail">
                              {cell.children && cell.children.map(m => (
                                <div key={m.MenuID} title={m.MenuName} onClick={() => {this.changeVerMenu(m)}}>
                                <div key={m.MenuID} title={m.MenuName} style={m.menuColor ? {color: m.menuColor} : null} onClick={() => {this.changeVerMenu(m)}}>
                                  {m.MenuName}
                                </div>
                              ))}
@@ -755,7 +788,7 @@
        </Dropdown>
        {/* 编辑状态登录 */}
        <Modal
          title="登录开发机"
          title={<span>登录开发机{this.state.lang === 'en-US' ? <span style={{color: 'red'}}>(英文)</span> : ''}</span>}
          visible={this.state.loginVisible}
          onOk={this.loginSubmit}
          width={'430px'}
@@ -767,6 +800,26 @@
        </Modal>
        {/* 修改密码 */}
        <Resetpwd />
        {/* 微信消息 */}
        <Modal
          wrapClassName="mk-wx-sms-modal"
          visible={this.state.wxVisible}
          title="扫码关注  接收消息"
          width={400}
          centered={true}
          onCancel={() => this.setState({wxVisible: false})}
          footer={null}
          destroyOnClose
        >
          <div className="wx-sms-wrap">
            <QrCode card={{qrWidth: 200, color: '#000000'}} value={window.GLOB.baseurl + 'mob/wxnotice.html?userid=' + sessionStorage.getItem('UserID') + '&loginuid=' + sessionStorage.getItem('LoginUID')}/>
            <div className="tip">
              <img src={wxicon} alt=""/>
              <span>微信扫码</span>
              <span>关注公众号</span>
            </div>
          </div>
        </Modal>
      </header>
    )
  }