import React from 'react'; import { inject, observer } from 'mobx-react'; import { Button, Modal, message } from 'antd' import * as mobx from 'mobx'; import isEmpty from 'lodash/isEmpty' import debounce from 'lodash/debounce' // import Immutable from 'immutable' // const is = Immutable.is; import Simple from './simple' import Full from './full' import '../../style/add.less'; import { jumpToHrmCard } from '../../util/pulic-func' import { WeaTab, WeaTop, WeaSearchGroup, WeaRightMenu, WeaPopoverHrm, WeaLeftRightLayout, WeaOrgTree, WeaSelect, WeaErrorPage, WeaTools, WeaFormItem, WeaSearchBrowserBox, WeaDialog, WeaLocaleProvider } from 'ecCom' import { WeaTableNew, WeaSwitch } from 'comsMobx'; const WeaTable = WeaTableNew.WeaTable; import * as PublicFunc from '../../util/pulic-func'; import { i18n } from '../../public/i18n'; const getLabel = WeaLocaleProvider.getLabel; @inject('hrmAdd') @observer class Add extends React.Component { constructor(props) { super(props); } componentDidMount () { const { hrmAdd } = this.props; hrmAdd.setSearchsValue(''); hrmAdd.setDefDialog() hrmAdd.getData(); } componentWillReceiveProps (nextProps) { const { hrmAdd } = this.props; const keyOld = this.props.location.key; const keyNew = nextProps.location.key; if (keyOld !== keyNew) { hrmAdd.setShowSearchAd(false); this.componentDidMount(); } } componentWillUnmount () { const { hrmAdd } = this.props; hrmAdd.setShowSearchAd(false); hrmAdd.simpleVisible = false; } onSimpleCancelHandle = () => { const { hrmAdd } = this.props; hrmAdd.simpleVisible = false; } onFullCancelHandle = () => { const { hrmAdd } = this.props; hrmAdd.fullVisible = false; } render () { const { hrmAdd } = this.props; const { dataKey, title, searchParamsAd, showSearchAd, table, simpleVisible, fullVisible, jobtitleVisible, closeJobtitleDialog, formSimple, formFull, searchsValue } = hrmAdd; return
} iconBgcolor='#217346' buttons={this.getButtons()} buttonSpace={10} showDropIcon={true} dropMenuDatas={this.getRightMenu()} onDropMenuClick={this.onRightMenuClick} >
{ hrmAdd.setShowSearchAd(bool) }} hideSearchAd={() => hrmAdd.setShowSearchAd(false)} searchsAd={
{ if (e.keyCode == 13 && e.target.tagName === "INPUT") { hrmAdd.doSearch(); hrmAdd.setShowSearchAd(false); } }} >{this.getSearchs(true)}
} showSearchAd={showSearchAd} onSearch={hrmAdd.doSearch} onSearchChange={ debounce(v => { hrmAdd.searchsValue = v; }, 200) } />
{ jobtitleVisible && ( { const { id, jobtitlemark } = datas; const form = simpleVisible ? formSimple : formFull; form.updateFields({ jobtitle: { value: id, valueSpan: jobtitlemark, valueObj: [{ id, name: jobtitlemark }] } }); closeJobtitleDialog(); } } url={'/spa/hrm/engine.html#/hrmengine/posts?type=0'} visible={jobtitleVisible} style={{ width: 600, height: 500 }} /> ) }
} reRenderColumns = (columns) => { columns.forEach(c => { if (c.dataIndex == 'lastname') { c.render = (text, record) => { return this.jumpToHrmCard(record.id)}>{record.lastname} } // } else { // c.render = function (text, record) { // let valueSpan = record[c.dataIndex + "span"] !== undefined ? record[c.dataIndex + "span"] : record[c.dataIndex]; // return // } } }) return columns; } jumpToHrmCard = (hrmId) => { jumpToHrmCard(hrmId) } update = () => { const { hrmAdd } = this.props; hrmAdd.update(); } onOperatesClick = (record, index, operate, flag, argumentString) => { const fn = operate.href ? operate.href.split(':')[1].split('(')[0] : ''; const id = record.id ? record.id : ''; PublicFunc[fn](id); } addhrm = () => { const { hrmAdd } = this.props; const { dialogDefShow } = hrmAdd; //此处控制应该显示那种模式的弹窗 if (dialogDefShow == '0') { hrmAdd.simpleVisible = true; } if (dialogDefShow == '1') { hrmAdd.fullVisible = true; } } openFullmode = () => { const { hrmAdd } = this.props; hrmAdd.openFullmode(); } getButtons = () => { const { hrmAdd } = this.props; const { title } = hrmAdd; let btns = []; btns.push( ); return btns } getTabButtonsAd = () => { const { hrmAdd } = this.props; const { formSearch } = hrmAdd; return [ (), (), () ] } getSearchs = (bool) => { const { hrmAdd } = this.props; const { condition, formSearch } = hrmAdd; const { isFormInit } = formSearch; let searchGroupArr = []; isFormInit && condition && condition.forEach((item, index) => { searchGroupArr.push( ) }) return searchGroupArr; } getTitle = (index = 0) => { const { hrmAdd } = this.props; const { condition } = hrmAdd; return !isEmpty(condition) && condition[index].title } isShowFields = (index = 0) => { const { hrmAdd } = this.props; const { condition } = hrmAdd; return !isEmpty(condition) && condition[index].defaultshow } onChangeHandle = debounce((datas) => { const { hrmAdd } = this.props; const { setSearchsValue } = hrmAdd; if (datas.resourcename) { setSearchsValue(datas.resourcename.value); } }, 500) getFields = (bool = false, index = 0) => { const { hrmAdd } = this.props; const { formSearch, condition, setSearchsValue } = hrmAdd; const browserConditions = condition; const fieldsData = !isEmpty(browserConditions) && browserConditions[index].items; let items = new Array(); fieldsData.forEach((field, i) => { field && items.push({ com: { // if (datas.resourcename) { // setSearchsValue(datas.resourcename.value); // } // },500) this.onChangeHandle } /> , colSpan: field.colSpan || 2 }); }); return items; } getTree = () => { return ${i18n.label.organization()}`} topPrefix={'hrmAdd'} treeNodeClick={this.treeNodeClick} params={{ rightStr: 'HrmResourceAdd:Add' }} /> } treeNodeClick = (nodeObj) => { const type = nodeObj.node.props.type || '0'; const id = nodeObj.node.props.id || ''; const name = nodeObj.node.props.name || ''; const { hrmAdd } = this.props; const { formSearch } = hrmAdd; hrmAdd.setShowSearchAd(false); let params = {}; if (type == '1') { params.subcompanyid1 = id; } if (type == '2') { params.departmentid = id; } hrmAdd.doSearch(params); } getRightMenu = () => { const keys = this.getSelectedRowKeys(); const arr = [ { icon: , content: i18n.module.createResource() }, { icon: , content: i18n.button.search() }, { icon: , content: i18n.button.columnVisibleSetting() } // ,{ // icon: , // content:'收藏', // },{ // icon: , // content:'帮助' // } ]; return arr; } onRightMenuClick = (key) => { switch (key) { case '0': this.addhrm(); break; case '1': this.doSearch(); break; case '2': this.definedColumn(); break; } } getSelectedRowKeys = () => { const { hrmAdd } = this.props; const { table } = hrmAdd; const selectedRowKeys = table.selectedRowKeys; return selectedRowKeys; } sendEmessage = () => { const keys = this.getSelectedRowKeys(); const ids = keys ? keys.join(',') : ''; PublicFunc.sendEmessage(ids); } exportExcel = () => { const { hrmAdd } = this.props; const { dataKey } = hrmAdd; dataKey && hrmAdd.exportExcel(dataKey); } doSearch = () => { const { hrmAdd } = this.props; hrmAdd.doSearch(); } definedColumn = () => { const { hrmAdd } = this.props; const { table } = hrmAdd; table.setColSetVisible(true); table.tableColSet(true); } } export default Add