import React from 'react';
import { inject, observer} from 'mobx-react';
import {WeaTop, WeaTab,WeaRightMenu,WeaTools} from 'ecCom';
import {Spin,Button} from 'antd';
import * as mobx from 'mobx';
import isEmpty from 'lodash/isEmpty';
const toJS = mobx.toJS;
import * as PublicFunc from '../util/pulic-func';
import moment from 'moment';
import {WeaTableNew} from 'comsMobx';
const WeaTable = WeaTableNew.WeaTable;
import {i18n} from '../public/i18n';
@inject('hrmUnderling')
@observer
class HrmUnderling extends React.Component {
componentDidMount() {
this.init();
}
componentWillReceiveProps(nextProps) {
if(this.props.location.key !== nextProps.location.key) {
this.init();
}
}
init = () => {
const { hrmUnderling } = this.props;
let hrmId = this.props.params.hrmId || '';
hrmUnderling.id = hrmId;
hrmUnderling.lastname = '';
hrmUnderling.showAllLevel = false;
hrmUnderling.getSearchList();
}
getTopButtons = () => {
const { hrmUnderling } = this.props;
const { showAllLevel } = hrmUnderling;
let btns =[];
const btnShowAllLevel = ;
btns.push(btnShowAllLevel);
btns.push();
return btns;
}
changeShowAllLevel = () => {
const { hrmUnderling } = this.props;
hrmUnderling.changeShowAllLevel();
}
onSearchChange = v => {
this.props.hrmUnderling.lastname = v;
}
render(){
const { hrmUnderling } = this.props;
let {title,lastname,table} = hrmUnderling;
if(window.location.href.indexOf("/spa/hrm/index_mobx.html")>-1){
if(title){
document.title=title;
}
}
return (
}
iconBgcolor='#217346'
buttons={this.getTopButtons()}
buttonSpace={10}
showDropIcon={true}
dropMenuDatas={this.getRightMenu()}
>
);
}
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;
}
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);
}
jumpToHrmCard = (hrmId) => {
PublicFunc.jumpToHrmCard(hrmId);
}
getRightMenu = () => {
const keys = this.getSelectedRowKeys();
const { hrmUnderling } = this.props;
const arr = [{
icon: ,
content:i18n.button.search(),
key: 'getSearchList',
onClick: hrmUnderling.getSearchList
}, {
icon: ,
content:i18n.button.columnVisibleSetting(),
key: 'definedColumn',
onClick: this.definedColumn
}
];
return arr;
}
getSelectedRowKeys = () => {
const { hrmUnderling } = this.props;
const { table } = hrmUnderling;
const selectedRowKeys = table.selectedRowKeys;
return selectedRowKeys;
}
definedColumn = () => {
const { hrmUnderling } = this.props;
const { table} = hrmUnderling;
table.setColSetVisible(true);
table.tableColSet(true);
}
}
export default HrmUnderling