import React from 'react';
import { inject, observer} from 'mobx-react';
import {WeaTop, WeaTab,WeaRightMenu,WeaErrorPage,WeaSearchGroup,WeaFormItem,WeaSelect,WeaAlertPage,} from 'ecCom';
import {Button, Spin} from 'antd';
import {routerShape} from 'react-router';
import * as mobx from 'mobx';
const toJS = mobx.toJS;
import {WeaTableNew,WeaSwitch} from 'comsMobx';
import {i18n} from '../../public/i18n';
const WeaTable = WeaTableNew.WeaTable;
@inject('hrmRpSubSearch')
@observer
class RpSubSearch extends React.Component {
static contextTypes = {
router: routerShape
}
constructor(props) {
super(props);
const funcs = ['jumpToReport'];
funcs.forEach(f=> this[f] = this[f].bind(this))
}
componentDidMount() {
const { hrmRpSubSearch } = this.props;
hrmRpSubSearch.getHasRight();
}
componentWillReceiveProps(nextProps) {
const { hrmRpSubSearch } = this.props;
if(this.props.location.key !== nextProps.location.key){
hrmRpSubSearch.getHasRight();
}
}
render(){
const { hrmRpSubSearch } = this.props;
const {title,form,table,showSearchAd,searchParamsAd,verified,hasRight} = hrmRpSubSearch;
if (verified && hasRight) {
const formParams = form.getFormParams();
let loadingTable = table.loading;
return (
}
iconBgcolor='#217346'
buttons={[]}
buttonSpace={10}
showDropIcon={false}
>
{hrmRpSubSearch.setShowSearchAd(bool)}}
hideSearchAd={() => hrmRpSubSearch.setShowSearchAd(false)}
searchsAd={{
if ( e.keyCode == 13 && e.target.tagName === "INPUT") {
hrmRpSubSearch.doSearch();
hrmRpSubSearch.setShowSearchAd(false)
}
}
}
>{this.getSearchs()}
}
showSearchAd={showSearchAd}
onSearch={v => {hrmRpSubSearch.doSearch()}}
advanceHeight={150}
onSearchChange={v => {
form.updateFields({
formlabel:{name:'formlabel',value:v},
});
}}
/>
);
}
if (verified && !hasRight) {
return (
{i18n.message.authFailed()}
)
}
return (
)
}
getSearchs() {
const { hrmRpSubSearch } = this.props;
const { form,condition } = hrmRpSubSearch;
const {isFormInit} = form;
let group = [];
const formParams = form.getFormParams();
isFormInit && toJS(condition).map((c, i) =>{
let items = [];
c.items.map((fields, j) => {
let dom = ;
items.push({
com:(
{dom}
),
colSpan:1,
})
});
group.push()
});
return group;
}
reRenderColumns = (columns) => {
columns.forEach(c=>{
if(c.dataIndex=='formlabel'){
c.render = (text, record) => {
return this.jumpToReport(record.randomFieldId)}>{record.formlabel}
}
} else {
c.render = function(text, record){
let valueSpan = record[c.dataIndex + "span"] !== undefined ? record[c.dataIndex + "span"] : record[c.dataIndex];
return
}
}
})
return columns;
}
jumpToReport = (scopeId) => {
let {router} = this.context;
if (router) {
router.push({
pathname: `/main/hrm/constrpsubsearch/${scopeId}`,
query: {isCustom: "1"}
});
}
}
getRightMenu(){
const keys = this.getSelectedRowKeys();
const arr = [{
icon: ,
content:i18n.button.search()
}, {
icon: ,
content:i18n.button.columnVisibleSetting()
}
];
return arr;
}
onRightMenuClick(key){
const { hrmRpSubSearch } = this.props;
switch(key){
case '0':
hrmRpSubSearch.doSearch();
break;
case '1':
this.definedColumn();
break;
}
}
getSelectedRowKeys(){
const { hrmRpSubSearch } = this.props;
const { table} = hrmRpSubSearch;
const selectedRowKeys = table.selectedRowKeys;
return selectedRowKeys;
}
definedColumn() {
const { hrmRpSubSearch } = this.props;
const { table} = hrmRpSubSearch;
table.setColSetVisible(true);
table.tableColSet(true);
}
getTabButtonsAd() {
const { hrmRpSubSearch } = this.props;
const { form,searchParamsAd } = hrmRpSubSearch;
return [
(),
(),
()
]
}
}
export default RpSubSearch