From a94b0a4d15b26ecf8fe99f0a1c3e60d60b97766d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 15 八月 2023 14:22:03 +0800
Subject: [PATCH] 2023-08-15

---
 src/components/header/index.jsx |  735 +++++++++++++++++++++++++++++---------------------------
 1 files changed, 377 insertions(+), 358 deletions(-)

diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx
index 075ba1e..c9d7275 100644
--- a/src/components/header/index.jsx
+++ b/src/components/header/index.jsx
@@ -3,31 +3,27 @@
 import PropTypes from 'prop-types'
 import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
-import moment from 'moment'
-import { Dropdown, Menu, Icon, Modal, Form, notification, Switch, Input, Badge } from 'antd'
+import { Dropdown, Menu, Modal, notification, Switch, Input } from 'antd'
+import { SearchOutlined, DownOutlined, MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons'
 
 import {
   toggleCollapse,
-  modifyMenuTree,
   modifyMainMenu,
-  modifyTabview,
-  initActionPermission,
-  initMenuPermission,
   logout
 } from '@/store/action'
+import asyncSpinComponent from '@/utils/asyncSpinComponent'
+import asyncComponent from '@/utils/asyncComponent'
 import Api from '@/api'
 import MKEmitter from '@/utils/events.js'
-import options from '@/store/options.js'
-import zhCN from '@/locales/zh-CN/main.js'
-import enUS from '@/locales/en-US/main.js'
 import Utils from '@/utils/utils.js'
 import avatar from '@/assets/img/avatar.jpg'
-import Resetpwd from './resetpwd'
-import LoginForm from './loginform'
 import './index.scss'
 
 const { confirm } = Modal
 const { Search } = Input
+const Resetpwd = asyncComponent(() => import('@/components/resetPassword'))
+const QrCode = asyncComponent(() => import('@/components/qrcode'))
+const LoginForm = asyncSpinComponent(() => import('./loginform'))
 
 class Header extends Component {
   static propTpyes = {
@@ -35,10 +31,8 @@
   }
   state = {
     menulist: null, // 涓�绾ц彍鍗�
-    visible: false, // 淇敼瀵嗙爜妯℃�佹
-    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
-    confirmLoading: false,
-    userName: sessionStorage.getItem('User_Name'),
+    userName: '',
+    fullName: '',
     logourl: window.GLOB.mainlogo,
     loginVisible: false,
     loginLoading: false,
@@ -46,10 +40,7 @@
     systems: [],
     searchkey: '',
     thdMenuList: [],
-    oriVersion: '',
-    newVersion: '',
-    debug: sessionStorage.getItem('debug') === 'true',
-    navBar: ['linkage_navigation', 'linkage'].includes(window.GLOB.navBar) ? 'topmenu' : ''
+    debug: sessionStorage.getItem('debug') === 'true'
   }
 
   handleCollapse = () => {
@@ -60,53 +51,12 @@
 
   changePassword = () => {
     // 鐐瑰嚮淇敼瀵嗙爜锛屾樉绀哄脊绐�
-    this.setState({
-      visible: true
-    })
-  }
-
-  resetPwdSubmit = () => {
-    this.formRef.handleConfirm().then(res => {
-      this.setState({
-        confirmLoading: true
-      })
-
-      let _param = {
-        func: 's_PwdUpt',
-        LText: `select '${res.originpwd}','${res.password}'`
-      }
-      
-      _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')          // 鏃堕棿鎴�
-      _param.LText = Utils.formatOptions(_param.LText)                   // 鍏抽敭瀛楃鏇挎崲锛宐ase64鍔犲瘑
-      _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)   // md5瀵嗛挜
-  
-      Api.getSystemConfig(_param).then(result => {
-        this.setState({
-          visible: !result.status,
-          confirmLoading: false
-        })
-
-        if (result.status) {
-          notification.success({
-            top: 92,
-            message: this.state.dict['main.password.resetsuccess'],
-            duration: 2
-          })
-        } else {
-          notification.warning({
-            top: 92,
-            message: result.message,
-            duration: 5
-          })
-        }
-      })
-    }, () => {})
-  }
-
-  handleCancel = () => {
-    // 鍙栨秷鏃跺叧闂慨鏀瑰瘑鐮佹ā鎬佹锛屾竻绌鸿〃鍗曟暟鎹�
-    this.setState({
-      visible: false
+    MKEmitter.emit('resetpassword', () => {
+      setTimeout(() => {
+        sessionStorage.clear()
+        this.props.logout()
+        this.props.history.replace('/login')
+      }, 2000)
     })
   }
 
@@ -114,8 +64,10 @@
     // 閫�鍑虹櫥褰�
     let _this = this
     confirm({
-      title: this.state.dict['main.logout.hint'],
+      title: '鎮ㄧ‘瀹氳閫�鍑哄悧?',
       content: '',
+      okText: '纭畾',
+      cancelText: '鍙栨秷',
       onOk() {
         sessionStorage.clear()
         _this.props.logout()
@@ -127,17 +79,68 @@
 
   changeMenu (value) {
     // 涓昏彍鍗曞垏鎹�
-    if (value.OpenType === 'outpage' && value.linkUrl) {
-      window.open(value.linkUrl)
+    if (value.OpenType === 'newpage') {
+      window.open(value.src)
+    } else if (value.OpenType === 'newtab') {
+      MKEmitter.emit('modifyTabs', value)
     } else if (value.OpenType === 'menu') {
       this.props.modifyMainMenu(value)
     }
   }
 
   getRolesMenu () {
-    // 鑾峰彇瑙掕壊鏉冮檺
-    let roledefer = new Promise(resolve => {
-      // edition_type 鎺ュ彛鐗堟湰鎺у埗 ''銆�'Y'銆�'A'
+    // 鑾峰彇涓昏彍鍗曞弬鏁�
+    let _param = {func: 's_get_pc_menus', systemType: window.GLOB.sysType}
+    _param.pro_sys = window.GLOB.systemType === 'production' ? 'Y' : ''
+    
+    Api.getSystemConfig(_param).then(result => {
+      if (!result.status) {
+        notification.error({
+          top: 92,
+          message: result.message,
+          duration: 10
+        })
+        return
+      }
+
+      const { menulist, thdMenuList } = this.getMenulist(result)
+
+      let systems = []
+      if ((window.GLOB.sysType === 'local' || window.GLOB.sysType === 'SSO') && result.sys_list) {
+        systems = result.sys_list
+
+        if (window.GLOB.sysType === 'local' && window.GLOB.systemType !== 'production' && systems.length > 10) {
+          systems.length = 10
+        }
+      }
+
+      this.setState({
+        menulist,
+        thdMenuList,
+        systems: systems
+      })
+      
+      let mainMenu = menulist[0] || ''
+      let _menu = null
+
+      if (sessionStorage.getItem('ThirdMenu')) { // 鏄惁涓烘墦寮�鏂伴〉闈�
+        let ThirdMenuId = sessionStorage.getItem('ThirdMenu')
+        _menu = thdMenuList.filter(item => item.MenuID === ThirdMenuId)[0] // 閫氳繃url涓璵enuid绛涢�夊嚭閫変腑鐨勪富鑿滃崟
+
+        sessionStorage.removeItem('ThirdMenu')
+      }
+
+      this.props.modifyMainMenu(mainMenu)
+
+      window.GLOB.mkThdMenus = [...thdMenuList, {MenuID: 'home_page_id', EasyCode: '', MenuName: 'home', type: 'CustomPage'}]
+
+      if (_menu) {
+        this.openTab(_menu, 0)
+      }
+    })
+    
+    // 鑾峰彇瑙掕壊鏉冮檺, edition_type 鎺ュ彛鐗堟湰鎺у埗 ''銆�'Y'銆�'A'
+    setTimeout(() => {
       Api.getSystemConfig({
         func: 's_Get_TrdMenu_Role',
         edition_type: 'A',
@@ -145,14 +148,14 @@
       }).then(result => {
         let _permAction = {loaded: true} // 鎸夐挳鏉冮檺
 
-        if (result && result.status) {
+        if (result.status) {
           if (result.UserRoles_Menu) {
             result.UserRoles_Menu.forEach(menu => {
               if (!menu.MenuID) return
               _permAction[menu.MenuID] = true
             })
           }
-        } else if (result) {
+        } else {
           notification.error({
             top: 92,
             message: result.message,
@@ -160,92 +163,31 @@
           })
         }
 
-        this.props.initActionPermission(_permAction)
-        resolve()
+        window.GLOB.mkActions = _permAction
       })
-    })
+    }, 50)
+  }
 
-    // 鑾峰彇涓昏彍鍗曞弬鏁�
-    let menudefer = new Promise(resolve => {
-      let _param = {func: 's_get_pc_menus', systemType: options.sysType}
-      _param.pro_sys = window.GLOB.systemType === 'production' ? 'Y' : ''
-      
-      Api.getSystemConfig(_param).then(result => {
-        if (!result.status) {
-          notification.error({
-            top: 92,
-            message: result.message,
-            duration: 10
-          })
-          return
-        }
+  openTab = (menu, times) => {
+    if (times > 50) return
+    times++
 
-        const { menulist, thdMenuList } = this.getMenulist(result)
+    let tabgroup = document.getElementById('mk-tabgroup-wrap')
 
-        this.setState({
-          menulist,
-          thdMenuList,
-          systems: window.GLOB.systemType === 'production' || options.sysType === 'SSO' ? (result.sys_list || []) : []
-        })
-        
-        let mainMenu = menulist[0] || ''
-        let _menu = null
-
-        if (mainMenu === '') { // 鏄惁鏄剧ず渚ц竟鏍忔帶鍒�
-          let _url = window.location.href.split('#')[0]
-          localStorage.setItem(_url + '-sideHidden', 'true')
-        } else {
-          let _url = window.location.href.split('#')[0]
-          localStorage.removeItem(_url + '-sideHidden')
-        }
-
-        if (sessionStorage.getItem('ThirdMenu')) { // 鏄惁涓烘墦寮�鏂伴〉闈�
-          let ThirdMenuId = sessionStorage.getItem('ThirdMenu')
-          _menu = thdMenuList.filter(item => item.MenuID === ThirdMenuId)[0] // 閫氳繃url涓璵enuid绛涢�夊嚭閫変腑鐨勪富鑿滃崟
-
-          if (_menu) {
-            mainMenu = menulist.filter(item => item.MenuID === _menu.FstId)[0]
-            mainMenu = fromJS(mainMenu).toJS()
-            mainMenu.openId = _menu.ParentId
-          }
-
-          sessionStorage.removeItem('ThirdMenu')
-        }
-
-        this.props.modifyMenuTree(menulist)
-        this.props.modifyMainMenu(mainMenu)
-        this.props.initMenuPermission([...thdMenuList, {MenuID: 'home_page_id', EasyCode: '', MenuName: 'home', type: 'CustomPage'}])
-
-        resolve(_menu)
-      })
-    })
-    
-    Promise.all([roledefer, menudefer]).then(response => {
-      if (response[1]) {
-        let tabs = fromJS(this.props.tabviews).toJS()
-        let menu = fromJS(response[1]).toJS()
-
-        if (this.state.navBar === 'topmenu') {
-          menu.selected = true
-          this.props.modifyTabview([menu])
-        } else {
-          tabs = tabs.map(tab => {
-            tab.selected = false
-            return tab
-          })
-
-          menu.selected = true
-          tabs.push(menu)
-          this.props.modifyTabview(tabs)
-        }
-      }
-    })
+    if (window.GLOB.mkActions.loaded && tabgroup) {
+      MKEmitter.emit('modifyTabs', menu)
+    } else {
+      setTimeout(() => {
+        this.openTab(times)
+      }, 200)
+    }
   }
 
   getMenulist = (result) => {
     let thdMenuList = []
-    let iframes = ['Main/Index', 'bda/rdt', 'Home/rdt']
     let menulist = []
+    let names = new Map()
+    let doublenames = new Map()
     result.fst_menu && result.fst_menu.forEach(fst => {
       let fstItem = {
         MenuID: fst.MenuID,
@@ -255,14 +197,18 @@
       }
       if (fst.PageParam) {
         try {
-          fstItem.PageParam = JSON.parse(fst.PageParam)
-        } catch (e) {
-          fstItem.PageParam = null
-        }
-        if (fstItem.PageParam && fstItem.PageParam.OpenType === 'outpage' && fstItem.PageParam.linkUrl) {
-          fstItem.OpenType = 'outpage'
-          fstItem.linkUrl = fstItem.PageParam.linkUrl
-        }
+          let PageParam = JSON.parse(fst.PageParam)
+
+          if (PageParam.OpenType === 'outpage' && PageParam.linkUrl) {
+            fstItem.OpenType = 'newpage'
+            fstItem.src = PageParam.linkUrl
+            if (/#\/iframe\//.test(fstItem.src)) {
+              fstItem.src = fstItem.src.replace(/@loginuid@/ig, sessionStorage.getItem('LoginUID'))
+              fstItem.type = 'iframe'
+              fstItem.OpenType = 'newtab'
+            }
+          }
+        } catch (e) {}
       }
 
       if (fst.snd_menu) {
@@ -271,31 +217,16 @@
             ParentId: fst.MenuID,
             MenuID: snd.MenuID,
             MenuName: snd.MenuName,
-            PageParam: {Icon: 'folder'},
+            Icon: 'folder',
             children: []
           }
 
           if (snd.PageParam) {
             try {
-              sndItem.PageParam = JSON.parse(snd.PageParam)
-            } catch (e) {
-              sndItem.PageParam = {Icon: 'folder'}
-            }
-          }
+              let PageParam = JSON.parse(snd.PageParam)
 
-          let msg = {
-            UserID: sessionStorage.getItem('UserID'),
-            LoginUID: sessionStorage.getItem('LoginUID'),
-            User_Name: sessionStorage.getItem('User_Name'),
-            Full_Name: sessionStorage.getItem('Full_Name'),
-            Member_Level: sessionStorage.getItem('Member_Level'),
-            dataM: sessionStorage.getItem('dataM'),
-            avatar: sessionStorage.getItem('avatar'),
-            debug: sessionStorage.getItem('debug'),
-            role_id: sessionStorage.getItem('role_id'),
-            mainlogo: window.GLOB.mainlogo,
-            navBar: window.GLOB.navBar || '',
-            mstyle: window.GLOB.style
+              sndItem.Icon = PageParam.Icon || 'folder'
+            } catch (e) {}
           }
 
           if (snd.trd_menu) {
@@ -305,50 +236,46 @@
                 ParentId: snd.MenuID,
                 MenuID: trd.MenuID,
                 MenuName: trd.MenuName,
+                menu_name: trd.MenuName,
                 ParentNames: [fst.MenuName, snd.MenuName],
                 MenuNo: trd.MenuNo,
                 EasyCode: trd.EasyCode,
-                type: 'CommonTable',            // 榛樿鍊间负甯哥敤琛�
-                OpenType: 'newtab'              // 鎵撳紑鏂瑰紡
+                type: 'CommonTable',
+                OpenType: 'newtab',
+                hidden: 'false'
               }
-  
-              if (trd.LinkUrl && iframes.includes(trd.LinkUrl.split('?')[0])) {
-                trdItem.type = 'iframe'
-                trdItem.LinkUrl = trd.LinkUrl.replace('&amp;', '&')
-              } else {
+
+              if (trd.PageParam) {
                 try {
-                  trdItem.PageParam = trd.PageParam ? JSON.parse(trd.PageParam) : {OpenType: 'newtab'}
-                } catch (e) {
-                  trdItem.PageParam = {OpenType: 'newtab'}
-                }
+                  let PageParam = JSON.parse(trd.PageParam)
 
-                trdItem.type = trdItem.PageParam.Template || trdItem.type
-                trdItem.OpenType = trdItem.PageParam.OpenType || trdItem.OpenType
+                  trdItem.type = PageParam.Template || 'CommonTable'
+                  trdItem.OpenType = PageParam.OpenType || 'newtab'
+                  trdItem.hidden = PageParam.hidden || 'false'
 
-                if (trdItem.type === 'NewPage') {
-                  trdItem.src = trdItem.PageParam.url || ''
-                  
-                  if (trdItem.src.indexOf('paramsmain/') > -1) {
-                    try {
-                      let _url = trdItem.src.split('paramsmain/')[0] + 'paramsmain/'
-                      let _param = JSON.parse(window.decodeURIComponent(window.atob(trdItem.src.split('paramsmain/')[1])))
-                      _param.UserID = sessionStorage.getItem('UserID')
-                      _param.LoginUID = sessionStorage.getItem('LoginUID')
-                      _param.User_Name = sessionStorage.getItem('User_Name')
-                      _param.Full_Name = sessionStorage.getItem('Full_Name')
-
-                      trdItem.src = _url + window.btoa(window.encodeURIComponent(JSON.stringify(_param)))
-                    } catch {
-                      console.warn('鑿滃崟鍙傛暟瑙f瀽閿欒锛�')
+                  if (trdItem.type === 'NewPage') {
+                    trdItem.OpenType = 'newpage'
+                    trdItem.src = PageParam.url || ''
+                    if (/#\/iframe\//.test(trdItem.src)) {
+                      trdItem.src = trdItem.src.replace(/@loginuid@/ig, sessionStorage.getItem('LoginUID'))
+                      trdItem.type = 'iframe'
+                      trdItem.OpenType = 'newtab'
                     }
+                  } else if (trdItem.OpenType === 'view') {
+                    trdItem.OpenType = 'newpage'
+                    trdItem.src = '#/view/' + trd.MenuID
+                  } else {
+                    trdItem.src = '#/tab/' + trd.MenuID
                   }
-                } else {
-                  // 鎵撳紑鏂伴〉闈㈤摼鎺�
-                  trdItem.src = '#/paramsmain/' + window.btoa(window.encodeURIComponent(JSON.stringify({
-                    ...msg,
-                    ThirdMenu: trd.MenuID
-                  })))
-                }
+                } catch (e) {}
+              } else {
+                trdItem.src = '#/tab/' + trd.MenuID
+              }
+
+              if (names.has(trdItem.menu_name)) {
+                doublenames.set(trdItem.menu_name, true)
+              } else {
+                names.set(trdItem.menu_name, true)
               }
 
               thdMenuList.push(trdItem)
@@ -357,11 +284,20 @@
             })
           }
 
+          sndItem.children = sndItem.children.filter(item => item.hidden !== 'true')
+
           return sndItem
         })
       }
 
       menulist.push(fstItem)
+    })
+
+    thdMenuList = thdMenuList.map(item => {
+      if (doublenames.has(item.menu_name)) {
+        item.menu_name += '锛�' + item.ParentNames.join('-') + '锛�'
+      }
+      return item
     })
 
     return { menulist, thdMenuList }
@@ -371,31 +307,44 @@
     // 淇敼缂栬緫鐘舵��
     let UserID = sessionStorage.getItem('CloudUserID')
     let LoginUID = sessionStorage.getItem('CloudLoginUID')
-
+    
     if (!UserID || !LoginUID) {
       this.setState({
         loginVisible: true
       })
     } else {
-      sessionStorage.setItem('role_id', sessionStorage.getItem('cloudRole_id'))
-      sessionStorage.setItem('dataM', sessionStorage.getItem('cloudDataM'))
-      sessionStorage.setItem('isEditState', 'true')
-
-      this.props.modifyMenuTree([])
       this.props.modifyMainMenu(null)
-      this.props.modifyTabview([])
 
       this.props.history.replace('/design')
     }
   }
 
   loginSubmit = () => {
+    if (!this.loginRef) return
+
     this.setState({
       loginLoading: true
     })
+
     this.loginRef.handleConfirm().then(param => {
       Api.getusermsg(param.username, param.password, true).then(res => {
         if (res.status) {
+          this.setState({
+            loginLoading: false
+          })
+
+          if (res.modifydate) {
+            let s = (new Date().getTime() - new Date(res.modifydate).getTime()) / (1000 * 24 * 60 * 60)
+            if (!isNaN(s) && s > 90) {
+              Modal.warning({
+                width: 520,
+                title: <span>绯荤粺妫�娴嬪埌鎮ㄧ殑璐︽埛瀛樺湪椋庨櫓锛岃鍙婃椂鍒�<a target="_blank" rel="noopener noreferrer" href="https://cloud.mk9h.cn/admin/index.html">浜戜腑蹇�</a>淇敼瀵嗙爜锛�</span>,
+                okText: '鐭ラ亾浜�'
+              })
+              return
+            }
+          }
+
           sessionStorage.setItem('CloudUserID', res.UserID)
           sessionStorage.setItem('CloudLoginUID', res.LoginUID)
           sessionStorage.setItem('CloudUserName', res.UserName)
@@ -404,14 +353,14 @@
           sessionStorage.setItem('cloudDataM', res.dataM ? 'true' : '')
           sessionStorage.setItem('cloudRole_id', res.role_id || '')
 
-          sessionStorage.setItem('role_id', res.role_id || '')
-          sessionStorage.setItem('dataM', res.dataM ? 'true' : '')
-          sessionStorage.setItem('isEditState', 'true')
+          let _url = window.location.href.split('#')[0] + 'cloud'
+          if (param.remember) {
+            localStorage.setItem(_url, window.btoa(window.encodeURIComponent(JSON.stringify({time: new Date().getTime(), username: param.username, password: param.password}))))
+          } else {
+            localStorage.setItem(_url, window.btoa(window.encodeURIComponent(JSON.stringify({time: new Date().getTime(), username: param.username, password: ''}))))
+          }
 
-          this.props.modifyMenuTree([])
           this.props.modifyMainMenu(null)
-          this.props.modifyTabview([])
-
           this.props.history.replace('/design')
         } else {
           if (res.message.indexOf('瀵嗙爜閿欒') > -1) {
@@ -447,18 +396,40 @@
       url = url + '/'
     }
 
-    let href = url + 'index.html#/ssologin/' + window.btoa(window.encodeURIComponent(JSON.stringify({
-      UserID: sessionStorage.getItem('UserID'),
-      LoginUID: sessionStorage.getItem('LoginUID'),
-      User_Name: sessionStorage.getItem('User_Name'),
-      Full_Name: sessionStorage.getItem('Full_Name'),
-      avatar: sessionStorage.getItem('avatar'),
-      dataM: system.dataM ? 'true' : '',
-      debug: system.debug || '',
-      role_id: system.role_id || ''
-    })))
+    let key = Utils.getuuid()
 
-    window.open(href)
+    let _param = {
+      func: 'webapi_scan_binding_key',
+      binding_type: 'mk',
+      scan_type: 'toggle',
+      scan_appkey: system.scan_appkey,
+      id: key
+    }
+
+    Api.getSystemConfig(_param).then(res => {
+      if (!res.status) {
+        notification.warning({
+          top: 92,
+          message: res.message,
+          duration: 5
+        })
+      } else if (res.thd_party_appid && res.thd_party_member_id && res.thd_party_openid) {
+        let href = url + 'admin/index.html#/ssologin/' + window.btoa(window.encodeURIComponent(JSON.stringify({
+          appid: res.thd_party_appid,
+          memberId: res.thd_party_member_id,
+          openid: res.thd_party_openid,
+          key: key
+        })))
+
+        window.open(href)
+      } else {
+        notification.warning({
+          top: 92,
+          message: '淇℃伅缂哄け锛岃鑱旂郴绠$悊鍛橈紒',
+          duration: 5
+        })
+      }
+    })
   }
 
   dropdownMenuChange = (visible) => {
@@ -475,26 +446,42 @@
   UNSAFE_componentWillMount () {
     // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁
     this.getRolesMenu()
-  }
 
-  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
-      })
+    let fullName = sessionStorage.getItem('Full_Name') || ''
+    let userName = sessionStorage.getItem('User_Name') || ''
+
+    if (fullName.toLowerCase() === userName.toLowerCase()) {
+      userName = ''
     }
+
+    this.setState({fullName, userName})
   }
 
   componentDidMount () {
     // 鑾峰彇绯荤粺鐨勭増鏈俊鎭紝寤舵椂鏌ヨ
     setTimeout(() => {
-      Api.getAppVersion().then(res => {
-        this.setState({
-          oriVersion: res.oldVersion,
-          newVersion: res.newVersion
-        })
-      }, () => {})
+      Api.getAppVersion()
     }, 1000)
+
+    // sessionStorage 璺ㄩ〉闈㈠叡浜�
+    window.addEventListener('storage', (e) => {
+      if (e.key === 'getSessionStorage' && e.newValue === window.GLOB.appkey) {
+        localStorage.setItem('sessionStorage', JSON.stringify(sessionStorage))
+      } else if (e.key === 'getSysPermission' && e.newValue === window.GLOB.appkey) {
+        localStorage.setItem('sysPermissions', JSON.stringify({mkThdMenus: window.GLOB.mkThdMenus, mkActions: window.GLOB.mkActions}))
+      } else if (e.key === 'menuUpdate') {
+        let vals = e.newValue.split(',')
+        let menuId = vals[1]
+        let position = vals[2] || ''
+        if (position === 'menu') {
+          MKEmitter.emit('reloadMenuView', menuId)
+        } else if (menuId) {
+          Api.getAppVersion(menuId).then(() => {
+            MKEmitter.emit('reloadMenuView', menuId)
+          })
+        }
+      }
+    })
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -510,80 +497,28 @@
     }
   }
 
-  verup = () => {
-    const { oriVersion, newVersion } = this.state
-    const _this = this
-
-    confirm({
-      title: this.state.dict['main.verup'],
-      content: `鏈�鏂扮増鏈�${newVersion}锛屽綋鍓嶇増鏈�${oriVersion}`,
-      onOk() {
-        return new Promise(resolve => {
-          if (!window.GLOB.WebSql) {
-            notification.warning({
-              top: 92,
-              message: '鍗囩骇澶辫触锛岃鍒锋柊椤甸潰閲嶈瘯锛�',
-              duration: 2
-            })
-            resolve()
-          } else {
-            Api.updateAppVersion(newVersion)
-            notification.success({
-              top: 92,
-              message: '鍗囩骇鎴愬姛锛�',
-              duration: 2
-            })
-            _this.setState({oriVersion: newVersion})
-            resolve()
-          }
-        })
-      },
-      onCancel() {}
-    })
-  }
-
   gotoDoc = () => {
-    if (options.sysType === 'local' && window.GLOB.mainSystemApi) {
+    if (window.GLOB.sysType === 'local' && window.GLOB.mainSystemApi) {
       let ssodomain = window.GLOB.mainSystemApi.replace('/webapi/dostars', '')
       let url = `${ssodomain}/doc/index.html#?appkey=${window.GLOB.appkey}&LoginUID=${sessionStorage.getItem('LoginUID')}`
       window.open(url)
-    } else if (options.sysType === 'SSO' || options.sysType === 'cloud') {
-      window.open(`${window.location.href.replace(/\/index.html(.*)|\/#(.*)/ig, '')}/doc/index.html#?appkey=${window.GLOB.appkey}&LoginUID=${sessionStorage.getItem('LoginUID')}`)
+    } else if (window.GLOB.sysType === 'SSO' || window.GLOB.sysType === 'cloud') {
+      window.open(`${window.location.href.replace(/\/admin(.*)|\/index.html(.*)|\/#(.*)/ig, '')}/doc/index.html#?appkey=${window.GLOB.appkey}&LoginUID=${sessionStorage.getItem('LoginUID')}`)
     }
   }
 
   changeVerMenu(menu, type) {
     if (type === 'first') {
-      if (menu.OpenType === 'outpage' && menu.linkUrl) {
-        window.open(menu.linkUrl)
-      } else if (menu.OpenType === 'menu') {
-
+      if (menu.OpenType === 'newpage') {
+        window.open(menu.src)
+      } else if (menu.OpenType === 'newtab') {
+        MKEmitter.emit('modifyTabs', menu)
       }
     } else {
-      if (menu.OpenType === 'newpage' || menu.OpenType === 'NewPage') { // NewPage涓烘墦寮�澶栭儴椤甸潰鍦板潃锛宯ewpage涓烘墦寮�绯荤粺鑿滃崟
+      if (menu.OpenType === 'newpage') {
         window.open(menu.src)
-      } else if (menu.OpenType === 'blank') {
-        menu.selected = true
-        this.props.modifyTabview([menu])
-      } else if (this.state.navBar === 'topmenu') {
-        menu.selected = true
-        this.props.modifyTabview([menu])
       } else {
-        let tabs = fromJS(this.props.tabviews).toJS()
-        tabs = tabs.filter(tab => {
-          tab.selected = false
-          return tab.MenuID !== menu.MenuID
-        })
-  
-        if (this.props.tabviews.length > tabs.length) {
-          this.props.modifyTabview(fromJS(tabs).toJS())
-        }
-  
-        this.setState({}, () => {
-          menu.selected = true
-          tabs.push(menu)
-          this.props.modifyTabview(tabs)
-        })
+        MKEmitter.emit('modifyTabs', menu)
       }
   
       if (window.GLOB.systemType === 'production') {
@@ -592,38 +527,98 @@
     }
   }
 
+  verup = () => {
+    confirm({
+      title: '椤甸潰鏇存柊',
+      content: '閲嶆柊鍔犺浇搴旂敤淇℃伅',
+      onOk() {
+        return new Promise(resolve => {
+          if (!window.GLOB.IndexDB) {
+            notification.warning({
+              top: 92,
+              message: '鏇存柊澶辫触锛岃鍒锋柊椤甸潰閲嶈瘯锛�',
+              duration: 2
+            })
+            resolve()
+          } else {
+            Api.updateAppVersion()
+            Api.delCacheConfig('all')
+            setTimeout(() => {
+              notification.success({
+                top: 92,
+                message: '鏇存柊鎴愬姛锛�',
+                duration: 2
+              })
+              resolve()
+            }, 1000)
+          }
+        })
+      },
+      onCancel() {}
+    })
+  }
+
+  about = () => {
+    Modal.success({
+      title: '绯荤粺鐗堟湰v' + window.GLOB.appVersion
+    })
+  }
+
+  wxnotice = () => {
+    Modal.success({
+      className: 'mk-wx-notice',
+      title: <QrCode card={{qrWidth: 320, color: '#000000'}} value={window.GLOB.baseurl + 'mob/wxnotice.html?userid=' + sessionStorage.getItem('UserID') + '&loginuid=' + sessionStorage.getItem('LoginUID')}/>,
+      okText: '鍏抽棴'
+    })
+  }
+
+  changeToHome = () => {
+    if (!['linkage', 'menu_board'].includes(window.GLOB.navBar)) return
+
+    MKEmitter.emit('modifyTabs', {MenuID: 'home_page_id', EasyCode: '', MenuName: 'home', type: 'CustomPage'})
+  }
+
   render () {
     const { mainMenu, collapse } = this.props
-    const { thdMenuList, searchkey, oriVersion, newVersion, debug, menulist, navBar } = this.state
+    const { thdMenuList, searchkey, debug, menulist } = this.state
+    const navBar = window.GLOB.navBar
 
     const menu = (
       <Menu className="header-dropdown">
         {debug && <Menu.Item key="switch">
-          {this.state.dict['main.edit']}
+          缂栬緫
           <Switch size="small" style={{marginLeft: '7px'}} checked={false} onChange={this.changeEditState} />
         </Menu.Item>}
-        <Menu.Item key="password" onClick={this.changePassword}>{this.state.dict['main.password']}</Menu.Item>
+        <Menu.Item key="password" onClick={this.changePassword}>淇敼瀵嗙爜</Menu.Item>
         {this.state.systems.length ? <Menu.SubMenu style={{minWidth: '110px'}} title="鍒囨崲绯荤粺">
           {this.state.systems.map((system, index) => (
             <Menu.Item style={{minWidth: '100px', lineHeight: '30px'}} key={'sub' + index} onClick={() => {this.changeSystem(system)}}> {system.AppName} </Menu.Item>
           ))}
         </Menu.SubMenu> : null}
-        <Menu.Item key="doc" onClick={this.gotoDoc}>{this.state.dict['main.doc']}</Menu.Item>
-        {oriVersion ? <Menu.Item key="verup" onClick={this.verup}>
-          <Badge dot={oriVersion !== newVersion}>{this.state.dict['main.verup']}</Badge>
+        <Menu.Item key="doc" onClick={this.gotoDoc}>鏂囨。涓績</Menu.Item>
+        <Menu.Item key="verup" onClick={this.verup}>
+          椤甸潰鏇存柊
+        </Menu.Item>
+        {window.GLOB.WXNotice ? <Menu.Item key="wxnotice" onClick={this.wxnotice}>
+          寰俊娑堟伅
         </Menu.Item> : null}
-        <Menu.Item key="logout" onClick={this.logout}>{this.state.dict['main.logout']}</Menu.Item>
+        {window.GLOB.appVersion ? <Menu.Item key="version" onClick={this.about}>
+          鍏充簬
+        </Menu.Item> : null}
+        <Menu.Item key="logout" onClick={this.logout}>閫�鍑�</Menu.Item>
       </Menu>
     )
 
     return (
       <header className="header-container ant-menu-dark" id="main-header-container">
-        <div className={'header-logo ' + (collapse && navBar !== 'topmenu' ? 'collapse' : '')}><img src={this.state.logourl} alt=""/></div>
-        <div className={'header-collapse ' + (collapse && navBar !== 'topmenu' ? 'collapse' : '')}>
-          {navBar !== 'topmenu' ? <Icon type={collapse ? 'menu-unfold' : 'menu-fold'} onClick={this.handleCollapse}/> : null}
-        </div>
+        {navBar === 'shutter' ?
+          <div className={'header-logo ' + (collapse ? 'collapse' : '')}><img src={this.state.logourl} alt=""/></div> : 
+          <div className="header-logo" onClick={this.changeToHome}><img src={this.state.logourl} alt=""/></div>}
+        {navBar === 'shutter' ? <div className={'header-collapse ' + (collapse ? 'collapse' : '')}>
+          {collapse ? <MenuUnfoldOutlined onClick={this.handleCollapse}/> : <MenuFoldOutlined onClick={this.handleCollapse}/>}
+        </div> : <div style={{width: '20px', height: '45px'}}></div>}
         {/* 姝e父鑿滃崟 */}
-        {navBar !== 'topmenu' && menulist ?
+        {navBar === 'shutter' && menulist ?
           <ul className="header-menu">{
             menulist.map(item => {
               return (
@@ -634,8 +629,7 @@
             })}
           </ul> : null
         }
-        {/* 姝e父鑿滃崟 */}
-        {navBar === 'topmenu' && menulist ?
+        {(navBar === 'linkage' || navBar === 'linkage_navigation') && menulist ?
           <ul className="header-menu vertical-menu">{
             menulist.map(item => {
               if (item.children && item.children.length > 0) {
@@ -678,15 +672,47 @@
             })}
           </ul> : null
         }
-        {/* 澶村儚銆佺敤鎴峰悕 */}
-        <Dropdown className="header-setting" overlay={menu}>
-          <div>
-            <img src={this.state.avatar || avatar} alt=""/>
-            <span>
-              <span className="username">{this.state.userName}</span> <Icon type="down" />
-            </span>
-          </div>
-        </Dropdown>
+        {(navBar === 'menu_board' || navBar === 'menu_board_navigation') && menulist ?
+          <ul className="header-menu vertical-menu">{
+            menulist.map(item => {
+              if (item.children && item.children.length > 0) {
+                return (
+                  <Dropdown key={item.MenuID} placement="bottomCenter" overlayClassName="vertical-dropdown-menu" overlay={
+                    <div className="menu-board">
+                      {item.children.map(cell => {
+                        return (
+                          <div className="menu-wrap" key={cell.MenuID}>
+                            <div className="title" onClick={e => e.stopPropagation()}>{cell.MenuName}</div>
+                            <div className="menu-detail">
+                              {cell.children && cell.children.map(m => (
+                                <div key={m.MenuID} title={m.MenuName} onClick={() => {this.changeVerMenu(m)}}>
+                                  {m.MenuName}
+                                </div>
+                              ))}
+                            </div>
+                          </div>
+                        )
+                      })}
+                    </div>
+                  }>
+                    <li>
+                      <span>{item.MenuName}</span>
+                    </li>
+                  </Dropdown>
+                )
+              } else {
+                return (
+                  <li key={item.MenuID} onClick={() => {this.changeVerMenu(item, 'first')}}>
+                    <span>{item.MenuName}</span>
+                  </li>
+                )
+              }
+            })}
+          </ul> : null
+        }
+        {!menulist ?
+          <div className="header-menu"></div> : null
+        }
         {/* 鑿滃崟鎼滅储 */}
         {thdMenuList.length > 0 ?
           <Dropdown overlayClassName="menu-select-dropdown" getPopupContainer={() => document.getElementById('main-header-container')} overlay={
@@ -709,43 +735,43 @@
                         option.MenuNo.toLowerCase().indexOf(searchkey.toLowerCase()) >= 0 ||
                         option.EasyCode.toLowerCase().indexOf(searchkey.toLowerCase()) >= 0
                       ) {
-                        return <Menu.Item key={option.MenuID} onClick={() => this.changeVerMenu(option)}>{option.MenuName}</Menu.Item>
+                        return <Menu.Item key={option.MenuID} onClick={() => this.changeVerMenu(option)}>{option.menu_name}</Menu.Item>
                       } else {
                         return null
                       }
                     }
-                    return <Menu.Item key={option.MenuID} onClick={() => this.changeVerMenu(option)}>{option.MenuName}</Menu.Item>
+                    return <Menu.Item key={option.MenuID} onClick={() => this.changeVerMenu(option)}>{option.menu_name}</Menu.Item>
                   })}
                 </Menu>
               </div>
             </div>
           } trigger={['click']} className="search-menu" placement="bottomRight" onVisibleChange={this.dropdownMenuChange}>
-            <Icon className="search-menu" type="search" />
+            <SearchOutlined className="search-menu" />
           </Dropdown> : null
         }
-        {/* 淇敼瀵嗙爜 */}
-        <Modal
-          title={this.state.dict['main.password']}
-          visible={this.state.visible}
-          onOk={this.resetPwdSubmit}
-          confirmLoading={this.state.confirmLoading}
-          onCancel={this.handleCancel}
-          destroyOnClose
-        >
-          <Resetpwd dict={this.state.dict} wrappedComponentRef={(inst) => this.formRef = inst} resetPwdSubmit={this.resetPwdSubmit}/>
-        </Modal>
+        {/* 澶村儚銆佺敤鎴峰悕 */}
+        <Dropdown className="header-setting" overlay={menu}>
+          <div>
+            <img src={this.state.avatar || avatar} alt=""/>
+            <span>
+              <span className="username"><span>{this.state.fullName}</span>{this.state.userName ? <span>{this.state.userName}</span> : null}</span> <DownOutlined />
+            </span>
+          </div>
+        </Dropdown>
         {/* 缂栬緫鐘舵�佺櫥褰� */}
         <Modal
-          title={this.state.dict['main.login.develop']}
+          title="鐧诲綍寮�鍙戞満"
           visible={this.state.loginVisible}
           onOk={this.loginSubmit}
           width={'430px'}
           confirmLoading={this.state.loginLoading}
           onCancel={() => {this.setState({ loginVisible: false, loginLoading: false })}}
           destroyOnClose
-        >
+          >
           <LoginForm handleSubmit={() => this.loginSubmit()} wrappedComponentRef={(inst) => this.loginRef = inst}/>
         </Modal>
+        {/* 淇敼瀵嗙爜 */}
+        <Resetpwd />
       </header>
     )
   }
@@ -753,24 +779,17 @@
 
 const mapStateToProps = (state) => {
   return {
-    tabviews: state.tabviews,
     collapse: state.collapse,
-    menuTree: state.menuTree,
-    mainMenu: state.mainMenu,
-    permAction: state.permAction,
+    mainMenu: state.mainMenu
   }
 }
 
 const mapDispatchToProps = (dispatch) => {
   return {
     toggleCollapse: (collapse) => dispatch(toggleCollapse(collapse)),
-    modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)),
-    modifyMenuTree: (menuTree) => dispatch(modifyMenuTree(menuTree)),
     modifyMainMenu: (mainMenu) => dispatch(modifyMainMenu(mainMenu)),
-    initActionPermission: (permAction) => dispatch(initActionPermission(permAction)),
-    initMenuPermission: (permMenus) => dispatch(initMenuPermission(permMenus)),
     logout: () => dispatch(logout())
   }
 }
 
-export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Form.create()(Header)))
\ No newline at end of file
+export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Header))
\ No newline at end of file

--
Gitblit v1.8.0