import {
WeaTab,
WeaDialog,
WeaFormItem,
WeaPopoverHrm
} from 'ecCom'
import {
Row,
Col,
Spin,
Button,
} from 'antd'
import {
WeaSwitch
} from 'comsMobx'
import {
WeaTableNew
} from 'comsMobx';
import React from 'react';
import {i18n} from '../../public/i18n';
const WeaTable = WeaTableNew.WeaTable;
class MoreWithAdSearch extends React.Component {
constructor(props) {
super(props);
this.state = {
width: 1100,
height: 510,
isPanelShow: false,
conditionNumber: 4,
}
}
componentWillReceiveProps(nextProps) {
if (this.props.condition && nextProps.condition && (this.props.condition !== nextProps.condition) && nextProps.condition[0] && nextProps.condition[0].items) {
this.setConditionNumber(nextProps.condition[0].items.length);
this.setDialogWidth(nextProps.condition);
}
}
getPanelComponents() {
const {
condition,
form,
style
} = this.props;
let arr = [];
let formParams = form.getFormParams();
const {
isFormInit
} = form;
isFormInit && condition.map(c => {
c.items.map((field, index) => {
arr.push(
{}
)
})
})
if (style) {
return {
if ( e.keyCode == 13 && e.target.tagName === "INPUT") {
this.props.search();
this.setPanelStatus(false)
}
}
}
>{arr}
} else {
return {
if ( e.keyCode == 13 && e.target.tagName === "INPUT") {
this.props.search();
this.setPanelStatus(false)
}
}
}
>{arr}
}
}
setPanelStatus(bool) {
this.setState({
isPanelShow: bool
});
}
setConditionNumber(num) {
this.setState({
conditionNumber: num
});
}
setDialogWidth(condition) {
if (this.isConditionHasDate(condition)) {
this.setState({
width: 990
});
}
}
isConditionHasDate(condition) {
if (this.isArray(condition) && condition[0].items) {
let items = condition[0].items;
for (let i = 0; i < items.length; i++) {
if ((items[i].conditionType && items[i].conditionType == 'DATE') && (items[i].domkey && this.isArray(items[i].domkey) && items[i].domkey.length == 3)) {
return true;
}
}
}
return false;
}
isArray(obj) {
return Object.prototype.toString.call(obj) == '[object Array]';
}
reRenderColumns(columns, isNeedReRender) {
if (!isNeedReRender) {
return;
}
const {
dataIndex,
colId,
jumpToHrmCard,
jumpToHrmDept,
jumpToHrmSubCompany,
jumpToHrmPost,
jumpToHrmContract,
isColIdUnusual
} = this.props;
let that = this;
columns.forEach((c, index) => {
if (c.dataIndex == dataIndex[0]) {
c.render = function(text, record) {
return window.pointerXY(e)} >{record[dataIndex[0]]}
}
}
if (c.dataIndex == dataIndex[1] && !isColIdUnusual) {
c.render = function(text, record) {
return jumpToHrmDept(record[colId[1]])}>{record[dataIndex[1]]}
}
}
if (c.dataIndex == dataIndex[1] && isColIdUnusual) { //transfer
c.render = function(text, record) {
return jumpToHrmDept(record[colId[6]])}>{record[dataIndex[1]]}
}
}
if (c.dataIndex == dataIndex[2]) {
c.render = function(text, record) {
return jumpToHrmSubCompany(record[colId[2]])}>{record[dataIndex[2]]}
}
}
if (c.dataIndex == dataIndex[3] && !isColIdUnusual) {
c.render = function(text, record) {
return jumpToHrmPost(record[colId[3]])}>{record[dataIndex[3]]}
}
}
if (c.dataIndex == dataIndex[3] && isColIdUnusual) { //transfer
c.render = function(text, record) {
return jumpToHrmPost(record[colId[7]])}>{record[dataIndex[3]]}
}
}
if (c.dataIndex == dataIndex[4]) {
c.render = function(text, record) {
return jumpToHrmDept(record[colId[4]])}>{record[dataIndex[4]]}
}
}
if (c.dataIndex == dataIndex[5]) {
c.render = function(text, record) {
return jumpToHrmPost(record[colId[5]])}>{record[dataIndex[5]]}
}
}
//Contract
if (c.dataIndex == dataIndex[6]) {
c.render = function(text, record) {
return window.pointerXY(e)}>{record[dataIndex[6]]}
}
}
if (c.dataIndex == dataIndex[7]) {
c.render = function(text, record) {
return { record[dataIndex[7]] }
// return jumpToHrmContract(record[colId[9]])}>{record[dataIndex[7]]}
}
}
if (c.dataIndex == dataIndex[8]) {
c.render = function(text, record) {
return jumpToHrmDept(record[colId[10]])}>{record[dataIndex[8]]}
}
}
if (c.dataIndex == dataIndex[9]) {
c.render = function(text, record) {
return jumpToHrmPost(record[colId[3]])}>{record[dataIndex[9]]}
}
}
})
}
getRowKey = (record,index) => index
render() {
const {
title,
visible,
onCancel,
buttons,
search,
tableStore,
form,
searchsBaseValue,
onSearchChange,
isNeedReRender
} = this.props;
const {
width,
height,
isPanelShow,
conditionNumber
} = this.state;
const btn = [
(),
(),
(),
];
return (
{ onCancel(); this.setPanelStatus(false) } }
buttons={buttons}
style={{width: width, height: 510}}
onChangeHeight={(h) => this.setState({height: h})}
>
this.setPanelStatus(bool) }
hideSearchAd={ () => this.setPanelStatus(false) }
searchsAd= {this.getPanelComponents()}
advanceHeight={ Math.ceil(conditionNumber / 2) * 58.5}
hasMask={false}
buttonsAd={btn}
onSearch={() => search()}
onSearchChange={ (val) => onSearchChange(val)}
/>
this.reRenderColumns(c, isNeedReRender)}
/>
)
}
}
export default MoreWithAdSearch