import React from 'react'; import { inject, observer } from 'mobx-react'; import {routerShape} from 'react-router'; import { Button} from 'antd'; import {Condition} from '../list/listCondition'; import {WeaRightMenu,WeaTop,WeaErrorPage,WeaTools,WeaAlertPage,WeaLocaleProvider} from 'ecCom'; const getLabel = WeaLocaleProvider.getLabel; @inject('prjMonitorStore') @observer class ProjectMonitor extends React.Component { static contextTypes = { router: routerShape } constructor(props) { super(props); } componentDidMount(){ const { prjMonitorStore } = this.props; const {initDatas} = prjMonitorStore; WeaTools.callApi('/api/proj/pcproject/getPrjMonitorRight', 'GET', {}).then(data=>{ prjMonitorStore.hasRight = data.isright; prjMonitorStore.verified = true; if(data.isright){ initDatas({},true); //initTreeDatas(); } }); } componentWillReceiveProps(nextProps){ const { prjMonitorStore } = this.props; const {initDatas} = prjMonitorStore; if(this.props.location.key !== nextProps.location.key){ WeaTools.callApi('/api/proj/pcproject/getPrjMonitorRight', 'GET', {}).then(data=>{ prjMonitorStore.hasRight = data.isright; prjMonitorStore.verified = true; if(data.isright){ initDatas({},true); //initTreeDatas(); } }); } } resetHeight(height){ jQuery(".prj-query-condition").height(height - 60); } render(){ const {prjMonitorStore} = this.props; const {loading,form,verified,hasRight} = prjMonitorStore; if (verified && !hasRight) { return (
{getLabel(2012,"对不起,您暂时没有权限!")}
) } if (verified && hasRight) { return (
} iconBgcolor='#217346' buttons={[]} getHeight={this.resetHeight.bind(this)} buttonSpace={10} showDropIcon={true} dropMenuDatas={this.getRightMenu()} >
{this.getSearchButtons()}
) } return (
) } getRightMenu(){ let btns = []; btns.push({ key: "search", icon: , content:getLabel(197,"搜索"), onClick: this.forwardQueryResult.bind(this) }); return btns; } getSearchButtons() { const { prjMonitorStore } = this.props; const {clearFormFields,setSelectedTreeKey} = prjMonitorStore; const btnStyle = {borderRadius: 3, minWidth: 80} return [ (), (), () ] } forwardQueryResult(){ const path = "/monitorResult"; this.context.router.push({ pathname: "/main/prj"+path }); } } export default WeaTools.tryCatch(React, props => , {error: ""} )(ProjectMonitor);