king
2020-01-10 1b0fd0a20d54068f0f4716177780e00a75b860ef
src/components/header/index.jsx
@@ -23,6 +23,7 @@
import logourl from '@/assets/img/main-logo.png'
import avatar from '@/assets/img/avatar.jpg'
import Resetpwd from './resetpwd'
import LoginForm from './loginform'
import './index.scss'
const EditMenu = asyncComponent(() => import('./editmenu'))
@@ -42,7 +43,10 @@
    dict: (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS,
    confirmLoading: false,
    userName: sessionStorage.getItem('User_Name'),
    logourl: window.GLOB.mainlogo || logourl
    logourl: window.GLOB.mainlogo || logourl,
    loginVisible: false,
    loginLoading: false,
    systems: []
  }
  handleCollapse = () => {
@@ -78,8 +82,14 @@
    _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' // 时间戳
    _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)   // md5密钥
    let result = await Api.getSystemConfig(_param)
    if (result.status) {
    let localResult = await Api.getLocalConfig(_param)
    let result = {status: true}
    if (window.GLOB.mainSystemApi && window.GLOB.subSystemApi !== window.GLOB.mainSystemApi) {
      result = await Api.getSystemConfig(_param)
    }
    if (result.status && localResult.status) {
      this.setState({
        visible: false,
        confirmLoading: false
@@ -92,7 +102,7 @@
    } else {
      notification.warning({
        top: 92,
        message: result.message,
        message: result.message || localResult.message,
        duration: 10
      })
      this.setState({
@@ -178,7 +188,8 @@
            item.PageParam = {OpenType: 'menu', linkUrl: ''}
          }
          return item
        })
        }),
        systems: result.Systems.filter(sys => sys.LinkUrl1)
      })
    } else {
      notification.error({
@@ -223,7 +234,50 @@
  changeEditState = (state) => {
    // 修改编辑状态
    this.props.resetEditState(state)
    let UserID = sessionStorage.getItem('CloudUserID')
    let LoginUID = sessionStorage.getItem('CloudLoginUID')
    sessionStorage.setItem('isEditState', state)
    if (state && (!UserID || !LoginUID)) {
      this.setState({
        loginVisible: true
      })
    } else {
      this.setState({
        menulist: null
      })
      this.loadmenu()
      this.props.resetEditState(state)
    }
  }
  loginSubmit = () => {
    this.setState({
      loginLoading: true
    })
    this.loginRef.handleConfirm().then(param => {
      Api.getusermsg(param.username, param.password).then(res => {
        if (res.status) {
          sessionStorage.setItem('CloudUserID', res.UserID)
          sessionStorage.setItem('CloudSessionUid', Utils.getuuid())
          sessionStorage.setItem('CloudLoginUID', res.LoginUID)
          this.setState({
            menulist: null,
            loginVisible: false,
            loginLoading: false
          })
          this.loadmenu()
          this.props.resetEditState(true)
        } else {
          notification.error({
            top: 92,
            message: res.message,
            duration: 15
          })
        }
      })
    })
  }
  enterEdit = () => {
@@ -234,6 +288,10 @@
  exitEdit = () => {
    // 退出编辑状态
    this.props.resetEditLevel(false)
  }
  changeSystem = (system) => {
    console.log(system)
  }
  
  UNSAFE_componentWillMount () {
@@ -258,9 +316,14 @@
      <Menu overlayclassname="header-dropdown">
        {this.props.debug && <Menu.Item key="0">
          {this.state.dict['header.edit']}
          <Switch size="small" className="edit-switch" disabled={!!this.props.editLevel} onChange={this.changeEditState} />
          <Switch size="small" className="edit-switch" disabled={!!this.props.editLevel} checked={this.props.editState} onChange={this.changeEditState} />
        </Menu.Item>}
        <Menu.Item key="1" onClick={this.changePassword}>{this.state.dict['header.password']}</Menu.Item>
        {!this.props.editState ? <Menu.Item key="1" onClick={this.changePassword}>{this.state.dict['header.password']}</Menu.Item> : null}
        <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>
        <Menu.Item key="2" onClick={this.logout}>{this.state.dict['header.logout']}</Menu.Item>
      </Menu>
    )
@@ -308,6 +371,20 @@
        >
          <Resetpwd dict={this.state.dict} wrappedComponentRef={(inst) => this.formRef = inst} resetPwdSubmit={this.resetPwdSubmit}/>
        </Modal>
        {/* 编辑状态登录 */}
        <Modal
          title={this.state.dict['header.login.develop']}
          okText={this.state.dict['header.confirm']}
          cancelText={this.state.dict['header.cancel']}
          visible={this.state.loginVisible}
          onOk={this.loginSubmit}
          width={'430px'}
          confirmLoading={this.state.loginLoading}
          onCancel={() => {this.setState({ loginVisible: false, loginLoading: false })}}
          destroyOnClose
        >
          <LoginForm handleSubmit={() => this.loginSubmit()} wrappedComponentRef={(inst) => this.loginRef = inst}/>
        </Modal>
      </header>
    )
  }