weaver_trunk_cli/pc4mobx/hrm/components/useDemand/index.js

99 lines
2.7 KiB
JavaScript

import React from 'react'
import {
inject,
observer
} from 'mobx-react'
import {
WeaAlertPage,
WeaLocaleProvider
} from 'ecCom'
import {
Spin
} from 'antd'
import Top from './Top';
import MainDialog from './MainDialog';
const getLabel = WeaLocaleProvider.getLabel;
import '../../style/useDemang.less';
@inject('hrmUsedemand') //todo
@observer
export default class Usedemand extends React.Component { //todo
constructor(props) {
super(props);
}
componentWillMount() {
if (window.location.href.indexOf('/spa/hrm/engine.html') > -1) {
document.title = getLabel('6131', "用工需求"); //todo
}
}
componentWillReceiveProps(nextProps) {
if (this.props.location && (this.props.location.key !== nextProps.location.key)) {
this.props.hrmUsedemand.refresh();
}
}
componentDidMount() {
this.init();
}
init() {
const {
hrmUsedemand
} = this.props, {
getAuth,
onresize
} = hrmUsedemand;
getAuth();
window.addEventListener('resize', onresize);
}
componentWillUnmount() {
const {
hrmUsedemand
} = this.props, {
onresize
} = hrmUsedemand;
window.removeEventListener('resize', onresize);
}
render() {
const {
hrmUsedemand
} = this.props, {
main,
} = hrmUsedemand, {
loading,
authorized
} = main;
if (!authorized) {
return (
<div style={{height: '100%'}}>
{loading ? <div className='hrm-loading-center'>
<Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@6u46g8`} spinning={loading} size='large'></Spin>
</div>
: <div className="hrm-wea-alert-page">
<WeaAlertPage ecId={`${this && this.props && this.props.ecId || ''}_WeaAlertPage@7alk2c`}>
<div style={{ color: '#000' }}>
{getLabel(2012, '对不起,您暂时没有权限!')}
</div>
</WeaAlertPage>
</div>
}
</div>
)
} else {
return (
<div>
<Top ecId={`${this && this.props && this.props.ecId || ''}_Top@l3cg2p`} />
<MainDialog ecId={`${this && this.props && this.props.ecId || ''}_MainDialog@qaznny`} />
</div>
)
}
}
}