From 569ccb3c1ff82f30ffefa7d3700571448d742662 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 03 十二月 2020 11:46:28 +0800
Subject: [PATCH] 2020-12-03

---
 src/components/header/index.jsx |  693 +++++++++++++++++++++++++++++++--------------------------
 1 files changed, 381 insertions(+), 312 deletions(-)

diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx
index 84d11fe..486af95 100644
--- a/src/components/header/index.jsx
+++ b/src/components/header/index.jsx
@@ -4,18 +4,17 @@
 import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
 import moment from 'moment'
-import {Dropdown, Menu, Icon, Modal, Form, notification, Switch, Button, Input } from 'antd'
+import { Dropdown, Menu, Icon, Modal, Form, notification, Switch, Button, Input, Badge } from 'antd'
 
 import asyncComponent from '@/utils/asyncComponent'
 import {
   toggleCollapse,
+  modifyMenuTree,
   modifyMainMenu,
   modifyTabview,
   resetState,
-  resetDebug,
   resetEditState,
   resetEditLevel,
-  initPermission,
   modifyDataManager,
   initActionPermission,
   initMenuPermission,
@@ -23,25 +22,21 @@
 } from '@/store/action'
 import Api from '@/api'
 import options from '@/store/options.js'
-import zhCN from '@/locales/zh-CN/header.js'
-import enUS from '@/locales/en-US/header.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 EditMenu = asyncComponent(() => import('@/templates/headerconfig'))
+const EditMenu = asyncComponent(() => import('@/templates/menuconfig/editfirstmenu'))
 const { confirm } = Modal
 const { Search } = Input
 
 class Header extends Component {
   static propTpyes = {
-    collapse: PropTypes.bool,
-    mainMenu: PropTypes.oneOfType([
-      PropTypes.string,
-      PropTypes.object
-    ])
+    collapse: PropTypes.bool
   }
   state = {
     menulist: null, // 涓�绾ц彍鍗�
@@ -52,10 +47,12 @@
     logourl: window.GLOB.mainlogo,
     loginVisible: false,
     loginLoading: false,
-    avatar: avatar,
+    avatar: Utils.getrealurl(sessionStorage.getItem('avatar')),
     systems: [],
     searchkey: '',
-    thdMenuList: []
+    thdMenuList: [],
+    oriVersion: '',
+    newVersion: ''
   }
 
   handleCollapse = () => {
@@ -78,42 +75,37 @@
       this.setState({
         confirmLoading: true
       })
-      this.resetPwdSubmitexec(res)
+
+      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
+          })
+        }
+      })
     }, () => {})
-  }
-
-  async resetPwdSubmitexec (param) {
-    let _param = {
-      func: 's_PwdUpt',
-      LText: `select '${param.originpwd}','${param.password}'`
-    }
-    
-    _param.LText = Utils.formatOptions(_param.LText)                   // 鍏抽敭瀛楃鏇挎崲锛宐ase64鍔犲瘑
-    _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' // 鏃堕棿鎴�
-    _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)   // md5瀵嗛挜
-
-    let result = await Api.getSystemConfig(_param) // 鍙栨秷淇敼鏈湴瀵嗙爜锛屽彧淇敼鍗曠偣鏈嶅姟鍣�
-
-    if (result.status) {
-      this.setState({
-        visible: false,
-        confirmLoading: false
-      })
-      notification.success({
-        top: 92,
-        message: this.state.dict['header.password.resetsuccess'],
-        duration: 2
-      })
-    } else {
-      notification.warning({
-        top: 92,
-        message: result.message,
-        duration: 5
-      })
-      this.setState({
-        confirmLoading: false
-      })
-    }
   }
 
   handleCancel = () => {
@@ -127,10 +119,8 @@
     // 閫�鍑虹櫥褰�
     let _this = this
     confirm({
-      title: this.state.dict['header.logout.hint'],
+      title: this.state.dict['main.logout.hint'],
       content: '',
-      okText: this.state.dict['header.confirm'],
-      cancelText: this.state.dict['header.cancel'],
       onOk() {
         sessionStorage.clear()
         _this.props.logout()
@@ -155,13 +145,14 @@
 
   async loadmenu () {
     // 鑾峰彇涓昏彍鍗�
-    let _param = {func: 'sPC_Get_MainMenu', systemType: options.systemType}
-    if (sessionStorage.getItem('isEditState') === 'true') { // 缂栬緫鐘舵�佹椂锛岃幏鍙栦竴绾ц彍鍗曪紝澧炲姞鍙傛暟debug
+    let _param = {func: 's_get_pc_menus', systemType: options.sysType}
+    if (sessionStorage.getItem('isEditState') === 'true') { // 缂栬緫鐘舵�佹椂锛屽鍔犲弬鏁癲ebug
       _param.debug = 'Y'
     }
-    if (options.systemType !== 'cloud' && window.GLOB.systemType !== 'official') {
+    if (options.sysType !== 'cloud' && window.GLOB.systemType !== 'production') {
       _param.linkurl = window.GLOB.linkurl
     }
+    _param.pro_sys = window.GLOB.systemType === 'production' ? 'Y' : ''
 
     let result = await Api.getSystemConfig(_param)
 
@@ -169,41 +160,15 @@
     if (!result) return
 
     if (result.status) {
-      if (result.debug === 'true') { // 鏄惁涓篸ebug妯″紡锛屽嵆鍙鍒惰彍鍗曞弬鏁�
-        this.props.resetDebug()
-      }
-
-      let MainMenuId = sessionStorage.getItem('MainMenu') // 鏄惁涓烘墦寮�鏂伴〉闈�
-      if (MainMenuId) {
-        // 閫氳繃url涓璵enuid绛涢�夊嚭閫変腑鐨勪富鑿滃崟
-        let _menu = result.data.filter(item => item.MenuID === MainMenuId)[0]
-        sessionStorage.removeItem('MainMenu')
-        this.props.modifyMainMenu(_menu || result.data[0])
-      } else {
-        this.props.modifyMainMenu(result.data[0])
-      }
+      let res = this.getMenulist(result)
 
       this.setState({
-        menulist: result.data.map((item, index) => {
-          item.id = index
-          item.text = item.MenuName
-          if (item.PageParam) {
-            try {
-              item.PageParam = JSON.parse(item.PageParam)
-            } catch (e) {
-              item.PageParam = {OpenType: 'menu', linkUrl: ''}
-            }
-          } else {
-            item.PageParam = {OpenType: 'menu', linkUrl: ''}
-          }
-          return item
-        }),
-        systems: result.Systems.filter(sys => sys.LinkUrl1 && sys.AppKey !== window.GLOB.appkey)
+        menulist: res.menulist,
+        systems: []
       })
 
-      if (result.dataM) {
-        this.props.modifyDataManager(true)
-      }
+      this.props.modifyMenuTree(res.menulist)
+      this.props.modifyMainMenu(res.menulist[0] || null)
     } else {
       notification.error({
         top: 92,
@@ -213,21 +178,22 @@
     }
   }
 
-  async getRolesMenu () {
+  getRolesMenu () {
     // 鑾峰彇瑙掕壊鏉冮檺
-    let promiseRole = new Promise(resolve => {
-      Api.getSystemConfig({func: 'sPC_Get_RolesMenu'}).then(result => {
-        let _permAction = {}
-        let _permRoles = []
-        if (result && result.status) {
-          if (result.UserRoles) {
-            result.UserRoles.forEach(role => {
-              _permRoles.push(role.RoleID)
+    let roledefer = new Promise(resolve => {
+      // edition_type 鎺ュ彛鐗堟湰鎺у埗 ''銆�'Y'銆�'A'
+      Api.getSystemConfig({
+        func: 's_Get_TrdMenu_Role',
+        edition_type: 'A',
+        pro_sys: window.GLOB.systemType === 'production' ? 'Y' : ''
+      }).then(result => {
+        let _permAction = {} // 鎸夐挳鏉冮檺
 
-              role.RoleMenu.forEach(menu => {
-                if (!menu.MenuID) return
-                _permAction[menu.MenuID] = true
-              })
+        if (result && result.status) {
+          if (result.UserRoles_Menu) {
+            result.UserRoles_Menu.forEach(menu => {
+              if (!menu.MenuID) return
+              _permAction[menu.MenuID] = true
             })
           }
         } else if (result) {
@@ -238,87 +204,205 @@
           })
         }
 
-        resolve({permAction: _permAction, permRoles: _permRoles})
+        this.props.initActionPermission(_permAction)
+        resolve()
       })
     })
-    
+
     // 鑾峰彇涓昏彍鍗曞弬鏁�
-    let promiseMenu = new Promise(resolve => {
-      let _param = {func: 'sPC_Get_MainMenu', systemType: options.systemType}
-      if (options.systemType !== 'cloud' && window.GLOB.systemType !== 'official') {
+    let menudefer = new Promise(resolve => {
+      let _param = {func: 's_get_pc_menus', systemType: options.sysType}
+      if (options.sysType !== 'cloud' && window.GLOB.systemType !== 'production') {
         _param.linkurl = window.GLOB.linkurl
       }
-
+      _param.pro_sys = window.GLOB.systemType === 'production' ? 'Y' : ''
+      
       Api.getSystemConfig(_param).then(result => {
-        let mainMenu = null
-        if (result && result.status) {
-          if (result.debug === 'true') { // 鏄惁涓篸ebug妯″紡锛屽嵆鍙鍒惰彍鍗曞弬鏁�
-            this.props.resetDebug()
-          }
-    
-          let MainMenuId = sessionStorage.getItem('MainMenu') // 鏄惁涓烘墦寮�鏂伴〉闈�
-          if (MainMenuId) {
-            // 閫氳繃url涓璵enuid绛涢�夊嚭閫変腑鐨勪富鑿滃崟
-            let _menu = result.data.filter(item => item.MenuID === MainMenuId)[0]
-            sessionStorage.removeItem('MainMenu')
-            mainMenu = _menu || result.data[0]
-          } else {
-            mainMenu = result.data[0]
-          }
-    
-          this.setState({
-            menulist: result.data.map((item, index) => {
-              item.id = index
-              item.text = item.MenuName
-              if (item.PageParam) {
-                try {
-                  item.PageParam = JSON.parse(item.PageParam)
-                } catch (e) {
-                  item.PageParam = {OpenType: 'menu', linkUrl: ''}
-                }
-              } else {
-                item.PageParam = {OpenType: 'menu', linkUrl: ''}
-              }
-              return item
-            }),
-            systems: result.Systems.filter(sys => sys.LinkUrl1 && sys.AppKey !== window.GLOB.appkey)
-          })
-
-          if (result.dataM) {
-            this.props.modifyDataManager(true)
-          }
-        } else if (result) {
+        if (!result.status || !result.fst_menu) {
           notification.error({
             top: 92,
-            message: result.message,
+            message: result.message || '鏈煡璇㈠埌鑿滃崟淇℃伅锛�',
             duration: 10
           })
+          return
         }
 
-        resolve(mainMenu)
+        let res = this.getMenulist(result)
+
+        this.setState({
+          menulist: res.menulist,
+          thdMenuList: res.thdMenuList,
+          systems: window.GLOB.systemType === 'production' || options.sysType === 'SSO' ? (result.sys_list || []) : []
+        })
+        
+        let mainMenu = res.menulist[0] || null
+        let _menu = null
+
+        if (sessionStorage.getItem('ThirdMenu')) { // 鏄惁涓烘墦寮�鏂伴〉闈�
+          let ThirdMenuId = sessionStorage.getItem('ThirdMenu')
+          _menu = res.thdMenuList.filter(item => item.MenuID === ThirdMenuId)[0] // 閫氳繃url涓璵enuid绛涢�夊嚭閫変腑鐨勪富鑿滃崟
+
+          if (_menu) {
+            mainMenu = res.menulist.filter(item => item.MenuID === _menu.FstId)[0]
+            mainMenu = fromJS(mainMenu).toJS()
+            mainMenu.openId = _menu.ParentId
+          }
+
+          sessionStorage.removeItem('ThirdMenu')
+        }
+
+        this.props.modifyMenuTree(res.menulist)
+        this.props.modifyMainMenu(mainMenu)
+        this.props.initMenuPermission(res.thdMenuList)
+
+        resolve(_menu)
       })
     })
     
-    let _mainMenu = await promiseMenu
-    if (_mainMenu) {
-      this.props.modifyMainMenu(_mainMenu)
-    }
+    Promise.all([roledefer, menudefer]).then(response => {
+      if (response[1]) {
+        let tabs = fromJS(this.props.tabviews).toJS()
+        let menu = fromJS(response[1]).toJS()
 
-    let _role = await promiseRole
+        tabs = tabs.map(tab => {
+          tab.selected = false
+          return tab
+        })
 
-    this.props.initActionPermission(_role.permRoles, _role.permAction)
+        menu.selected = true
+        tabs.push(menu)
+        this.props.modifyTabview(tabs)
+      }
+    })
+  }
+
+  getMenulist = (result) => {
+    let thdMenuList = []
+    let iframes = ['Main/Index', 'bda/rdt', 'Home/rdt']
+    let menulist = result.fst_menu.map(fst => {
+      let fstItem = {
+        MenuID: fst.MenuID,
+        MenuName: fst.MenuName,
+        PageParam: {OpenType: 'menu', linkUrl: ''},
+        children: []
+      }
+      if (fst.PageParam) {
+        try {
+          fstItem.PageParam = JSON.parse(fst.PageParam)
+        } catch (e) {
+          fstItem.PageParam = {OpenType: 'menu', linkUrl: ''}
+        }
+      }
+
+      if (fst.snd_menu) {
+        fstItem.children = fst.snd_menu.map(snd => {
+          let sndItem = {
+            ParentId: fst.MenuID,
+            MenuID: snd.MenuID,
+            MenuName: snd.MenuName,
+            PageParam: {Icon: 'folder'},
+            children: []
+          }
+
+          if (snd.PageParam) {
+            try {
+              sndItem.PageParam = JSON.parse(snd.PageParam)
+            } catch (e) {
+              sndItem.PageParam = {Icon: 'folder'}
+            }
+          }
+
+          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,
+            mstyle: window.GLOB.style
+          }
+
+          if (snd.trd_menu) {
+            sndItem.children = snd.trd_menu.map(trd => {
+              let trdItem = {
+                FstId: fst.MenuID,
+                ParentId: snd.MenuID,
+                MenuID: trd.MenuID,
+                MenuName: trd.MenuName,
+                MenuNo: trd.MenuNo,
+                EasyCode: trd.EasyCode,
+                type: 'CommonTable',            // 榛樿鍊间负甯哥敤琛�
+                OpenType: 'newtab'              // 鎵撳紑鏂瑰紡
+              }
+  
+              if (trd.LinkUrl && iframes.includes(trd.LinkUrl.split('?')[0])) {
+                trdItem.type = 'iframe'
+                trdItem.LinkUrl = trd.LinkUrl
+                trdItem.forbidden = true
+              } else {
+                try {
+                  trdItem.PageParam = trd.PageParam ? JSON.parse(trd.PageParam) : {OpenType: 'newtab'}
+                } catch (e) {
+                  trdItem.PageParam = {OpenType: 'newtab'}
+                }
+
+                trdItem.type = trdItem.PageParam.Template || trdItem.type
+                trdItem.OpenType = trdItem.PageParam.OpenType || trdItem.OpenType
+
+                if (trdItem.type === 'CustomPage' && this.props.memberLevel < 20) { // 浼氬憳绛夌骇澶т簬绛変簬20鏃讹紝鏈夌紪杈戞潈闄�
+                  trdItem.forbidden = true
+                }
+                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瀽閿欒锛�')
+                    }
+                  }
+                } else {
+                  // 鎵撳紑鏂伴〉闈㈤摼鎺�
+                  trdItem.src = '#/paramsmain/' + window.btoa(window.encodeURIComponent(JSON.stringify({
+                    ...msg,
+                    ThirdMenu: trd.MenuID
+                  })))
+                }
+              }
+
+              thdMenuList.push(trdItem)
+
+              return trdItem
+            })
+          }
+
+          return sndItem
+        })
+      }
+
+      return fstItem
+    })
+
+    return { menulist, thdMenuList }
   }
 
   reload = () => {
-    this.setState({
-      menulist: null
-    })
     this.loadmenu()
   }
 
   changeEditState = (state) => {
-    const { menulist } = this.state
-
     if (!state) { // 閫�鍑虹紪杈戯紝椤甸潰鍒锋柊
       window.location.reload()
       return
@@ -328,45 +412,23 @@
     let UserID = sessionStorage.getItem('CloudUserID')
     let LoginUID = sessionStorage.getItem('CloudLoginUID')
 
-    if (state && (!UserID || !LoginUID)) {
+    if (!UserID || !LoginUID) {
       this.setState({
         loginVisible: true
       })
     } else {
-      sessionStorage.setItem('isEditState', state)
-      let _userName = sessionStorage.getItem('User_Name')
-      let _avatar = avatar
+      sessionStorage.setItem('isEditState', 'true')
+      this.props.modifyDataManager(sessionStorage.getItem('cloudDataM') === 'true')
 
-      if (!state && sessionStorage.getItem('avatar')) {
-        _avatar = Utils.getrealurl(sessionStorage.getItem('avatar')) // 澶村儚
-      } else if (state && sessionStorage.getItem('CloudAvatar')) {
-        _avatar = Utils.getrealurl(sessionStorage.getItem('CloudAvatar')) // 澶村儚
-      }
-
-      if (state) {
-        _userName = sessionStorage.getItem('CloudUserName')
-      }
-
-      if (window.GLOB.systemType === 'official' && state) {
+      if (window.GLOB.systemType === 'production') {
         this.props.resetEditLevel('HS')
         this.props.modifyMainMenu({
           MenuID: 'systemManageView'
         })
 
         this.setState({
-          userName: _userName,
-          avatar: _avatar
-        })
-        this.props.resetEditState(state)
-
-        return
-      } else if (window.GLOB.systemType === 'official' && !state) {
-        this.props.resetEditLevel(false)
-        this.props.modifyMainMenu(menulist[0] || '')
-
-        this.setState({
-          userName: _userName,
-          avatar: _avatar
+          userName: sessionStorage.getItem('CloudUserName'),
+          avatar: Utils.getrealurl(sessionStorage.getItem('CloudAvatar'))
         })
         this.props.resetEditState(state)
 
@@ -375,15 +437,15 @@
 
       this.setState({
         menulist: null,
-        userName: _userName,
-        avatar: _avatar
+        userName: sessionStorage.getItem('CloudUserName'),
+        avatar: Utils.getrealurl(sessionStorage.getItem('CloudAvatar'))
       })
       this.loadmenu()
-      this.props.modifyMainMenu('')
+      this.props.modifyMainMenu(null)
       this.props.resetEditState(state)
     }
 
-    if (state && this.props.sysRoles.length === 0 && this.props.permFuncField.length === 0 && window.GLOB.systemType !== 'official') {
+    if (window.GLOB.systemType !== 'production') {
       Api.getSystemConfig({func: 'sPC_Get_Roles_sModular'}).then(res => {
         if (res.status) {
           let _permFuncField = []
@@ -408,7 +470,8 @@
             _permFuncField = _permFuncField.sort()
           }
 
-          this.props.initPermission(_sysRoles, _permFuncField)
+          sessionStorage.setItem('sysRoles', JSON.stringify(_sysRoles))
+          sessionStorage.setItem('permFuncField', JSON.stringify(_permFuncField))
         }
       })
     }
@@ -422,19 +485,19 @@
       Api.getusermsg(param.username, param.password, true).then(res => {
         if (res.status) {
           sessionStorage.setItem('CloudUserID', res.UserID)
-          sessionStorage.setItem('CloudSessionUid', Utils.getuuid())
           sessionStorage.setItem('CloudLoginUID', res.LoginUID)
           sessionStorage.setItem('CloudUserName', res.UserName)
           sessionStorage.setItem('CloudFullName', res.FullName)
           sessionStorage.setItem('CloudAvatar', res.icon)
+          sessionStorage.setItem('cloudDataM', res.dataM ? 'true' : '')
+          
           sessionStorage.setItem('isEditState', 'true')
 
-          let _avatar = avatar
-          if (res.icon) {
-            _avatar = Utils.getrealurl(res.icon) // 澶村儚
+          if (res.dataM) {
+            this.props.modifyDataManager(true)
           }
 
-          if (window.GLOB.systemType === 'official') {
+          if (window.GLOB.systemType === 'production') {
             this.props.resetEditLevel('HS')
             this.props.modifyMainMenu({
               MenuID: 'systemManageView'
@@ -444,7 +507,7 @@
               loginVisible: false,
               loginLoading: false,
               userName: res.UserName,
-              avatar: _avatar
+              avatar: res.icon
             })
             this.props.resetEditState(true)
     
@@ -456,10 +519,10 @@
             loginVisible: false,
             loginLoading: false,
             userName: res.UserName,
-            avatar: _avatar
+            avatar: res.icon
           })
           this.loadmenu()
-          this.props.modifyMainMenu('')
+          this.props.modifyMainMenu(null)
           this.props.resetEditState(true)
         } else {
           this.setState({
@@ -495,14 +558,16 @@
    * @description 閫�鍑虹鐞嗙晫闈㈣彍鍗�
    */
   exitManage = () => {
-    if (window.GLOB.systemType === 'official') { // 姝e紡绯荤粺鐗堟湰鍗囩骇鍚庯紝椤甸潰鍒锋柊
+    const { menulist } = this.state
+
+    if (window.GLOB.systemType === 'production') { // 姝e紡绯荤粺鐗堟湰鍗囩骇鍚庯紝椤甸潰鍒锋柊
       window.location.reload()
       return
     }
 
-    this.props.resetEditState(true)
+    this.props.modifyMainMenu(menulist[0] || null)
     this.props.resetEditLevel(false)
-    this.reload()
+    this.props.modifyTabview([])
   }
   
   exitEdit = () => {
@@ -511,8 +576,18 @@
   }
 
   changeSystem = (system) => {
-    let _param = window.btoa('ud=' + sessionStorage.getItem('UserID') + '&sd=' + sessionStorage.getItem('SessionUid') + '&ld=' + sessionStorage.getItem('LoginUID') + '&un=' + sessionStorage.getItem('User_Name'))
-    window.location.href = system.LinkUrl1 + '#/ssologin/' + _param
+    let href = system.LinkUrl1 + '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 || ''
+    })))
+
+    window.open(href)
   }
 
   dropdownMenuChange = (visible) => {
@@ -520,150 +595,143 @@
       if (visible) {
         setTimeout(() => {
           let input = document.getElementById('thdMenu-search')
-
-          if (input) {
-            input.focus()
-          }
+          input && input.focus()
         }, 500)
       }
     })
   }
 
   selectMenu = (item) => {
-    const { tabviews } = this.props
-    
-    let menu = JSON.parse(JSON.stringify(item))
+    let tabs = fromJS(this.props.tabviews).toJS()
+    let menu = fromJS(item).toJS()
     menu.selected = true
 
-    let index = 0
-    let isexit = false
-    let tabs = tabviews.map((tab, i) => {
+    tabs = tabs.filter(tab => {
       tab.selected = false
-
-      if (tab.MenuID === menu.MenuID) {
-        tab.selected = true
-        isexit = true
-      }
-
-      return tab
+      return tab.MenuID !== menu.MenuID
     })
 
-    if (!isexit) {
-      tabs.splice(index + 1, 0, menu)
+    if (this.props.tabviews.length !== tabs.length) {
+      this.props.modifyTabview(fromJS(tabs).toJS())
     }
 
-    this.props.modifyTabview(tabs)
+    this.setState({}, () => {
+      tabs.push(menu)
+      this.props.modifyTabview(tabs)
+    })
   }
   
   UNSAFE_componentWillMount () {
     // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁
-    let _avatar = sessionStorage.getItem('avatar')
-    if (_avatar) {
-      _avatar = Utils.getrealurl(_avatar) // 澶村儚
-      this.setState({avatar: _avatar})
-    }
     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
+      })
+    }
+  }
+
   componentDidMount () {
-    // 鑾峰彇瑙掕壊鑿滃崟鏉冮檺
-    Api.getSystemConfig({func: 's_Get_TrdMenu_Role'}).then(result => {
-      if (!result) return
-      if (result.status) {
-        let _permMenus = {}
-        let menulist = []
-
-        if (result.UserRoles) {
-          let iframes = ['Main/Index', 'bda/rdt', 'Home/rdt']
-
-          result.UserRoles.forEach(role => {
-            role.RoleMenu.forEach(menu => {
-              if (!menu.MenuID) return
-              _permMenus[menu.MenuID] = true
-
-              let _type = ''
-              if (menu.LinkUrl) {
-                if (menu.LinkUrl === 'CommonTable') {
-                  _type = 'CommonTable'
-                } else if (menu.LinkUrl === 'DataManage') {
-                  _type = 'DataManage'
-                } else if (iframes.includes(menu.LinkUrl.split('?')[0])) {
-                  _type = 'iframe'
-                }
-              }
-  
-              if (_type !== 'iframe') {
-                let pageParam = {}
-                try {
-                  pageParam = JSON.parse(menu.PageParam)
-                } catch (e) {
-                  pageParam = {}
-                }
-                _type = pageParam.Template || _type
-              }
-
-              menulist.push({
-                MenuID: menu.MenuID,
-                MenuName: menu.MenuName,
-                MenuNo: menu.MenuNo || '',
-                EasyCode: menu.EasyCode || '',
-                LinkUrl: menu.LinkUrl,
-                type: _type
-              })
-            })
-          })
-        }
-  
+    // 鑾峰彇绯荤粺鐨勭増鏈俊鎭紝寤舵椂鏌ヨ
+    setTimeout(() => {
+      new Promise((resolve, reject) => {
+        Api.getAppVersion(resolve, reject)
+      }).then(res => {
         this.setState({
-          thdMenuList: menulist
+          oriVersion: res.oldVersion,
+          newVersion: res.newVersion
         })
-
-        this.props.initMenuPermission(_permMenus)
-      } else {
-        notification.error({
-          top: 92,
-          message: result.message,
-          duration: 10
-        })
-      }
-    })
+      }, () => {
+        console.warn('websql 鍒濆鍖栭敊璇紒')
+      })
+    }, 1000)
   }
 
   shouldComponentUpdate (nextProps, nextState) {
     return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
   }
 
+  verup = () => {
+    const { oriVersion, newVersion } = this.state
+    const _this = this
+
+    confirm({
+      title: this.state.dict['main.verup'],
+      content: `鏈�鏂扮増鏈�${newVersion}锛屽綋鍓嶇増鏈�${oriVersion}`,
+      onOk() {
+        return new Promise(resolve => {
+          Api.updateAppVersion(newVersion).then(res => {
+            if (res.status) {
+              notification.success({
+                top: 92,
+                message: '鍗囩骇鎴愬姛锛�',
+                duration: 2
+              })
+              _this.setState({oriVersion: newVersion})
+            } else {
+              notification.warning({
+                top: 92,
+                message: '鍗囩骇澶辫触锛岃鍒锋柊椤甸潰閲嶈瘯锛�',
+                duration: 2
+              })
+            }
+            resolve()
+          })
+        })
+      },
+      onCancel() {}
+    })
+  }
+
+  gotoDoc = () => {
+    if (options.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')}`)
+    }
+  }
+
   render () {
-    const { thdMenuList, searchkey } = this.state
+    const { mainMenu, collapse } = this.props
+    const { thdMenuList, searchkey, oriVersion, newVersion } = this.state
 
     const menu = (
-      <Menu overlayclassname="header-dropdown">
-        {this.props.debug && <Menu.Item key="0">
-          {this.state.dict['header.edit']}
+      <Menu className="header-dropdown">
+        {this.props.debug && <Menu.Item key="switch">
+          {this.state.dict['main.edit']}
           <Switch size="small" className="edit-switch" disabled={!!this.props.editLevel} checked={this.props.editState} onChange={this.changeEditState} />
         </Menu.Item>}
-        {!this.props.editState ? <Menu.Item key="1" onClick={this.changePassword}>{this.state.dict['header.password']}</Menu.Item> : null}
-        {/* {this.state.systems.length > 0 ? <Menu.SubMenu title="鍒囨崲绯荤粺">
+        {!this.props.editState ? <Menu.Item key="password" onClick={this.changePassword}>{this.state.dict['main.password']}</Menu.Item> : null}
+        {this.state.systems.length > 0 ? <Menu.SubMenu className="header-subSystem-box" title="鍒囨崲绯荤粺">
           {this.state.systems.map((system, index) => (
             <Menu.Item className="header-subSystem" key={'sub' + index} onClick={() => {this.changeSystem(system)}}> {system.AppName} </Menu.Item>
           ))}
-        </Menu.SubMenu> : null} */}
-        <Menu.Item key="2" onClick={this.logout}>{this.state.dict['header.logout']}</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> : null}
+        <Menu.Item key="logout" onClick={this.logout}>{this.state.dict['main.logout']}</Menu.Item>
       </Menu>
     )
 
     return (
       <header className="header-container ant-menu-dark" id="main-header-container">
-        <div className={this.props.collapse ? "collapse header-logo" : "header-logo"}><img src={this.state.logourl} alt=""/></div>
-        <div className={this.props.collapse ? "collapse header-collapse" : "header-collapse"} onClick={this.handleCollapse}>
-          <Icon type={this.props.collapse ? 'menu-unfold' : 'menu-fold'} />
+        <div className={collapse ? "collapse header-logo" : "header-logo"}><img src={this.state.logourl} alt=""/></div>
+        <div className={collapse ? "collapse header-collapse" : "header-collapse"} onClick={this.handleCollapse}>
+          <Icon type={collapse ? 'menu-unfold' : 'menu-fold'} />
         </div>
         {/* 姝e父鑿滃崟 */}
         {this.props.editLevel !== 'level1' && this.state.menulist ?
           <ul className={'header-menu ' + this.props.editLevel}>{
             this.state.menulist.map(item => {
               return (
-                <li key={item.MenuID} onClick={() => {this.changeMenu(item)}} className={this.props.selectmenu.MenuID === item.MenuID ? 'active' : ''}>
+                <li key={item.MenuID} onClick={() => {this.changeMenu(item)}} className={mainMenu && mainMenu.MenuID === item.MenuID ? 'active' : ''}>
                   <span>{item.MenuName}</span>
                 </li>
               )
@@ -678,15 +746,21 @@
         {this.props.editLevel === 'HS' ? <Button className="level4-close" type="primary" onClick={this.exitManage}>閫�鍑�</Button> : null}
         {/* 杩涘叆缂栬緫鎸夐挳 */}
         {this.props.editState && !this.props.editLevel ? <Icon onClick={this.enterEdit} className="edit-check" type="edit" /> : null}
-        {/* {this.props.editState && !this.props.editLevel && options.systemType === 'local' && window.GLOB.systemType !== 'official' ?
+        {/* {this.props.editState && !this.props.editLevel && options.sysType === 'local' && window.GLOB.systemType !== 'production' ?
           <a href="#/mobmanage" target="_blank" className="mobile" type="edit"> 搴旂敤绠$悊 <Icon type="arrow-right" /></a> : null
         } */}
+        {/* window.btoa(window.encodeURIComponent(JSON.stringify({ MenuType: 'home', MenuId: 'home_page_id', MenuName: '棣栭〉' }))) */}
+        {this.props.editState && !this.props.editLevel && window.GLOB.systemType !== 'production' && this.props.memberLevel >= 20 ?
+          <a className="home-edit" href={`#/menudesign/JTdCJTIyTWVudVR5cGUlMjIlM0ElMjJob21lJTIyJTJDJTIyTWVudUlkJTIyJTNBJTIyaG9tZV9wYWdlX2lkJTIyJTJDJTIyTWVudU5hbWUlMjIlM0ElMjIlRTklQTYlOTYlRTklQTElQjUlMjIlN0Q=`} target="_blank" rel="noopener noreferrer">
+            棣栭〉 <Icon type="arrow-right" />
+          </a> : null
+        }
         {/* 缂栬緫鑿滃崟 */}
         {this.props.editLevel === 'level1' ? <EditMenu menulist={this.state.menulist} reload={this.reload} exitEdit={this.exitEdit}/> : null}
         {/* 澶村儚銆佺敤鎴峰悕 */}
         <Dropdown className="header-setting" overlay={menu}>
           <div>
-            <img src={this.state.avatar} alt=""/>
+            <img src={this.state.avatar || avatar} alt=""/>
             <span>
               <span className="username">{this.state.userName}</span> <Icon type="down" />
             </span>
@@ -730,9 +804,7 @@
         }
         {/* 淇敼瀵嗙爜 */}
         <Modal
-          title={this.state.dict['header.password']}
-          okText={this.state.dict['header.confirm']}
-          cancelText={this.state.dict['header.cancel']}
+          title={this.state.dict['main.password']}
           visible={this.state.visible}
           onOk={this.resetPwdSubmit}
           confirmLoading={this.state.confirmLoading}
@@ -743,9 +815,7 @@
         </Modal>
         {/* 缂栬緫鐘舵�佺櫥褰� */}
         <Modal
-          title={this.state.dict['header.login.develop']}
-          okText={this.state.dict['header.confirm']}
-          cancelText={this.state.dict['header.cancel']}
+          title={this.state.dict['main.login.develop']}
           visible={this.state.loginVisible}
           onOk={this.loginSubmit}
           width={'430px'}
@@ -764,13 +834,13 @@
   return {
     tabviews: state.tabviews,
     collapse: state.collapse,
-    selectmenu: state.selectedMainMenu,
+    menuTree: state.menuTree,
+    mainMenu: state.mainMenu,
     debug: state.debug,
     editState: state.editState,
     editLevel: state.editLevel,
     permAction: state.permAction,
-    sysRoles: state.sysRoles,
-    permFuncField: state.permFuncField
+    memberLevel: state.memberLevel
   }
 }
 
@@ -778,15 +848,14 @@
   return {
     toggleCollapse: (collapse) => dispatch(toggleCollapse(collapse)),
     modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)),
-    modifyMainMenu: (selectmenu) => dispatch(modifyMainMenu(selectmenu)),
+    modifyMenuTree: (menuTree) => dispatch(modifyMenuTree(menuTree)),
+    modifyMainMenu: (mainMenu) => dispatch(modifyMainMenu(mainMenu)),
     resetEditState: (state) => dispatch(resetEditState(state)),
     resetEditLevel: (level) => dispatch(resetEditLevel(level)),
-    initActionPermission: (permRoles, permAction) => dispatch(initActionPermission(permRoles, permAction)),
-    initPermission: (sysRoles, permFuncField) => dispatch(initPermission(sysRoles, permFuncField)),
+    initActionPermission: (permAction) => dispatch(initActionPermission(permAction)),
     initMenuPermission: (permMenus) => dispatch(initMenuPermission(permMenus)),
     modifyDataManager: (dataManager) => dispatch(modifyDataManager(dataManager)),
     resetState: () => dispatch(resetState()),
-    resetDebug: () => dispatch(resetDebug()),
     logout: () => dispatch(logout())
   }
 }

--
Gitblit v1.8.0