| | |
| | | |
| | | import { |
| | | toggleCollapse, |
| | | modifyMenuTree, |
| | | modifyMainMenu, |
| | | modifyTabview, |
| | | initActionPermission, |
| | | initMenuPermission, |
| | | logout |
| | | } from '@/store/action' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import Api from '@/api' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import options from '@/store/options.js' |
| | |
| | | import enUS from '@/locales/en-US/main.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import avatar from '@/assets/img/avatar.jpg' |
| | | import Resetpwd from './resetpwd' |
| | | import LoginForm from './loginform' |
| | | import './index.scss' |
| | | |
| | | const { confirm } = Modal |
| | | const { Search } = Input |
| | | const Resetpwd = asyncComponent(() => import('./resetpwd')) |
| | | const LoginForm = asyncComponent(() => import('./loginform')) |
| | | |
| | | class Header extends Component { |
| | | static propTpyes = { |
| | |
| | | confirmLoading: false, |
| | | userName: sessionStorage.getItem('User_Name'), |
| | | logourl: window.GLOB.mainlogo, |
| | | appVersion: window.GLOB.appVersion, |
| | | loginVisible: false, |
| | | loginLoading: false, |
| | | avatar: Utils.getrealurl(sessionStorage.getItem('avatar')), |
| | |
| | | if (result.status) { |
| | | notification.success({ |
| | | top: 92, |
| | | message: this.state.dict['main.password.resetsuccess'], |
| | | message: '修改成功,请重新登录。', |
| | | duration: 2 |
| | | }) |
| | | setTimeout(() => { |
| | | sessionStorage.clear() |
| | | this.props.logout() |
| | | this.props.history.replace('/login') |
| | | }, 2000) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | // 获取角色权限 |
| | | 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) |
| | | }) |
| | | |
| | | // 获取主菜单参数 |
| | |
| | | sessionStorage.removeItem('ThirdMenu') |
| | | } |
| | | |
| | | this.props.modifyMenuTree(menulist) |
| | | this.props.modifyMainMenu(mainMenu) |
| | | this.props.initMenuPermission([...thdMenuList, {MenuID: 'home_page_id', EasyCode: '', MenuName: 'home', type: 'CustomPage'}]) |
| | | |
| | |
| | | |
| | | Promise.all([roledefer, menudefer]).then(response => { |
| | | if (response[1]) { |
| | | let tabs = fromJS(this.props.tabviews).toJS() |
| | | let menu = fromJS(response[1]).toJS() |
| | | |
| | | if (this.state.navBar === 'topmenu') { |
| | | menu.selected = true |
| | | this.props.modifyTabview([menu]) |
| | | if (this.state.navBar === 'topmenu' && this.state.menuType !== 'menu_board_navigation') { |
| | | MKEmitter.emit('modifyTabs', menu, 'replace') |
| | | } else { |
| | | tabs = tabs.map(tab => { |
| | | tab.selected = false |
| | | return tab |
| | | }) |
| | | |
| | | menu.selected = true |
| | | tabs.push(menu) |
| | | this.props.modifyTabview(tabs) |
| | | MKEmitter.emit('modifyTabs', menu, 'plus') |
| | | } |
| | | } |
| | | }) |
| | |
| | | sessionStorage.setItem('dataM', sessionStorage.getItem('cloudDataM')) |
| | | sessionStorage.setItem('isEditState', 'true') |
| | | |
| | | this.props.modifyMenuTree([]) |
| | | this.props.modifyMainMenu(null) |
| | | this.props.modifyTabview([]) |
| | | |
| | | this.props.history.replace('/design') |
| | | } |
| | |
| | | sessionStorage.setItem('isEditState', 'true') |
| | | |
| | | this.setSystemFuncs() |
| | | |
| | | this.props.modifyMenuTree([]) |
| | | this.props.modifyMainMenu(null) |
| | | this.props.modifyTabview([]) |
| | | |
| | | this.props.history.replace('/design') |
| | | } else { |
| | | if (res.message.indexOf('密码错误') > -1) { |
| | |
| | | this.getRolesMenu() |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | if (!is(fromJS(this.props.menuTree), fromJS(nextProps.menuTree)) && !is(fromJS(this.state.menulist), fromJS(nextProps.menuTree))) { |
| | | this.setState({ |
| | | menulist: nextProps.menuTree |
| | | }) |
| | | } |
| | | } |
| | | |
| | | componentDidMount () { |
| | | // 获取系统的版本信息,延时查询 |
| | | setTimeout(() => { |
| | |
| | | if (menu.OpenType === 'newpage' || menu.OpenType === 'NewPage') { // NewPage为打开外部页面地址,newpage为打开系统菜单 |
| | | window.open(menu.src) |
| | | } else if (menu.OpenType === 'blank') { |
| | | menu.selected = true |
| | | this.props.modifyTabview([menu]) |
| | | MKEmitter.emit('modifyTabs', menu, 'replace') |
| | | } else if (this.state.navBar === 'topmenu' && this.state.menuType !== 'menu_board_navigation') { |
| | | menu.selected = true |
| | | this.props.modifyTabview([menu]) |
| | | MKEmitter.emit('modifyTabs', menu, 'replace') |
| | | } else { |
| | | let tabs = fromJS(this.props.tabviews).toJS() |
| | | tabs = tabs.filter(tab => { |
| | | tab.selected = false |
| | | return tab.MenuID !== menu.MenuID |
| | | }) |
| | | |
| | | if (this.props.tabviews.length > tabs.length) { |
| | | this.props.modifyTabview(fromJS(tabs).toJS()) |
| | | } |
| | | |
| | | this.setState({}, () => { |
| | | menu.selected = true |
| | | tabs.push(menu) |
| | | this.props.modifyTabview(tabs) |
| | | }) |
| | | MKEmitter.emit('modifyTabs', menu, 'plus') |
| | | } |
| | | |
| | | if (window.GLOB.systemType === 'production') { |
| | |
| | | |
| | | verup = () => { |
| | | confirm({ |
| | | title: '版本升级', |
| | | title: '页面更新', |
| | | content: '重新加载应用信息', |
| | | onOk() { |
| | | return new Promise(resolve => { |
| | | if (!window.GLOB.WebSql && !window.GLOB.IndexDB) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '升级失败,请刷新页面重试!', |
| | | message: '更新失败,请刷新页面重试!', |
| | | duration: 2 |
| | | }) |
| | | resolve() |
| | |
| | | setTimeout(() => { |
| | | notification.success({ |
| | | top: 92, |
| | | message: '升级成功!', |
| | | message: '更新成功!', |
| | | duration: 2 |
| | | }) |
| | | resolve() |
| | |
| | | }) |
| | | } |
| | | |
| | | about = () => { |
| | | Modal.success({ |
| | | title: '系统版本v' + this.state.appVersion |
| | | }) |
| | | } |
| | | |
| | | render () { |
| | | const { mainMenu, collapse } = this.props |
| | | const { thdMenuList, searchkey, debug, menulist, navBar, menuType } = this.state |
| | | const { thdMenuList, searchkey, debug, menulist, navBar, menuType, appVersion } = this.state |
| | | |
| | | const menu = ( |
| | | <Menu className="header-dropdown"> |
| | |
| | | </Menu.SubMenu> : null} |
| | | <Menu.Item key="doc" onClick={this.gotoDoc}>{this.state.dict['main.doc']}</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> |
| | | ) |
| | |
| | | |
| | | const mapStateToProps = (state) => { |
| | | return { |
| | | tabviews: state.tabviews, |
| | | collapse: state.collapse, |
| | | menuTree: state.menuTree, |
| | | mainMenu: state.mainMenu, |
| | | permAction: state.permAction, |
| | | mainMenu: state.mainMenu |
| | | } |
| | | } |
| | | |
| | | const mapDispatchToProps = (dispatch) => { |
| | | return { |
| | | toggleCollapse: (collapse) => dispatch(toggleCollapse(collapse)), |
| | | modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)), |
| | | modifyMenuTree: (menuTree) => dispatch(modifyMenuTree(menuTree)), |
| | | modifyMainMenu: (mainMenu) => dispatch(modifyMainMenu(mainMenu)), |
| | | initActionPermission: (permAction) => dispatch(initActionPermission(permAction)), |
| | | initMenuPermission: (permMenus) => dispatch(initMenuPermission(permMenus)), |