import React from 'react'; import { inject, observer} from 'mobx-react'; import {WeaTop, WeaTab,WeaRightMenu,WeaErrorPage,WeaSearchGroup,WeaFormItem,WeaSelect,WeaAlertPage,} from 'ecCom'; import {Row,Col,Button} from 'antd'; import * as mobx from 'mobx'; import isEmpty from 'lodash/isEmpty'; const toJS = mobx.toJS; import * as PublicFunc from '../util/pulic-func'; window.openFullWindowForXtable = PublicFunc.openFullWindowForXtable; import moment from 'moment'; import {WeaTableNew,WeaSwitch} from 'comsMobx'; import {i18n} from '../public/i18n'; const WeaTable = WeaTableNew.WeaTable; @inject('hrmTrainRecord') @inject('hrmCard') @observer class HrmTrainRecord extends React.Component { componentDidMount() { const { hrmTrainRecord, hrmCard } = this.props; const {changeId} = hrmTrainRecord; let hrmId = this.props.params.hrmId || ''; hrmCard.setTopRightMenus(this.getRightMenu.bind(this)); changeId(hrmId) this.changeTab('1'); } componentWillReceiveProps(nextProps) { if(this.props.location.key !== nextProps.location.key) { this.changeTab('1'); } } onKeyDown = (e) => { if ( e.keyCode == 13 && e.target.tagName === "INPUT") { this.props.hrmTrainRecord.doSearch(); this.props.hrmTrainRecord.setShowSearchAd(false) } } onSearch = v => { this.props.hrmTrainRecord.form.updateFields({ planname:{name:'planname',value:v}, }); } render(){ const { hrmTrainRecord } = this.props; let {title,form,table,showSearchAd,searchParamsAd,tabkey,tabDatas} = hrmTrainRecord; tabDatas = toJS(tabDatas); const {query} = this.props.location; const formParams = form.getFormParams(); return (
} iconBgcolor='#217346' buttons={this.getTopButtons()} buttonSpace={10} showDropIcon={true} dropMenuDatas={this.getRightMenu()} />
{hrmTrainRecord.setShowSearchAd(bool)}} hideSearchAd={() => hrmTrainRecord.setShowSearchAd(false)} searchsAd={
{this.getSearchs()}
} showSearchAd={showSearchAd} onSearch={hrmTrainRecord.doSearch} onSearchChange={this.onSearch} />
); } changeTab = (key) => { const {hrmTrainRecord} = this.props; hrmTrainRecord.changeTab(key); } getSearchs = () => { const { hrmTrainRecord } = this.props; const { form,condition } = hrmTrainRecord; const {isFormInit} = form; let group = []; const formParams = form.getFormParams(); isFormInit && condition.map((c, i) =>{ let items = []; c.items.map((fields, j) => { let hide = false; let dom = ; items.push({ com:( {dom} ), colSpan:1, hide: hide }) }); group.push() }); return group; } onOperatesClick = (record,index,operate,flag,argumentString) => { const { hrmTrainRecord } = this.props; const { condition } = hrmTrainRecord; const fn = operate.href ? operate.href.split(':')[1].split('(')[0] : ''; const id = record.id ? record.id : ''; const applyworkflowid = !isEmpty(condition) && condition[0].applyworkflowid if(fn && fn=='jsHrmTrainApply'){ PublicFunc[fn](id,applyworkflowid); }else{ PublicFunc[fn](id); } } getRightMenu = () => { const { hrmTrainRecord } = this.props; let arr = []; try{ arr = [{ icon: , content:i18n.button.search(), key: 'search', onClick: hrmTrainRecord.doSearch }, { icon: , content:i18n.button.columnVisibleSetting(), key: 'definedColumn', onClick: this.definedColumn } ]; }catch(e){} return arr; } onRightMenuClick = (key) => { const { hrmTrainRecord } = this.props; switch(key){ case '0': hrmTrainRecord.doSearch(); break; case '1': this.definedColumn(); break; } } getSelectedRowKeys = () => { const { hrmTrainRecord } = this.props; const { table} = hrmTrainRecord; const selectedRowKeys = table.selectedRowKeys; return selectedRowKeys; } definedColumn = () => { const { hrmTrainRecord } = this.props; const { table} = hrmTrainRecord; table.setColSetVisible(true); table.tableColSet(true); } getTabButtonsAd = () => { const { hrmTrainRecord } = this.props; const { form,searchParamsAd } = hrmTrainRecord; return [ (), (), () ] } getTopButtons = () => { const { hrmTrainRecord } = this.props; return [ () ] } } export default HrmTrainRecord