| | |
| | | import {connect} from 'react-redux' |
| | | import { is, fromJS } from 'immutable' |
| | | import moment from 'moment' |
| | | import { Dropdown, Menu, Icon, Modal, Form, notification, Switch, Input } from 'antd' |
| | | import { Dropdown, Menu, Modal, Form, notification, Switch, Input } from 'antd' |
| | | import { SearchOutlined, DownOutlined, MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons' |
| | | |
| | | import { |
| | | toggleCollapse, |
| | |
| | | initMenuPermission, |
| | | logout |
| | | } from '@/store/action' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import asyncComponent from '@/utils/asyncSpinComponent' |
| | | import Api from '@/api' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import options from '@/store/options.js' |
| | |
| | | visible: false, // 修改密码模态框 |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | confirmLoading: false, |
| | | userName: sessionStorage.getItem('User_Name'), |
| | | userName: '', |
| | | fullName: '', |
| | | logourl: window.GLOB.mainlogo, |
| | | appVersion: window.GLOB.appVersion, |
| | | loginVisible: false, |
| | |
| | | } |
| | | |
| | | resetPwdSubmit = () => { |
| | | if (!this.formRef) return |
| | | |
| | | this.formRef.handleConfirm().then(res => { |
| | | this.setState({ |
| | | confirmLoading: true |
| | |
| | | // 获取角色权限 |
| | | let roledefer = new Promise(resolve => { |
| | | // edition_type 接口版本控制 ''、'Y'、'A' |
| | | Api.getSystemConfig({ |
| | | func: 's_Get_TrdMenu_Role', |
| | | edition_type: 'A', |
| | | pro_sys: window.GLOB.systemType === 'production' ? 'Y' : '' |
| | | }).then(result => { |
| | | let _permAction = {loaded: true} // 按钮权限 |
| | | |
| | | if (result && result.status) { |
| | | if (result.UserRoles_Menu) { |
| | | result.UserRoles_Menu.forEach(menu => { |
| | | if (!menu.MenuID) return |
| | | _permAction[menu.MenuID] = true |
| | | setTimeout(() => { |
| | | Api.getSystemConfig({ |
| | | func: 's_Get_TrdMenu_Role', |
| | | edition_type: 'A', |
| | | pro_sys: window.GLOB.systemType === 'production' ? 'Y' : '' |
| | | }).then(result => { |
| | | let _permAction = {loaded: true} // 按钮权限 |
| | | |
| | | if (result && result.status) { |
| | | if (result.UserRoles_Menu) { |
| | | result.UserRoles_Menu.forEach(menu => { |
| | | if (!menu.MenuID) return |
| | | _permAction[menu.MenuID] = true |
| | | }) |
| | | } |
| | | } else if (result) { |
| | | notification.error({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | } |
| | | } else if (result) { |
| | | notification.error({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | } |
| | | |
| | | this.props.initActionPermission(_permAction) |
| | | resolve() |
| | | }) |
| | | |
| | | this.props.initActionPermission(_permAction) |
| | | resolve() |
| | | }) |
| | | }, 50) |
| | | }) |
| | | |
| | | // 获取主菜单参数 |
| | |
| | | |
| | | const { menulist, thdMenuList } = this.getMenulist(result) |
| | | |
| | | let systems = [] |
| | | if ((options.sysType === 'local' || options.sysType === 'SSO') && result.sys_list) { |
| | | systems = result.sys_list |
| | | |
| | | if (options.sysType === 'local' && window.GLOB.systemType !== 'production' && systems.length > 10) { |
| | | systems.length = 10 |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | | menulist, |
| | | thdMenuList, |
| | | systems: window.GLOB.systemType === 'production' || options.sysType === 'SSO' ? (result.sys_list || []) : [] |
| | | systems: systems |
| | | }) |
| | | |
| | | let mainMenu = menulist[0] || '' |
| | |
| | | } |
| | | |
| | | loginSubmit = () => { |
| | | if (!this.loginRef) return |
| | | |
| | | this.setState({ |
| | | loginLoading: true |
| | | }) |
| | | |
| | | this.loginRef.handleConfirm().then(param => { |
| | | Api.getusermsg(param.username, param.password, true).then(res => { |
| | | if (res.status) { |
| | | this.setState({ |
| | | loginLoading: false |
| | | }) |
| | | |
| | | if (res.modifydate) { |
| | | let s = (new Date().getTime() - new Date(res.modifydate).getTime()) / (1000 * 24 * 60 * 60) |
| | | if (!isNaN(s) && s > 90) { |
| | | Modal.warning({ |
| | | width: 520, |
| | | title: <span>系统检测到您的账户存在风险,请及时到<a target="_blank" rel="noopener noreferrer" href="https://cloud.mk9h.cn/admin/index.html">云中心</a>修改密码!</span>, |
| | | okText: '知道了' |
| | | }) |
| | | return |
| | | } |
| | | } |
| | | |
| | | sessionStorage.setItem('CloudUserID', res.UserID) |
| | | sessionStorage.setItem('CloudLoginUID', res.LoginUID) |
| | | sessionStorage.setItem('CloudUserName', res.UserName) |
| | |
| | | sessionStorage.setItem('role_id', res.role_id || '') |
| | | sessionStorage.setItem('dataM', res.dataM ? 'true' : '') |
| | | sessionStorage.setItem('isEditState', 'true') |
| | | |
| | | if (param.remember) { |
| | | let _url = window.location.href.split('#')[0] + 'cloud' |
| | | |
| | | localStorage.setItem(_url, window.btoa(window.encodeURIComponent(JSON.stringify({time: new Date().getTime(), username: param.username, password: param.password})))) |
| | | } |
| | | |
| | | this.setSystemFuncs() |
| | | this.props.modifyMainMenu(null) |
| | |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } else if (result.func_detail && result.func_detail.length > 0) { |
| | | this.writeFuncs(result.func_detail) |
| | | } |
| | |
| | | url = url + '/' |
| | | } |
| | | |
| | | let href = url + 'index.html#/ssologin/' + window.btoa(window.encodeURIComponent(JSON.stringify({ |
| | | UserID: sessionStorage.getItem('UserID'), |
| | | LoginUID: sessionStorage.getItem('LoginUID'), |
| | | User_Name: sessionStorage.getItem('User_Name'), |
| | | Full_Name: sessionStorage.getItem('Full_Name'), |
| | | avatar: sessionStorage.getItem('avatar'), |
| | | dataM: system.dataM ? 'true' : '', |
| | | debug: system.debug || '', |
| | | role_id: system.role_id || '' |
| | | }))) |
| | | let key = Utils.getuuid() |
| | | |
| | | window.open(href) |
| | | let _param = { |
| | | func: 'webapi_scan_binding_key', |
| | | binding_type: 'mk', |
| | | scan_type: 'toggle', |
| | | scan_appkey: system.scan_appkey, |
| | | id: key |
| | | } |
| | | |
| | | Api.getSystemConfig(_param).then(res => { |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | } else if (res.thd_party_appid && res.thd_party_member_id && res.thd_party_openid) { |
| | | let href = url + 'admin/index.html#/ssologin/' + window.btoa(window.encodeURIComponent(JSON.stringify({ |
| | | appid: res.thd_party_appid, |
| | | memberId: res.thd_party_member_id, |
| | | openid: res.thd_party_openid, |
| | | key: key |
| | | }))) |
| | | |
| | | window.open(href) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '信息缺失,请联系管理员!', |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | dropdownMenuChange = (visible) => { |
| | |
| | | UNSAFE_componentWillMount () { |
| | | // 组件加载时,获取菜单数据 |
| | | this.getRolesMenu() |
| | | |
| | | let fullName = sessionStorage.getItem('Full_Name') || '' |
| | | let userName = sessionStorage.getItem('User_Name') || '' |
| | | |
| | | if (fullName.toLowerCase() === userName.toLowerCase()) { |
| | | userName = '' |
| | | } |
| | | |
| | | this.setState({fullName, userName}) |
| | | } |
| | | |
| | | componentDidMount () { |
| | |
| | | setTimeout(() => { |
| | | Api.getAppVersion().then(() => {}, () => {}) |
| | | }, 1000) |
| | | // Api.genericInterface({ |
| | | // func: 's_get_fcc_account_data', |
| | | // fcc_date: '2022-03-01', |
| | | // search_type: '' |
| | | // }).then(res => { |
| | | // }) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | let url = `${ssodomain}/doc/index.html#?appkey=${window.GLOB.appkey}&LoginUID=${sessionStorage.getItem('LoginUID')}` |
| | | window.open(url) |
| | | } else if (options.sysType === 'SSO' || options.sysType === 'cloud') { |
| | | window.open(`${window.location.href.replace(/\/index.html(.*)|\/#(.*)/ig, '')}/doc/index.html#?appkey=${window.GLOB.appkey}&LoginUID=${sessionStorage.getItem('LoginUID')}`) |
| | | window.open(`${window.location.href.replace(/\/admin(.*)|\/index.html(.*)|\/#(.*)/ig, '')}/doc/index.html#?appkey=${window.GLOB.appkey}&LoginUID=${sessionStorage.getItem('LoginUID')}`) |
| | | } |
| | | } |
| | | |
| | |
| | | <header className="header-container ant-menu-dark" id="main-header-container"> |
| | | <div className={'header-logo ' + (collapse && navBar !== 'topmenu' ? 'collapse' : '')}><img src={this.state.logourl} alt=""/></div> |
| | | <div className={'header-collapse ' + (collapse && navBar !== 'topmenu' ? 'collapse' : '')}> |
| | | {navBar !== 'topmenu' ? <Icon type={collapse ? 'menu-unfold' : 'menu-fold'} onClick={this.handleCollapse}/> : null} |
| | | {navBar !== 'topmenu' ? (collapse ? <MenuUnfoldOutlined onClick={this.handleCollapse}/> : <MenuFoldOutlined onClick={this.handleCollapse}/>) : null} |
| | | </div> |
| | | {/* 正常菜单 */} |
| | | {navBar !== 'topmenu' && menulist ? |
| | |
| | | <div> |
| | | <img src={this.state.avatar || avatar} alt=""/> |
| | | <span> |
| | | <span className="username">{this.state.userName}</span> <Icon type="down" /> |
| | | <span className="username"><span>{this.state.fullName}</span>{this.state.userName ? <span>{this.state.userName}</span> : null}</span> <DownOutlined /> |
| | | </span> |
| | | </div> |
| | | </Dropdown> |
| | |
| | | </div> |
| | | </div> |
| | | } trigger={['click']} className="search-menu" placement="bottomRight" onVisibleChange={this.dropdownMenuChange}> |
| | | <Icon className="search-menu" type="search" /> |
| | | <SearchOutlined className="search-menu" /> |
| | | </Dropdown> : null |
| | | } |
| | | {/* 修改密码 */} |
| | |
| | | const mapStateToProps = (state) => { |
| | | return { |
| | | collapse: state.collapse, |
| | | mainMenu: state.mainMenu, |
| | | permAction: state.permAction, |
| | | mainMenu: state.mainMenu |
| | | } |
| | | } |
| | | |