import { Tabs, Row, Col } from 'antd'; import { WeaInput, WeaErrorPage, WeaTools, WeaTableEdit, WeaSearchGroup, WeaRightMenu, WeaFormItem, WeaTab, WeaNewScroll, WeaAlertPage, WeaAvatar, WeaLeftRightLayout } from 'ecCom' import isEmpty from 'lodash/isEmpty' import * as mobx from 'mobx'; import { inject, observer } from 'mobx-react'; import SystemCard from './SystemCard'; import PortraitSetting from './PortraitSetting'; import { routerShape } from 'react-router'; import '../../style/card.less'; const toJS = mobx.toJS; import { WeaPopoverHrm } from 'ecCom'; import TopButton from '../../coms/topButton'; import { i18n } from '../../public/i18n'; import { addContentPath } from '../../util/index.js' const TabPane = Tabs.TabPane; const { ua } = WeaTools; const isIE9 = ua.browser === "IE" @inject('hrmCard') @observer class Main extends React.Component { static contextTypes = { router: routerShape, } constructor(props) { super(props); this.state = { weaWorkplanLoaded: false, rightMenu: [] } } getkey(path) { return path.match(/hrm\/card\/\w+/)[0].split('/')[2] || ''; } componentWillReceiveProps(nextProps) { const key = this.getkey(nextProps.location.pathname); if (this.props.location.key !== nextProps.location.key && key == 'cardInfo') { this.init(nextProps); } } componentWillMount() { // 异步加载日程模块静态资源 eventRegister.loadModule('f_workplan', () => { this.setState({ weaWorkplanLoaded: true }); }, () => { }); } componentDidMount() { this.init(); } init = (nextProps) => { const { hrmCard } = nextProps || this.props; const { pathname } = (nextProps || this.props).location; const key = this.getkey(pathname); const hrmId = (nextProps || this.props).params.hrmId || ''; //const hrmId = pathname.match(/cardInfo\/\w+/)[0].split('/')[1] hrmCard.init(key); hrmCard.verifyIsAdmin({ id: hrmId }); hrmCard.getData({ id: hrmId }); } setParentRightMenu = rightMenu => this.setState({ rightMenu }) getTabChildren() { const { hrmCard, children } = this.props; let { tabInfo, tabKey, } = hrmCard; let isIframe = false; let ifame; let innerPage = false; if (window.location.href.indexOf("/spa/hrm/index_mobx.html") == -1) { innerPage = true; } tabInfo = toJS(tabInfo); tabInfo && tabInfo.forEach((t) => { if (tabKey === t.key) { if (t.isIframe) { isIframe = true; if (t.key == 'iframe-9-workplansearch') { // 日程模块加载方式 const selectedUser = t.url.split('?')[1].split('&')[1].split('=')[1]; this.state.weaWorkplanLoaded && window.weaWorkplan && window.weaWorkplan.com ? ifame = : '' } else { ifame = } } } }); return ( {isIframe ? ifame : children} ); } render() { const { hrmCard } = this.props; let { verified, isAdmin, info, tabInfo, tabKey, showPortraitSetting, uploadPortrailAuth, hasRight, userId, setState, updateSuccess, topRightMenus } = hrmCard; const rightMenu = topRightMenus && topRightMenus() || []; info = toJS(info); const portraitDefalut = '/messager/images/icon_m_wev8.jpg'; if (window.location.href.indexOf("/spa/hrm/index_mobx.html") > -1) { if (info) { let lastname = info.lastname || ''; document.title = lastname ? i18n.label.resourceCard() + '-' + lastname : i18n.label.resourceCard(); } } if (verified) { if (hasRight) { if (verified && isAdmin) { return ( ) } if (verified && !isAdmin) { const avatarProps = { userId }; if (info.requestParams) Object.assign(avatarProps, { requestParams: JSON.parse(info.requestParams) }); return ( { this.tabsOnChange(v); }} tabPosition="left" />} >
{ !isEmpty(info) && { info.shortname != null && info.shortname.trim().length > 0 ?
{info.shortname}
: {/* */} { if (updateSuccess && result) { result.requestParams && result.requestParams(userId); setState({ updateSuccess: false }); } }} /> }
{info.lastname} { info.workcode ? ( ({info.workcode.indexOf('desensitization__') > -1 ? : info.workcode}) ) : null } { info.sex && }
{ info.orginfo ?
:
 
} }
{this.getTabChildren()}
{uploadPortrailAuth && }
) } } else { return (
{i18n.message.authFailed()}
) } } return (
) } tabsOnChange(key) { const { hrmCard } = this.props; this.setState({ rightMenu: [] }) hrmCard.setTopButtons(null); hrmCard.setTopRightMenus(null); hrmCard.setTopShowDropIcon(false); let { tabInfo } = hrmCard; hrmCard.changeTab(key); tabInfo = toJS(tabInfo); tabInfo && tabInfo.forEach((t) => { if (t.key === key && !t.isIframe) { this.context.router.push({ pathname: t.pathname, query: { fromcard: true } }) } }) } } export default Main;