king
2021-02-23 ea34e669b45f86793017621a0dc3f9a71aa3276b
src/components/tabview/index.jsx
@@ -2,7 +2,7 @@
import PropTypes from 'prop-types'
import {connect} from 'react-redux'
import { is, fromJS } from 'immutable'
import {Tabs, Icon, Button, message, BackTop} from 'antd'
import {Tabs, Icon, BackTop} from 'antd'
import moment from 'moment'
import 'moment/locale/zh-cn'
@@ -33,10 +33,10 @@
if (process.env.NODE_ENV === 'production') {
  service = document.location.origin + '/' + window.GLOB.service + 'zh-CN/'
} else {
  service = window.GLOB.location + window.GLOB.service + 'zh-CN/'
  service = window.GLOB.location + '/' + window.GLOB.service + 'zh-CN/'
}
class Header extends Component {
class TabViews extends Component {
  static propTpyes = {
    collapse: PropTypes.bool,
    tabviews: PropTypes.array // 标签页数组
@@ -46,7 +46,7 @@
    activeId: '',
    tabviews: null, // 标签集
    iFrameHeight: 0,
    dict: localStorage.getItem('lang') !== 'en-US' ? mzhCN : menUS
    dict: localStorage.getItem('lang') !== 'en-US' ? mzhCN : menUS,
  }
  handleTabview = (e, menu) => {
@@ -140,22 +140,10 @@
    } else if (view.type === 'FormTab') {
      return (<FormTab MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} key={view.MenuID} param={view.param}/>)
    } else if (view.type === 'iframe') {
      return (<Iframe key={view.MenuID} title={view.MenuName} MenuName={view.MenuName} url={service + view.LinkUrl}/>)
      return (<Iframe key={view.MenuID} MenuID={view.MenuID} MenuNo={view.MenuNo} title={view.MenuName} MenuName={view.MenuName} url={service + view.LinkUrl}/>)
    } else {
      return (<NotFount key={view.MenuID} />)
    }
  }
  copyMenuNo = (e) => {
    e.stopPropagation()
    let oInput = document.createElement('input')
    oInput.value = e.target.dataset.menuno || ''
    document.body.appendChild(oInput)
    oInput.select()
    document.execCommand('Copy')
    oInput.className = 'oInput'
    oInput.style.display = 'none'
    message.success(this.state.dict['main.copy.success'])
  }
  UNSAFE_componentWillMount () {
@@ -170,13 +158,15 @@
  }
  componentDidMount () {
    let home = {
      MenuID: 'home_page_id',
      MenuName: '首页',
      selected: true,
      type: 'Home'
    if (sessionStorage.getItem('isEditState') !== 'true') {
      let home = {
        MenuID: 'home_page_id',
        MenuName: this.state.dict['main.homepage'],
        selected: true,
        type: 'Home'
      }
      this.props.modifyTabview([home])
    }
    this.props.modifyTabview([home])
  }
  UNSAFE_componentWillReceiveProps (nextProps) {
@@ -223,11 +213,10 @@
  }
  render () {
    const { menuType } = this.props
    const { tabviews, activeId } = this.state
    return (
      <section className={'flex-container content-box' + (this.props.collapse ? ' collapsed' : '')}>
      <section id="mk-tabview-wrap" className={'mk-tabview-wrap' + (this.props.collapse ? ' collapsed' : '')}>
        <div className="content-header">
          {tabviews && tabviews.length > 0 &&
            <Tabs activeKey={activeId}>
@@ -236,9 +225,7 @@
                  <Tabs.TabPane
                    tab={
                      <span className="tab-control">
                        {['CommonTable', 'FormTab', 'TreePage', 'CalendarPage', 'CustomPage'].includes(view.type) ?
                          <Icon type="redo" onClick={(e) => {this.refreshTabview(e, view)}}/> : null
                        }
                        <Icon type="redo" onClick={(e) => {this.refreshTabview(e, view)}}/>
                        <span className="tab-name" onClick={(e) => {this.changeTab(e, view)}}>
                          {view.MenuName}
                        </span>
@@ -250,15 +237,6 @@
                    key={view.MenuID}
                  >
                    {this.selectcomponent(view)}
                    {options.sysType !== 'cloud' && menuType !== 'HS' && !['CommonTable', 'TreePage', 'ManageTable', 'CalendarPage', 'Home'].includes(view.type) ?
                      <Button
                        icon="copy"
                        shape="circle"
                        className={'main-copy ' + (view.type === 'iframe' ? 'ifr-copy' : '')}
                        data-menuno={view.MenuNo}
                        onClick={this.copyMenuNo}
                      /> : null
                    }
                    <BackTop>
                      <div className="ant-back-top">
                        <div className="ant-back-top-content">
@@ -266,6 +244,7 @@
                        </div>
                      </div>
                    </BackTop>
                    {options.sysType === 'local' && window.GLOB.systemType !== 'production' ? <div className="mk-water-mark">测试系统</div> : null}
                  </Tabs.TabPane>
                )
              })}
@@ -279,7 +258,6 @@
const mapStateToProps = (state) => {
  return {
    menuType: state.editLevel,
    tabviews: state.tabviews,
    collapse: state.collapse,
    isiframe: state.isiframe
@@ -293,4 +271,4 @@
  }
}
export default connect(mapStateToProps, mapDispatchToProps)(Header)
export default connect(mapStateToProps, mapDispatchToProps)(TabViews)