import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import { notification, Spin } from 'antd'
|
|
import Api from '@/api'
|
import asyncComponent from '@/utils/asyncComponent'
|
import './index.scss'
|
|
const DefaultHome = asyncComponent(() => import('./defaulthome'))
|
const CustomPage = asyncComponent(() => import('@/tabviews/custom'))
|
|
class Home extends Component {
|
static propTpyes = {
|
MenuID: PropTypes.string, // 菜单Id
|
}
|
|
state = {
|
loading: true,
|
view: ''
|
}
|
|
componentDidMount () {
|
this.loadHomeConfig()
|
}
|
|
loadHomeConfig = () => {
|
let _param = {
|
func: 'sPC_Get_LongParam',
|
MenuID: this.props.MenuID
|
}
|
Api.getCacheConfig(_param).then(result => {
|
if (result.status) {
|
if (result.LongParam) {
|
this.setState({
|
loading: false,
|
view: 'custom'
|
})
|
} else {
|
this.setState({
|
loading: false,
|
view: 'default'
|
})
|
}
|
} else {
|
this.setState({
|
loading: false,
|
view: 'default'
|
})
|
notification.warning({
|
top: 92,
|
message: result.message,
|
duration: 5
|
})
|
}
|
})
|
}
|
|
render() {
|
const { loading, view } = this.state
|
|
if (loading) {
|
return (<Spin className="home-box-spin" size="large" />)
|
} else if (view === 'custom') {
|
return (<CustomPage MenuID={this.props.MenuID}/>)
|
} else {
|
return (<DefaultHome />)
|
}
|
}
|
}
|
|
export default Home
|