From fbf25a99e0bc643be89b0f9dd0efed7867f1490e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 27 七月 2022 18:08:02 +0800
Subject: [PATCH] 2022-07-27

---
 src/views/design/header/index.jsx |   48 ++++++++++++++++++++++--------------------------
 1 files changed, 22 insertions(+), 26 deletions(-)

diff --git a/src/views/design/header/index.jsx b/src/views/design/header/index.jsx
index 7324d56..eabf65e 100644
--- a/src/views/design/header/index.jsx
+++ b/src/views/design/header/index.jsx
@@ -1,7 +1,6 @@
 import React, {Component} from 'react'
 import { withRouter } from 'react-router-dom'
 import {connect} from 'react-redux'
-import { is, fromJS } from 'immutable'
 import { Dropdown, Menu, Modal, notification, Switch, Button, Popover } from 'antd'
 import { MenuFoldOutlined, SettingOutlined, AppstoreOutlined, DownOutlined, HomeOutlined, ApiOutlined, PlusOutlined, SwapOutlined } from '@ant-design/icons'
 
@@ -53,10 +52,6 @@
 
   changeMenu (value) {
     // 涓昏彍鍗曞垏鎹�
-    if (this.props.editLevel) {
-      // 缂栬緫鐘舵�佷笅锛屼笉鍙垏鎹㈣彍鍗�
-      return
-    }
     if (value.PageParam.OpenType === 'menu') {
       this.props.modifyMainMenu(value)
     } else if (value.PageParam.OpenType === 'outpage') {
@@ -79,12 +74,21 @@
 
       this.setState({ menulist })
 
-      this.props.modifyMenuTree(menulist)
-      if (window.GLOB.systemType !== 'production') { // 闈炴寮忕郴缁熼�夋嫨绗竴椤�
-        this.props.modifyMainMenu(menulist[0] || null)
-      } else {
+      let mainMenu = menulist[0] || null
 
+      if (this.props.editLevel === 'level1') {
+        mainMenu = null
+      } else if (this.props.mainMenu && this.props.mainMenu.MenuID) {
+        let _menu = menulist.filter(item => item.MenuID === this.props.mainMenu.MenuID)[0]
+        mainMenu = _menu || mainMenu
+
+        if (!_menu && (this.props.editLevel === 'level2' || this.props.editLevel === 'level3')) {
+          this.props.resetEditLevel(false)
+        }
       }
+
+      this.props.modifyMenuTree(menulist)
+      this.props.modifyMainMenu(mainMenu)
     } else {
       notification.error({
         top: 92,
@@ -120,7 +124,8 @@
             MenuID: snd.MenuID,
             MenuName: snd.MenuName,
             PageParam: {Icon: 'folder'},
-            children: []
+            children: [],
+            level: 'second'
           }
 
           if (snd.PageParam) {
@@ -141,7 +146,8 @@
                 MenuNo: trd.MenuNo,
                 EasyCode: trd.EasyCode,
                 type: 'CommonTable',            // 榛樿鍊间负甯哥敤琛�
-                OpenType: 'newtab'              // 鎵撳紑鏂瑰紡
+                OpenType: 'newtab',             // 鎵撳紑鏂瑰紡
+                level: 'third'
               }
   
               if (trd.LinkUrl && iframes.includes(trd.LinkUrl.split('?')[0])) {
@@ -192,11 +198,13 @@
   enterEdit = () => {
     // 杩涘叆缂栬緫鐘舵��
     this.props.resetEditLevel('level1')
+    this.props.modifyMainMenu(null)
   }
   
   exitEdit = () => {
     // 閫�鍑虹紪杈戠姸鎬�
     this.props.resetEditLevel(false)
+    this.props.modifyMainMenu(this.state.menulist[0] || null)
   }
 
   
@@ -239,14 +247,6 @@
     this.loadmenu()
   }
 
-  UNSAFE_componentWillReceiveProps (nextProps) {
-    if (!is(fromJS(this.props.menuTree), fromJS(nextProps.menuTree)) && !is(fromJS(this.state.menulist), fromJS(nextProps.menuTree))) {
-      this.setState({
-        menulist: nextProps.menuTree
-      })
-    }
-  }
-
   componentDidMount () {
     if (window.GLOB.systemType !== 'production') {
       setTimeout(() => {
@@ -287,10 +287,6 @@
       this.reload()
     })
     MKEmitter.addListener('mkUpdateMenuList', this.reload)
-  }
-
-  shouldComponentUpdate (nextProps, nextState) {
-    return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
   }
 
   /**
@@ -343,9 +339,9 @@
         {/* 杩涘叆缂栬緫鎸夐挳 */}
         {!editLevel && window.GLOB.systemType !== 'production' && menulist ? <Popover overlayClassName="mk-popover-control-wrap mk-menu-control" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
           <div className="mk-popover-control">
-            <PlusOutlined onClick={() => this.setState({visible: true, loading: false})} className="mk-edit-menu"/>
-            <SwapOutlined onClick={this.enterEdit} className="mk-edit-menu"/>
-            <div style={{display: 'inline-block', minWidth: '32px'}}><ThawMenu ParentId="0" Type="10" className="mk-edit-menu"/></div>
+            <PlusOutlined onClick={() => this.setState({visible: true, loading: false})}/>
+            <SwapOutlined onClick={this.enterEdit}/>
+            <div style={{display: 'inline-block', minWidth: '32px'}}><ThawMenu ParentId="0" Type="10"/></div>
           </div>
         } trigger="hover">
           <SettingOutlined className="edit-check"/>

--
Gitblit v1.8.0