| | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import Api from '@/api' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import options from '@/store/options.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('@/components/resetPassword')) |
| | | const QrCode = asyncComponent(() => import('@/components/qrcode')) |
| | | const LoginForm = asyncSpinComponent(() => import('./loginform')) |
| | | |
| | | class Header extends Component { |
| | |
| | | |
| | | changeMenu (value) { |
| | | // 主菜单切换 |
| | | if (value.OpenType === 'outpage') { |
| | | window.open(value.linkUrl) |
| | | if (value.OpenType === 'newpage') { |
| | | window.open(value.src) |
| | | } else if (value.OpenType === 'newtab') { |
| | | MKEmitter.emit('modifyTabs', value) |
| | | } else if (value.OpenType === 'menu') { |
| | | this.props.modifyMainMenu(value) |
| | | } |
| | |
| | | |
| | | getRolesMenu () { |
| | | // 获取主菜单参数 |
| | | let _param = {func: 's_get_pc_menus', systemType: options.sysType} |
| | | let _param = {func: 's_get_pc_menus', systemType: window.GLOB.sysType} |
| | | _param.pro_sys = window.GLOB.systemType === 'production' ? 'Y' : '' |
| | | |
| | | Api.getSystemConfig(_param).then(result => { |
| | |
| | | const { menulist, thdMenuList } = this.getMenulist(result) |
| | | |
| | | let systems = [] |
| | | if ((options.sysType === 'local' || options.sysType === 'SSO') && result.sys_list) { |
| | | if ((window.GLOB.sysType === 'local' || window.GLOB.sysType === 'SSO') && result.sys_list) { |
| | | systems = result.sys_list |
| | | |
| | | if (options.sysType === 'local' && window.GLOB.systemType !== 'production' && systems.length > 10) { |
| | | if (window.GLOB.sysType === 'local' && window.GLOB.systemType !== 'production' && systems.length > 10) { |
| | | systems.length = 10 |
| | | } |
| | | } |
| | |
| | | |
| | | window.GLOB.mkThdMenus = [...thdMenuList, {MenuID: 'home_page_id', EasyCode: '', MenuName: 'home', type: 'CustomPage'}] |
| | | |
| | | if (_menu) { // 延时打开,防止标签组未完成加载 |
| | | setTimeout(() => { |
| | | MKEmitter.emit('modifyTabs', _menu) |
| | | }, 200) |
| | | if (_menu) { |
| | | this.openTab(_menu, 0) |
| | | } |
| | | MKEmitter.emit('mkMenuLoaded') |
| | | }) |
| | | |
| | | // 获取角色权限, edition_type 接口版本控制 ''、'Y'、'A' |
| | |
| | | }) |
| | | } |
| | | |
| | | MKEmitter.emit('mkActionLoaded') |
| | | window.GLOB.mkActions = _permAction |
| | | }) |
| | | }, 50) |
| | | } |
| | | |
| | | openTab = (menu, times) => { |
| | | if (times > 50) return |
| | | times++ |
| | | |
| | | let tabgroup = document.getElementById('mk-tabgroup-wrap') |
| | | |
| | | if (window.GLOB.mkActions.loaded && tabgroup) { |
| | | MKEmitter.emit('modifyTabs', menu) |
| | | } else { |
| | | setTimeout(() => { |
| | | this.openTab(times) |
| | | }, 200) |
| | | } |
| | | } |
| | | |
| | | getMenulist = (result) => { |
| | |
| | | let PageParam = JSON.parse(fst.PageParam) |
| | | |
| | | if (PageParam.OpenType === 'outpage' && PageParam.linkUrl) { |
| | | fstItem.OpenType = 'outpage' |
| | | fstItem.linkUrl = PageParam.linkUrl |
| | | fstItem.OpenType = 'newpage' |
| | | fstItem.src = PageParam.linkUrl |
| | | if (/#\/iframe\//.test(fstItem.src)) { |
| | | fstItem.src = fstItem.src.replace(/@loginuid@/ig, sessionStorage.getItem('LoginUID')) |
| | | fstItem.type = 'iframe' |
| | | fstItem.OpenType = 'newtab' |
| | | } |
| | | } |
| | | } catch (e) {} |
| | | } |
| | |
| | | trdItem.hidden = PageParam.hidden || 'false' |
| | | |
| | | if (trdItem.type === 'NewPage') { |
| | | trdItem.OpenType = 'newpage' |
| | | trdItem.src = PageParam.url || '' |
| | | if (/#\/iframe\//.test(trdItem.src)) { |
| | | trdItem.src = trdItem.src.replace(/@loginuid@/ig, sessionStorage.getItem('LoginUID')) |
| | | trdItem.type = 'iframe' |
| | | trdItem.OpenType = 'newtab' |
| | | } |
| | | } else if (trdItem.OpenType === 'view') { |
| | | trdItem.OpenType = 'newpage' |
| | | trdItem.src = '#/view/' + trd.MenuID |
| | | } else { |
| | | trdItem.src = '#/tab/' + trd.MenuID |
| | | } |
| | | } catch (e) {} |
| | | } |
| | | |
| | | if (trdItem.type !== 'NewPage') { |
| | | } else { |
| | | trdItem.src = '#/tab/' + trd.MenuID |
| | | } |
| | | |
| | | trdItem.OpenType = trdItem.OpenType.toLowerCase() // NewPage为打开外部页面地址 |
| | | |
| | | if (names.has(trdItem.menu_name)) { |
| | | doublenames.set(trdItem.menu_name, true) |
| | |
| | | loginVisible: true |
| | | }) |
| | | } else { |
| | | sessionStorage.setItem('isEditState', 'true') |
| | | |
| | | this.props.modifyMainMenu(null) |
| | | |
| | | this.props.history.replace('/design') |
| | |
| | | sessionStorage.setItem('cloudDataM', res.dataM ? 'true' : '') |
| | | sessionStorage.setItem('cloudRole_id', res.role_id || '') |
| | | |
| | | sessionStorage.setItem('isEditState', 'true') |
| | | |
| | | let _url = window.location.href.split('#')[0] + 'cloud' |
| | | 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})))) |
| | | } else { |
| | | localStorage.setItem(_url, window.btoa(window.encodeURIComponent(JSON.stringify({time: new Date().getTime(), username: param.username, password: ''})))) |
| | | } |
| | | |
| | | this.props.modifyMainMenu(null) |
| | |
| | | window.addEventListener('storage', (e) => { |
| | | if (e.key === 'getSessionStorage' && e.newValue === window.GLOB.appkey) { |
| | | localStorage.setItem('sessionStorage', JSON.stringify(sessionStorage)) |
| | | } else if (e.key === 'getSysPermission' && e.newValue === window.GLOB.appkey) { |
| | | localStorage.setItem('sysPermissions', JSON.stringify({mkThdMenus: window.GLOB.mkThdMenus, mkActions: window.GLOB.mkActions})) |
| | | } else if (e.key === 'menuUpdate') { |
| | | let menuId = e.newValue.split(',')[1] |
| | | if (menuId) { |
| | | let vals = e.newValue.split(',') |
| | | let menuId = vals[1] |
| | | let position = vals[2] || '' |
| | | if (position === 'menu') { |
| | | MKEmitter.emit('reloadMenuView', menuId) |
| | | } else if (menuId) { |
| | | Api.getAppVersion(menuId).then(() => { |
| | | MKEmitter.emit('reloadMenuView', menuId) |
| | | }) |
| | |
| | | } |
| | | |
| | | gotoDoc = () => { |
| | | if (options.sysType === 'local' && window.GLOB.mainSystemApi) { |
| | | if (window.GLOB.sysType === 'local' && window.GLOB.mainSystemApi) { |
| | | let ssodomain = window.GLOB.mainSystemApi.replace('/webapi/dostars', '') |
| | | 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') { |
| | | } else if (window.GLOB.sysType === 'SSO' || window.GLOB.sysType === 'cloud') { |
| | | window.open(`${window.location.href.replace(/\/admin(.*)|\/index.html(.*)|\/#(.*)/ig, '')}/doc/index.html#?appkey=${window.GLOB.appkey}&LoginUID=${sessionStorage.getItem('LoginUID')}`) |
| | | } |
| | | } |
| | | |
| | | changeVerMenu(menu, type) { |
| | | if (type === 'first') { |
| | | if (menu.OpenType === 'outpage') { |
| | | window.open(menu.linkUrl) |
| | | if (menu.OpenType === 'newpage') { |
| | | window.open(menu.src) |
| | | } else if (menu.OpenType === 'newtab') { |
| | | MKEmitter.emit('modifyTabs', menu) |
| | | } |
| | | } else { |
| | | if (menu.OpenType === 'newpage') { |
| | |
| | | }) |
| | | } |
| | | |
| | | wxnotice = () => { |
| | | Modal.success({ |
| | | className: 'mk-wx-notice', |
| | | title: <QrCode card={{qrWidth: 320, color: '#000000'}} value={window.GLOB.baseurl + 'mob/wxnotice.html?userid=' + sessionStorage.getItem('UserID') + '&loginuid=' + sessionStorage.getItem('LoginUID')}/>, |
| | | okText: '关闭' |
| | | }) |
| | | } |
| | | |
| | | changeToHome = () => { |
| | | if (!['linkage', 'menu_board'].includes(window.GLOB.navBar)) return |
| | | |
| | |
| | | <Menu.Item key="verup" onClick={this.verup}> |
| | | 页面更新 |
| | | </Menu.Item> |
| | | {window.GLOB.WXNotice ? <Menu.Item key="wxnotice" onClick={this.wxnotice}> |
| | | 微信消息 |
| | | </Menu.Item> : null} |
| | | {window.GLOB.appVersion ? <Menu.Item key="version" onClick={this.about}> |
| | | 关于 |
| | | </Menu.Item> : null} |