| | |
| | | |
| | | import Api from '@/api' |
| | | import asyncComponent from '@/utils/asyncLoadComponent' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import './index.scss' |
| | | |
| | | const CustomPage = asyncComponent(() => import('@/tabviews/custom')) |
| | |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | const { menuId, loginUid, bid } = this.props.match.params |
| | | const { params, path } = this.props.match |
| | | const { menuId, loginUid, bid } = params |
| | | |
| | | if (sessionStorage.getItem('UserID')) { |
| | | if (/^\/view\//.test(path)) { |
| | | localStorage.setItem('getSysPermission', window.GLOB.appkey) |
| | | |
| | | window.addEventListener('storage', function(event) { |
| | | if (event.key === 'sysPermissions' && event.newValue) { |
| | | let values = event.newValue |
| | | values = JSON.parse(values) |
| | | |
| | | window.GLOB.mkThdMenus = values.mkThdMenus |
| | | window.GLOB.mkActions = values.mkActions |
| | | } |
| | | }) |
| | | |
| | | setTimeout(() => { |
| | | localStorage.removeItem('getSysPermission') |
| | | localStorage.removeItem('sysPermissions') |
| | | |
| | | if (window.GLOB.mkActions) { |
| | | this.setState({loading: false}) |
| | | } else { |
| | | this.getPermRole() |
| | | } |
| | | }, 20) |
| | | } else if (sessionStorage.getItem('UserID')) { |
| | | this.getPermRole() |
| | | } else { |
| | | sessionStorage.setItem('LoginUID', loginUid) |
| | |
| | | this.setState({BID: bid || '', MenuId: menuId}) |
| | | } |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('modifyTabs', this.modifyTabs) |
| | | MKEmitter.addListener('closeTabView', this.closeTabView) |
| | | } |
| | | |
| | | /** |
| | | * @description 组件销毁,清除state更新 |
| | | */ |
| | | componentWillUnmount () { |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('modifyTabs', this.modifyTabs) |
| | | MKEmitter.removeListener('closeTabView', this.closeTabView) |
| | | } |
| | | |
| | | modifyTabs = (tab) => { |
| | | const { MenuId, BID } = this.state |
| | | |
| | | let _menuId = tab.MenuID |
| | | let _BID = tab.param && tab.param.$BID ? tab.param.$BID : '' |
| | | |
| | | let historys = sessionStorage.getItem('page_historys') |
| | | historys = historys ? JSON.parse(historys) : [] |
| | | |
| | | historys.push({MenuId: MenuId, BID: BID}) |
| | | |
| | | sessionStorage.setItem('page_historys', JSON.stringify(historys)) |
| | | |
| | | this.setState({ |
| | | MenuId: _menuId, |
| | | BID: _BID, |
| | | loading: true |
| | | }, () => { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | closeTabView = () => { |
| | | let historys = sessionStorage.getItem('page_historys') |
| | | historys = historys ? JSON.parse(historys) : [] |
| | | |
| | | if (historys.length === 0) return |
| | | |
| | | let tab = historys.shift() |
| | | |
| | | sessionStorage.setItem('page_historys', JSON.stringify(historys)) |
| | | |
| | | this.setState({ |
| | | MenuId: tab.MenuId, |
| | | BID: tab.BID, |
| | | loading: true |
| | | }, () => { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | getPermRole = () => { |
| | | Api.getSystemConfig({ |
| | | func: 's_Get_TrdMenu_Role', |