import { Icon } from 'antd'; import MenuInline from './MenuInline'; import MenuVertical from './MenuVertical'; import cloneDeep from 'lodash/cloneDeep'; import { WeaNewScroll, WeaIntro } from 'ecCom'; const { Step } = WeaIntro; class WeaMenu extends React.Component { constructor(props) { super(props); this.state = { mode: props.mode || 'inline', defaultSelectedKey: props.defaultSelectedKey || '', datas: props.datas || [], verticalWidth: props.verticalWidth || 50, inlineWidth: props.inlineWidth || 190, menuHeight: jQuery(document.body).height() - 55 - props.translatepageheight, fontSize: props.fontSize, translatepage: props.translatepage || '', }; } resetHeigth() { const { portalThemeStore } = this.props; const { translatepage } = portalThemeStore; let transheight = translatepage == '1' ? 30 : 0; this.setState({ menuHeight: jQuery(document.body).height() - 55 - transheight }); } componentDidMount() { jQuery(window).resize(() => { this._reactInternalInstance !== undefined && this.resetHeigth(); }); } componentWillReceiveProps(nextProps) { if ( JSON.stringify(this.props.datas) !== JSON.stringify(nextProps.datas) || (this.props.defaultSelectedKey !== nextProps.defaultSelectedKey && this.state.defaultSelectedKey !== nextProps.defaultSelectedKey) ) { // 计算出openKeys this.setState({ datas: nextProps.datas || [], defaultSelectedKey: nextProps.defaultSelectedKey || '', }); } if (this.props.mode != nextProps.mode) { this.setState({ mode: nextProps.mode, }); } } render() { const { mode, datas, verticalWidth, inlineWidth, defaultSelectedKey, menuHeight, fontSize, translatepage } = this.state; const newDatas = this.setTreeKey('', datas); const { addonBefore, addonAfter, addonBeforeHeight, addonAfterHeight, clickBlock, needSwitch } = this.props; let style = { width: mode == 'vertical' ? verticalWidth : inlineWidth }; let conHeightNum = (needSwitch ? 40 : 0) + (!!addonBeforeHeight && mode == 'inline' ? addonBeforeHeight : 0) + (!!addonAfterHeight && mode == 'inline' ? addonAfterHeight : 0); return (