From 207e7ed3d871717df4a02f9b27792850beebe779 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 13 九月 2019 19:15:06 +0800
Subject: [PATCH] 2019-09-13

---
 src/components/sidemenu/index.jsx |   63 +++++++++++++++++--------------
 1 files changed, 34 insertions(+), 29 deletions(-)

diff --git a/src/components/sidemenu/sidemenu.jsx b/src/components/sidemenu/index.jsx
similarity index 71%
rename from src/components/sidemenu/sidemenu.jsx
rename to src/components/sidemenu/index.jsx
index 182b955..54ace05 100644
--- a/src/components/sidemenu/sidemenu.jsx
+++ b/src/components/sidemenu/index.jsx
@@ -1,5 +1,4 @@
 import React, {Component} from 'react'
-// import { Lifecycle } from 'react-router'
 import { withRouter } from 'react-router-dom'
 import PropTypes from 'prop-types'
 import {connect} from 'react-redux'
@@ -7,11 +6,11 @@
 import { Menu, Icon } from 'antd'
 import {modifyTabview} from '@/store/action'
 import Api from '@/api'
-import './sidemenu.scss'
+import './index.scss'
 
 const { SubMenu } = Menu
 
-class Smenu extends Component {
+class Sidemenu extends Component {
   static propTypes = {
     collapse: PropTypes.bool,
     mainMenu: PropTypes.oneOfType([
@@ -29,11 +28,37 @@
   async loadsubmenu (menu) {
     let result = await Api.getSubMenuData(menu.MenuID)
     if (result.status) {
+      let param = sessionStorage.getItem('view_param') // 鏄惁涓烘墦寮�鏂伴〉闈�
+      let msg = sessionStorage.getItem('UserID') + '&' + sessionStorage.getItem('lang')
+      let submenuindex = 0 // 灞曞紑浜岀骇鑿滃崟绱㈠紩
+      let tabindex = null // 鎵撳紑鐨則ab椤�
+      if (param) {
+        param = param.split('&')
+        submenuindex = parseInt(param[1])
+        tabindex = parseInt(param[2])
+        sessionStorage.removeItem('view_param')
+      }
+
       this.setState({
-        subMenulist: result.data,
+        subMenulist: result.data.map((item, i) => {
+          if (item.children) {
+            item.children = item.children.map((child, n) => {
+              let _msg = window.btoa(menu.index + '&' + i + '&' + n + '&' + msg)
+              child.src = '#/main/' + _msg
+              return child
+            })
+          }
+          return item
+        }),
         rootSubmenuKeys: result.data.map(item => item.id),
-        openKeys: this.props.collapse ? [] : [result.data[0].id]
+        openKeys: this.props.collapse ? [] : [result.data[submenuindex].id]
       })
+
+      if (tabindex !== null) {
+        let opentab = result.data[submenuindex].children[tabindex]
+        opentab.selected = true
+        this.props.modifyTabview([opentab])
+      }
     }
   }
 
@@ -47,24 +72,7 @@
     menu.selected = true
     tabs.push(menu)
     this.props.modifyTabview(tabs)
-    // this.props.history.push('/main')
-    // this.props.history.replace('/main')
     e.preventDefault()
-  }
-
-  // mixins = [ Lifecycle ]
-
-  routerWillLeave(nextLocation) {
-    if (!this.state.isSaved)
-      return 'Your work is not saved! Are you sure you want to leave?'
-  }
-
-  componentDidMount () {
-
-  }
-
-  UNSAFE_componentWillMount () {
-
   }
 
   UNSAFE_componentWillReceiveProps (nextProps) {
@@ -88,10 +96,6 @@
     }
   }
 
-  componentDidUpdate () {
-    // console.log('componentDidUpdate')
-  }
-
   onOpenChange = openKeys => {
     const latestOpenKey = openKeys.find(key => this.state.openKeys.indexOf(key) === -1)
     if (this.state.rootSubmenuKeys.indexOf(latestOpenKey) === -1) {
@@ -104,7 +108,7 @@
   }
   render () {
     return (
-      <aside className={"side-menu ant-menu-dark" + (this.props.collapse ? ' side-menu-collapsed' : '')}>
+      <aside className={"side-menu ant-menu-dark" + (this.props.collapse ? ' side-menu-collapsed' : '') + (this.props.isiframe ? ' iframe' : '')}>
         {this.state.subMenulist &&
           <Menu openKeys={this.state.openKeys} onOpenChange={this.onOpenChange} mode="inline" theme="dark" inlineCollapsed={this.props.collapse}>
           {this.state.subMenulist.map(item => {
@@ -121,7 +125,7 @@
                 {item.children.map(cell => {
                   return (
                     <Menu.Item key={cell.id}>
-                      <a href="#/main/0345" id={cell.MenuID} data-item={JSON.stringify(cell)} onClick={this.changemenu.bind(this)}>{cell.MenuName}</a>
+                      <a href={cell.src} id={cell.MenuID} data-item={JSON.stringify(cell)} onClick={this.changemenu.bind(this)}>{cell.MenuName}</a>
                     </Menu.Item>
                   )
                 })}
@@ -138,6 +142,7 @@
   return {
     tabviews: state.tabviews,
     collapse: state.collapse,
+    isiframe: state.isiframe,
     mainMenu: state.selectedMainMenu
   }
 }
@@ -148,4 +153,4 @@
   }
 }
 
-export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Smenu))
\ No newline at end of file
+export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Sidemenu))
\ No newline at end of file

--
Gitblit v1.8.0