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 |  129 +++++++++++++++++++++++++++----------------
 1 files changed, 81 insertions(+), 48 deletions(-)

diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx
index 0f878e0..c9d7275 100644
--- a/src/components/header/index.jsx
+++ b/src/components/header/index.jsx
@@ -11,10 +11,10 @@
   modifyMainMenu,
   logout
 } from '@/store/action'
-import asyncComponent from '@/utils/asyncSpinComponent'
+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 Utils from '@/utils/utils.js'
 import avatar from '@/assets/img/avatar.jpg'
 import './index.scss'
@@ -22,7 +22,8 @@
 const { confirm } = Modal
 const { Search } = Input
 const Resetpwd = asyncComponent(() => import('@/components/resetPassword'))
-const LoginForm = asyncComponent(() => import('./loginform'))
+const QrCode = asyncComponent(() => import('@/components/qrcode'))
+const LoginForm = asyncSpinComponent(() => import('./loginform'))
 
 class Header extends Component {
   static propTpyes = {
@@ -33,7 +34,6 @@
     userName: '',
     fullName: '',
     logourl: window.GLOB.mainlogo,
-    appVersion: window.GLOB.appVersion,
     loginVisible: false,
     loginLoading: false,
     avatar: Utils.getrealurl(sessionStorage.getItem('avatar')),
@@ -66,6 +66,8 @@
     confirm({
       title: '鎮ㄧ‘瀹氳閫�鍑哄悧?',
       content: '',
+      okText: '纭畾',
+      cancelText: '鍙栨秷',
       onOk() {
         sessionStorage.clear()
         _this.props.logout()
@@ -77,8 +79,10 @@
 
   changeMenu (value) {
     // 涓昏彍鍗曞垏鎹�
-    if (value.OpenType === 'outpage') {
-      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)
     }
@@ -86,7 +90,7 @@
 
   getRolesMenu () {
     // 鑾峰彇涓昏彍鍗曞弬鏁�
-    let _param = {func: 's_get_pc_menus', systemType: options.sysType}
+    let _param = {func: 's_get_pc_menus', systemType: window.GLOB.sysType}
     _param.pro_sys = window.GLOB.systemType === 'production' ? 'Y' : ''
     
     Api.getSystemConfig(_param).then(result => {
@@ -102,10 +106,10 @@
       const { menulist, thdMenuList } = this.getMenulist(result)
 
       let systems = []
-      if ((options.sysType === 'local' || options.sysType === 'SSO') && result.sys_list) {
+      if ((window.GLOB.sysType === 'local' || window.GLOB.sysType === 'SSO') && result.sys_list) {
         systems = result.sys_list
 
-        if (options.sysType === 'local' && window.GLOB.systemType !== 'production' && systems.length > 10) {
+        if (window.GLOB.sysType === 'local' && window.GLOB.systemType !== 'production' && systems.length > 10) {
           systems.length = 10
         }
       }
@@ -130,12 +134,9 @@
 
       window.GLOB.mkThdMenus = [...thdMenuList, {MenuID: 'home_page_id', EasyCode: '', MenuName: 'home', type: 'CustomPage'}]
 
-      if (_menu) { // 寤舵椂鎵撳紑锛岄槻姝㈡爣绛剧粍鏈畬鎴愬姞杞�
-        setTimeout(() => {
-          MKEmitter.emit('modifyTabs', _menu)
-        }, 200)
+      if (_menu) {
+        this.openTab(_menu, 0)
       }
-      MKEmitter.emit('mkMenuLoaded')
     })
     
     // 鑾峰彇瑙掕壊鏉冮檺, edition_type 鎺ュ彛鐗堟湰鎺у埗 ''銆�'Y'銆�'A'
@@ -162,10 +163,24 @@
           })
         }
 
-        MKEmitter.emit('mkActionLoaded')
         window.GLOB.mkActions = _permAction
       })
     }, 50)
+  }
+
+  openTab = (menu, times) => {
+    if (times > 50) return
+    times++
+
+    let tabgroup = document.getElementById('mk-tabgroup-wrap')
+
+    if (window.GLOB.mkActions.loaded && tabgroup) {
+      MKEmitter.emit('modifyTabs', menu)
+    } else {
+      setTimeout(() => {
+        this.openTab(times)
+      }, 200)
+    }
   }
 
   getMenulist = (result) => {
@@ -185,8 +200,13 @@
           let PageParam = JSON.parse(fst.PageParam)
 
           if (PageParam.OpenType === 'outpage' && PageParam.linkUrl) {
-            fstItem.OpenType = 'outpage'
-            fstItem.linkUrl = 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) {}
       }
@@ -234,16 +254,23 @@
                   trdItem.hidden = PageParam.hidden || 'false'
 
                   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
                   }
                 } catch (e) {}
-              }
-
-              if (trdItem.type !== 'NewPage') {
+              } else {
                 trdItem.src = '#/tab/' + trd.MenuID
               }
-
-              trdItem.OpenType = trdItem.OpenType.toLowerCase() // NewPage涓烘墦寮�澶栭儴椤甸潰鍦板潃
 
               if (names.has(trdItem.menu_name)) {
                 doublenames.set(trdItem.menu_name, true)
@@ -286,10 +313,6 @@
         loginVisible: true
       })
     } else {
-      sessionStorage.setItem('role_id', sessionStorage.getItem('cloudRole_id'))
-      sessionStorage.setItem('dataM', sessionStorage.getItem('cloudDataM'))
-      sessionStorage.setItem('isEditState', 'true')
-
       this.props.modifyMainMenu(null)
 
       this.props.history.replace('/design')
@@ -330,14 +353,11 @@
           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) {
-            let _url = window.location.href.split('#')[0] + 'cloud'
-
             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.modifyMainMenu(null)
@@ -442,20 +462,20 @@
     setTimeout(() => {
       Api.getAppVersion()
     }, 1000)
-    // Api.genericInterface({
-    //   func: 's_get_fcc_account_data',
-    //   fcc_date: '2022-03-01',
-    //   search_type: ''
-    // }).then(res => {
-    // })
 
     // 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 menuId = e.newValue.split(',')[1]
-        if (menuId) {
+        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)
           })
@@ -478,19 +498,21 @@
   }
 
   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') {
+    } 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') {
-        window.open(menu.linkUrl)
+      if (menu.OpenType === 'newpage') {
+        window.open(menu.src)
+      } else if (menu.OpenType === 'newtab') {
+        MKEmitter.emit('modifyTabs', menu)
       }
     } else {
       if (menu.OpenType === 'newpage') {
@@ -511,7 +533,7 @@
       content: '閲嶆柊鍔犺浇搴旂敤淇℃伅',
       onOk() {
         return new Promise(resolve => {
-          if (!window.GLOB.WebSql && !window.GLOB.IndexDB) {
+          if (!window.GLOB.IndexDB) {
             notification.warning({
               top: 92,
               message: '鏇存柊澶辫触锛岃鍒锋柊椤甸潰閲嶈瘯锛�',
@@ -538,7 +560,15 @@
 
   about = () => {
     Modal.success({
-      title: '绯荤粺鐗堟湰v' + this.state.appVersion
+      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: '鍏抽棴'
     })
   }
 
@@ -550,7 +580,7 @@
 
   render () {
     const { mainMenu, collapse } = this.props
-    const { thdMenuList, searchkey, debug, menulist, appVersion } = this.state
+    const { thdMenuList, searchkey, debug, menulist } = this.state
     const navBar = window.GLOB.navBar
 
     const menu = (
@@ -569,7 +599,10 @@
         <Menu.Item key="verup" onClick={this.verup}>
           椤甸潰鏇存柊
         </Menu.Item>
-        {appVersion ? <Menu.Item key="version" onClick={this.about}>
+        {window.GLOB.WXNotice ? <Menu.Item key="wxnotice" onClick={this.wxnotice}>
+          寰俊娑堟伅
+        </Menu.Item> : null}
+        {window.GLOB.appVersion ? <Menu.Item key="version" onClick={this.about}>
           鍏充簬
         </Menu.Item> : null}
         <Menu.Item key="logout" onClick={this.logout}>閫�鍑�</Menu.Item>

--
Gitblit v1.8.0