import React from 'react';
import {inject, observer} from 'mobx-react';
import {toJS} from 'mobx';
import {WeaStepsMenus, WeaTab, WeaLeftRightLayout} from 'ecCom';
import NoRight from "../../public/NoRight";
import NonStand from "../../public/NonStand";

const store = ['inteNCStore'];
@inject(...store)
@observer
export default class NC extends React.Component {
  constructor(props) {
    super(props);
  }

  componentDidMount() {
    this.props.inteNCStore.getMenuList({groupid: 1})
  }

  render() {
    const {inteNCStore} = this.props;
    let {menuList, routeUrl, mainTitle, hasRight, rightLoading, nonStandLoading, hasNonStandard} = inteNCStore;
    menuList = toJS(menuList);

    return (nonStandLoading
      ? null
      : hasNonStandard
        ? rightLoading 
          ? null
          : hasRight  
            ? <div className='wea-inte-NC' style={{height: '100%'}}>
                <WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@w2k9f8`} datas={[{title: `${mainTitle}`, viewcondition: '1'}]} keyParam="viewcondition" selectedKey={'1'}/>
                <div style={{height: 'calc(100% - 47px)'}}>
                  <WeaLeftRightLayout ecId={`${this && this.props && this.props.ecId || ''}_WeaLeftRightLayout@a4zz4v`}
                    isNew={true}
                    showBtn={false}
                    leftWidth={174}
                    leftCom={
                      <div className='wea-inte-NC-left'>
                        {menuList && menuList.length > 0 &&
                        <WeaStepsMenus ecId={`${this && this.props && this.props.ecId || ''}_WeaStepsMenus@dqiu26`}
                          datas={menuList}
                          current={0}
                          onChange={v => {
                            inteNCStore.changeUrl(v.routeUrl+"?from=productEntrance&typename=1");
                          }}
                        />}
                      </div>
                    }
                  >
                    <iframe src={routeUrl} width="100%" height="100%" scrolling="yes" frameBorder="0" align="top"></iframe>
                  </WeaLeftRightLayout>
                </div>
              </div>
            : <NoRight ecId={`${this && this.props && this.props.ecId || ''}_NoRight@jqxuv9`} />
        : <NonStand ecId={`${this && this.props && this.props.ecId || ''}_NonStand@2rlke7`} />
    )
  }
}

