else
return '';
}
initTab = (props) => {
return React.cloneElement(, {
...props
});
}
renderTabNav = () => {
//data
const {
activeTabInfo,
tabConfig,
tabChangeHandle,
tabBtnDef,
conditionForm,
conditionFormFields,
advanceHeight,
store,
leftStyle,
} = this.props;
let tabInfo = tabConfig.tabs[activeTabInfo.activeTabIndex];
let tabsData = cloneDeep(tabConfig.tabs) || [];
tabsData != null && tabsData.map(tab => {
if (typeof(tab.title) == 'function'){
tab.title = tab.title();
}
delete tab.topButtonDef;
delete tab.tabButtonDef;
});
let tabProps = {
type: 'editable-inline',
datas: tabsData,
keyParam: tabConfig.keyParam,
selectedKey: tabConfig.activeTabKey,
onChange: tabChangeHandle,
leftStyle
}
tabBtnDef && Object.assign(tabProps, {
buttons: tabBtnDef
});
const searchType = tabInfo.searchType || [];
if (searchType.length > 0) {
Object.assign(tabProps, {
searchType: searchType,
onSearch: (value) => {
if (searchType.indexOf('advanced') >= 0) {
tabInfo.doSearch(conditionForm.getFormParams());
} else {
tabInfo.doSearch({
[tabInfo.searchKey]: value
});
}
}
});
if (searchType.indexOf('advanced') >= 0 && conditionForm != null && conditionForm.isFormInit) {
const formParams = conditionForm.getFormParams();
Object.assign(tabProps, {
searchsBaseValue: formParams[tabInfo.searchKey] || '',
showSearchAd: this.state.showSearchAd,
setShowSearchAd: (bool) => {
this.setState({
showSearchAd: bool
})
},
onSearchChange: (value) => conditionForm.updateFields({
[tabInfo.searchKey]: {
value
}
}, false),
buttonsAd: this.getTabButtonsAd(),
searchsAd: {
if (e.keyCode == 13 && e.target.tagName === "INPUT") {
tabInfo.doSearch(conditionForm.getFormParams());
this.setState({
showSearchAd: false
})
}
} }
>{this.renderForm()}
});
Object.assign(tabProps, {
//advanceHeight: calFormHeight(conditionFormFields.length, _.keys(formParams).length)
advanceHeight: advanceHeight ? advanceHeight : calFormHeight(conditionFormFields.length, conditionForm.fieldArr)
});
}
}
tabConfig.onTabEdit && Object.assign(tabProps, {
onEdit: tabConfig.onTabEdit
});
return this.initTab(tabProps);
}
renderTabContent = () => {
const {
children,
activeTabInfo,
rightMenu,
store
} = this.props;
if (Array.isArray(children)) {
return React.cloneElement(children[activeTabInfo.activeTabIndex], {
rightMenu,
activeTabIndex: activeTabInfo.activeTabIndex,
store
});
} else {
return React.cloneElement(children, {
rightMenu,
activeTabIndex: activeTabInfo.activeTabIndex,
store
});
}
}
render() {
const {
tabConfig
} = this.props;
return (
{tabConfig.tabs.length > 0 && this.renderTabNav()}
{tabConfig.tabs.length > 0 && this.renderTabContent()}
);
}
}