From 61ab22d7b6be46c00e8813b00b2352a52cc252f3 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 01 二月 2023 15:43:35 +0800 Subject: [PATCH] 2023-02-01 --- src/components/header/index.jsx | 95 ++++++++--------------------------------------- 1 files changed, 16 insertions(+), 79 deletions(-) diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx index 369d9c5..0f878e0 100644 --- a/src/components/header/index.jsx +++ b/src/components/header/index.jsx @@ -3,7 +3,6 @@ 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' @@ -16,15 +15,13 @@ 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 { @@ -33,9 +30,6 @@ } state = { menulist: null, // 涓�绾ц彍鍗� - visible: false, // 淇敼瀵嗙爜妯℃�佹 - dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, - confirmLoading: false, userName: '', fullName: '', logourl: window.GLOB.mainlogo, @@ -57,60 +51,12 @@ 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) // 鍏抽敭瀛楃鏇挎崲锛宐ase64鍔犲瘑 - _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) }) } @@ -118,7 +64,7 @@ // 閫�鍑虹櫥褰� let _this = this confirm({ - title: this.state.dict['main.logout.hint'], + title: '鎮ㄧ‘瀹氳閫�鍑哄悧?', content: '', onOk() { sessionStorage.clear() @@ -610,23 +556,23 @@ 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> ) @@ -779,29 +725,20 @@ </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> ) } -- Gitblit v1.8.0