From 1b0fd0a20d54068f0f4716177780e00a75b860ef Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 10 一月 2020 17:12:34 +0800 Subject: [PATCH] 2020-01-10 --- src/components/header/index.jsx | 93 ++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 85 insertions(+), 8 deletions(-) diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx index 305f2f8..db7d91c 100644 --- a/src/components/header/index.jsx +++ b/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> ) } -- Gitblit v1.8.0