| | |
| | | import React, {Component} from 'react' |
| | | import { Spin } from 'antd' |
| | | import { Spin, notification } from 'antd' |
| | | |
| | | import Api from '@/api' |
| | | import asyncComponent from '@/utils/asyncLoadComponent' |
| | | import './index.scss' |
| | | |
| | | const CustomPage = asyncComponent(() => import('@/tabviews/custom')) |
| | | const BaseTable = asyncComponent(() => import('@/tabviews/basetable')) |
| | | |
| | | class MkIframe extends Component { |
| | | state = { |
| | | loading: true |
| | | loading: true, |
| | | BID: '', |
| | | MenuId: '', |
| | | type: 'CustomPage' |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | const { menuId, userId, loginUid, bid } = this.props.match.params |
| | | const { menuId, loginUid, bid } = this.props.match.params |
| | | |
| | | sessionStorage.setItem('LoginUID', '202306221645124938E53FE0520A64CE2B486') |
| | | // sessionStorage.setItem('LoginUID', loginUid) |
| | | console.log(userId) |
| | | Api.getTouristMsg('login_check', 'http://demo.mk9h.cn/erp_new/webapi/dostars').then(res => { |
| | | console.log(res) |
| | | if (res.status) { |
| | | |
| | | if (sessionStorage.getItem('UserID')) { |
| | | this.getPermRole() |
| | | } else { |
| | | sessionStorage.setItem('LoginUID', loginUid) |
| | | |
| | | Api.getTouristMsg('login_check').then(res => { |
| | | if (res.status) { |
| | | sessionStorage.setItem('UserID', res.UserID) |
| | | sessionStorage.setItem('LoginUID', res.LoginUID) |
| | | sessionStorage.setItem('User_Name', res.UserName) |
| | | sessionStorage.setItem('Full_Name', res.FullName) |
| | | sessionStorage.setItem('avatar', res.icon || '') |
| | | sessionStorage.setItem('dataM', res.dataM ? 'true' : '') |
| | | sessionStorage.setItem('debug', res.debug || '') |
| | | sessionStorage.setItem('role_id', res.role_id || '') |
| | | sessionStorage.setItem('departmentcode', res.departmentcode || '') |
| | | sessionStorage.setItem('organization', res.organization || '') |
| | | sessionStorage.setItem('mk_user_type', res.mk_user_type || '') |
| | | this.getPermRole() |
| | | } else { |
| | | sessionStorage.clear() |
| | | sessionStorage.setItem('iframe', `/iframe/${menuId}/@loginuid@/${bid || ''}`) |
| | | this.props.history.replace('/login') |
| | | } |
| | | }) |
| | | } |
| | | |
| | | componentDidMount() { |
| | | // sessionStorage.setItem('ThirdMenu', this.props.match.params.menuId) |
| | | this.setState({BID: bid || '', MenuId: menuId}) |
| | | } |
| | | |
| | | // if (sessionStorage.getItem('UserID')) { |
| | | // this.props.history.replace('/main') |
| | | // } else { |
| | | // localStorage.setItem('getSessionStorage', window.GLOB.appkey) |
| | | getPermRole = () => { |
| | | Api.getSystemConfig({ |
| | | func: 's_Get_TrdMenu_Role', |
| | | edition_type: 'A', |
| | | pro_sys: window.GLOB.systemType === 'production' ? 'Y' : '' |
| | | }).then(result => { |
| | | if (!result.status) { |
| | | notification.error({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | // window.addEventListener('storage', function(event) { |
| | | // if (event.key === 'sessionStorage' && event.newValue && !sessionStorage.getItem('UserID')) { |
| | | // let values = event.newValue |
| | | // values = JSON.parse(values) |
| | | let _permAction = {loaded: true} // 按钮权限 |
| | | |
| | | // Object.keys(values).forEach(key => { |
| | | // sessionStorage.setItem(key, values[key]) |
| | | // }) |
| | | // } |
| | | // }) |
| | | if (result.UserRoles_Menu) { |
| | | result.UserRoles_Menu.forEach(menu => { |
| | | if (!menu.MenuID) return |
| | | _permAction[menu.MenuID] = true |
| | | }) |
| | | } |
| | | |
| | | // setTimeout(() => { |
| | | // localStorage.removeItem('getSessionStorage') |
| | | // localStorage.removeItem('sessionStorage') |
| | | window.GLOB.mkActions = _permAction |
| | | |
| | | // if (sessionStorage.getItem('UserID')) { |
| | | // this.props.history.replace('/main') |
| | | // } else { |
| | | // this.props.history.replace('/login') |
| | | // } |
| | | // }, 20) |
| | | // } |
| | | this.setState({loading: false}) |
| | | }) |
| | | } |
| | | |
| | | changeTemp = (MenuID, Template) => { |
| | | this.setState({ |
| | | type: Template |
| | | }) |
| | | } |
| | | |
| | | render () { |
| | | const { loading, BID, MenuId, type } = this.state |
| | | |
| | | return ( |
| | | <div className="main-iframe"> |
| | | <Spin size="large" /> |
| | | {loading ? <Spin size="large" /> : null} |
| | | {!loading && type === 'CustomPage' ? <CustomPage MenuID={MenuId} param={{$BID: BID}} changeTemp={this.changeTemp}/> : null} |
| | | {!loading && type === 'BaseTable' ? <BaseTable MenuID={MenuId} param={{$BID: BID}} changeTemp={this.changeTemp}/> : null} |
| | | </div> |
| | | ) |
| | | } |