king
2019-10-12 c7f79abded9ad2e29f297da4a04a641b96b61c5e
src/components/sidemenu/index.jsx
@@ -38,20 +38,30 @@
        tabindex = parseInt(param[2])
        sessionStorage.removeItem('view_param')
      }
      let parentID = result.data[submenuindex] ? result.data[submenuindex].ParentID : '' // 展开二级菜单ID
      this.setState({
        subMenulist: result.data.map((item, i) => {
          if (item.children) {
            item.children = item.children.map((child, n) => {
          if (item.FunMenu) {
            item.children = item.FunMenu.map((child, n) => {
              let _msg = window.btoa(menu.MenuID + '&' + i + '&' + n + '&' + msg) // 待完善
              child.src = '#/main/' + _msg
              if (child.LinkUrl === 'CommonTable') {
                child.type = 'CommonTable'
              } else if (child.LinkUrl === 'DataManage') {
                child.type = 'DataManage'
              } else if (child.LinkUrl === 'bda/rdt?pageno=rolemenus&MenuNo=RoleMenuM') {
                child.type = 'RoleManage'
              } else if (child.LinkUrl.split('?')[0] === 'Main/Index' || child.LinkUrl.split('?')[0] === 'bda/rdt') {
                child.type = 'iframe'
              }
              return child
            })
          }
          return item
        }),
        rootSubmenuKeys: result.data.map(item => item.id),
        openKeys: this.props.collapse ? [] : [result.data[submenuindex].id]
        rootSubmenuKeys: result.data.map(item => item.ParentID),
        openKeys: (this.props.collapse || !parentID) ? [] : [parentID]
      })
      if (tabindex !== null) {
@@ -64,15 +74,23 @@
  changemenu(e) {
    let menu = JSON.parse(e.target.dataset.item)
    let tabs = JSON.parse(JSON.stringify(this.props.tabviews))
    tabs = tabs.filter(tab => {
      tab.selected = false
      return tab.MenuID !== menu.MenuID
    })
    menu.selected = true
    tabs.push(menu)
    this.props.modifyTabview(tabs)
    e.preventDefault()
    if (menu.Ot === 'NewPage') {
      window.open(menu.src)
    } else if (menu.Ot === 'blank') {
      menu.selected = true
      this.props.modifyTabview([menu])
      e.preventDefault()
    } else {
      let tabs = JSON.parse(JSON.stringify(this.props.tabviews))
      tabs = tabs.filter(tab => {
        tab.selected = false
        return tab.MenuID !== menu.MenuID
      })
      menu.selected = true
      tabs.push(menu)
      this.props.modifyTabview(tabs)
      e.preventDefault()
    }
  }
  UNSAFE_componentWillReceiveProps (nextProps) {
@@ -96,30 +114,6 @@
    }
  }
  // componentDidMount () {
  //   this.props.modifyTabview([{
  //     Action: "Index",
  //     Deleted: "0",
  //     IsButton: "0",
  //     LinkUrl: "Main/Index?MenuNo=SRMPurchaseOrderM",
  //     MenuID: "MM02130020118001000170",
  //     MenuName: "采购单管理",
  //     MenuNo: "SRMPurchaseOrderM",
  //     Ot: "",
  //     ParentID: "MM021300201180010",
  //     Remark: "",
  //     Sort: "100",
  //     icon: "Content/Upload/2018-07-02/2018070216084721656911_199046432321408044.png",
  //     id: "MM02130020118001000170",
  //     pid: "MM021300201180010",
  //     sIcon: "Content/Upload/2018-07-02/2018070216084721656911_199046432321408044.png",
  //     selected: true,
  //     src: "#/main/MCYwJjAmVTAwMDAwMDAwMSZudWxs",
  //     text: "采购单管理",
  //     url: null
  //   }])
  // }
  onOpenChange = openKeys => {
    const latestOpenKey = openKeys.find(key => this.state.openKeys.indexOf(key) === -1)
    if (this.state.rootSubmenuKeys.indexOf(latestOpenKey) === -1) {
@@ -138,17 +132,17 @@
          {this.state.subMenulist.map(item => {
            return (
              <SubMenu
                key={item.id}
                key={item.ParentID}
                title={
                  <span>
                    {item.icon ? <Icon type={item.icon} /> : <Icon type="folder" />}
                    <span>{item.MenuName}</span>
                    {item.IconP ? <Icon type={item.IconP} /> : <Icon type="folder" />}
                    <span>{item.MenuNameP}</span>
                  </span>
                }
              >
                {item.children.map(cell => {
                  return (
                    <Menu.Item key={cell.id}>
                    <Menu.Item key={cell.MenuID}>
                      <a href={cell.src} id={cell.MenuID} data-item={JSON.stringify(cell)} onClick={this.changemenu.bind(this)}>{cell.MenuName}</a>
                    </Menu.Item>
                  )