| | |
| | | import PropTypes from 'prop-types' |
| | | import {connect} from 'react-redux' |
| | | import { is, fromJS } from 'immutable' |
| | | import moment from 'moment' |
| | | import { Dropdown, Menu, Modal, notification, Switch, Input } from 'antd' |
| | | import { SearchOutlined, DownOutlined, MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons' |
| | | |
| | |
| | | import Api from '@/api' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import options from '@/store/options.js' |
| | | import zhCN from '@/locales/zh-CN/main.js' |
| | | import enUS from '@/locales/en-US/main.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import avatar from '@/assets/img/avatar.jpg' |
| | | import './index.scss' |
| | | |
| | | const { confirm } = Modal |
| | | const { Search } = Input |
| | | const Resetpwd = asyncComponent(() => import('./resetpwd')) |
| | | const Resetpwd = asyncComponent(() => import('@/components/resetPassword')) |
| | | const LoginForm = asyncComponent(() => import('./loginform')) |
| | | |
| | | class Header extends Component { |
| | |
| | | } |
| | | state = { |
| | | menulist: null, // 一级菜单 |
| | | visible: false, // 修改密码模态框 |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | confirmLoading: false, |
| | | userName: '', |
| | | fullName: '', |
| | | logourl: window.GLOB.mainlogo, |
| | |
| | | |
| | | changePassword = () => { |
| | | // 点击修改密码,显示弹窗 |
| | | this.setState({ |
| | | visible: true |
| | | }) |
| | | } |
| | | |
| | | resetPwdSubmit = () => { |
| | | if (!this.formRef) return |
| | | |
| | | this.formRef.handleConfirm().then(res => { |
| | | this.setState({ |
| | | confirmLoading: true |
| | | }) |
| | | |
| | | let _param = { |
| | | func: 's_PwdUpt', |
| | | LText: `select '${res.originpwd}','${res.password}'` |
| | | } |
| | | |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') // 时间戳 |
| | | _param.LText = Utils.formatOptions(_param.LText) // 关键字符替换,base64加密 |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) // md5密钥 |
| | | |
| | | Api.getSystemConfig(_param).then(result => { |
| | | this.setState({ |
| | | visible: !result.status, |
| | | confirmLoading: false |
| | | }) |
| | | |
| | | if (result.status) { |
| | | notification.success({ |
| | | top: 92, |
| | | message: '修改成功,请重新登录。', |
| | | duration: 2 |
| | | }) |
| | | setTimeout(() => { |
| | | sessionStorage.clear() |
| | | this.props.logout() |
| | | this.props.history.replace('/login') |
| | | }, 2000) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | }, () => {}) |
| | | } |
| | | |
| | | handleCancel = () => { |
| | | // 取消时关闭修改密码模态框,清空表单数据 |
| | | this.setState({ |
| | | visible: false |
| | | MKEmitter.emit('resetpassword', () => { |
| | | setTimeout(() => { |
| | | sessionStorage.clear() |
| | | this.props.logout() |
| | | this.props.history.replace('/login') |
| | | }, 2000) |
| | | }) |
| | | } |
| | | |
| | |
| | | // 退出登录 |
| | | let _this = this |
| | | confirm({ |
| | | title: this.state.dict['main.logout.hint'], |
| | | title: '您确定要退出吗?', |
| | | content: '', |
| | | onOk() { |
| | | sessionStorage.clear() |
| | |
| | | const menu = ( |
| | | <Menu className="header-dropdown"> |
| | | {debug && <Menu.Item key="switch"> |
| | | {this.state.dict['main.edit']} |
| | | 编辑 |
| | | <Switch size="small" style={{marginLeft: '7px'}} checked={false} onChange={this.changeEditState} /> |
| | | </Menu.Item>} |
| | | <Menu.Item key="password" onClick={this.changePassword}>{this.state.dict['main.password']}</Menu.Item> |
| | | <Menu.Item key="password" onClick={this.changePassword}>修改密码</Menu.Item> |
| | | {this.state.systems.length ? <Menu.SubMenu style={{minWidth: '110px'}} title="切换系统"> |
| | | {this.state.systems.map((system, index) => ( |
| | | <Menu.Item style={{minWidth: '100px', lineHeight: '30px'}} key={'sub' + index} onClick={() => {this.changeSystem(system)}}> {system.AppName} </Menu.Item> |
| | | ))} |
| | | </Menu.SubMenu> : null} |
| | | <Menu.Item key="doc" onClick={this.gotoDoc}>{this.state.dict['main.doc']}</Menu.Item> |
| | | <Menu.Item key="doc" onClick={this.gotoDoc}>文档中心</Menu.Item> |
| | | <Menu.Item key="verup" onClick={this.verup}> |
| | | 页面更新 |
| | | </Menu.Item> |
| | | {appVersion ? <Menu.Item key="version" onClick={this.about}> |
| | | 关于 |
| | | </Menu.Item> : null} |
| | | <Menu.Item key="logout" onClick={this.logout}>{this.state.dict['main.logout']}</Menu.Item> |
| | | <Menu.Item key="logout" onClick={this.logout}>退出</Menu.Item> |
| | | </Menu> |
| | | ) |
| | | |
| | |
| | | </span> |
| | | </div> |
| | | </Dropdown> |
| | | {/* 修改密码 */} |
| | | <Modal |
| | | title={this.state.dict['main.password']} |
| | | visible={this.state.visible} |
| | | onOk={this.resetPwdSubmit} |
| | | confirmLoading={this.state.confirmLoading} |
| | | onCancel={this.handleCancel} |
| | | destroyOnClose |
| | | > |
| | | <Resetpwd dict={this.state.dict} wrappedComponentRef={(inst) => this.formRef = inst} resetPwdSubmit={this.resetPwdSubmit}/> |
| | | </Modal> |
| | | {/* 编辑状态登录 */} |
| | | <Modal |
| | | title={this.state.dict['main.login.develop']} |
| | | title="登录开发机" |
| | | 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> |
| | | {/* 修改密码 */} |
| | | <Resetpwd /> |
| | | </header> |
| | | ) |
| | | } |