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

---
 src/views/design/header/index.jsx |  172 ++++++++++++++++++++++++++++++---------------------------
 1 files changed, 91 insertions(+), 81 deletions(-)

diff --git a/src/views/design/header/index.jsx b/src/views/design/header/index.jsx
index a34c34d..7324d56 100644
--- a/src/views/design/header/index.jsx
+++ b/src/views/design/header/index.jsx
@@ -2,8 +2,8 @@
 import { withRouter } from 'react-router-dom'
 import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
-import { Dropdown, Menu, Modal, notification, Switch, Button } from 'antd'
-import { MenuFoldOutlined, EditOutlined, AppstoreOutlined, DownOutlined, HomeOutlined, ApiOutlined } from '@ant-design/icons'
+import { Dropdown, Menu, Modal, notification, Switch, Button, Popover } from 'antd'
+import { MenuFoldOutlined, SettingOutlined, AppstoreOutlined, DownOutlined, HomeOutlined, ApiOutlined, PlusOutlined, SwapOutlined } from '@ant-design/icons'
 
 import asyncComponent from '@/utils/asyncComponent'
 import {
@@ -14,8 +14,6 @@
 } from '@/store/action'
 import Api from '@/api'
 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 MainLogo from '@/assets/img/main-logo.png'
@@ -24,22 +22,25 @@
 
 const EditMenu = asyncComponent(() => import('./editfirstmenu'))
 const VersionsUp = asyncComponent(() => import('./versions'))
+const ThawMenu = asyncComponent(() => import('@/components/thawmenu'))
+const MenuForm = asyncComponent(() => import('./editfirstmenu/menuform'))
 const { confirm } = Modal
 
 class Header extends Component {
   state = {
     menulist: null, // 涓�绾ц彍鍗�
-    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
     userName: sessionStorage.getItem('CloudUserName'),
     avatar: Utils.getrealurl(sessionStorage.getItem('CloudAvatar')),
-    memberLevel: Utils.getMemberLevel()
+    memberLevel: Utils.getMemberLevel(),
+    visible: false,
+    loading: false
   }
 
   logout = () => {
     // 閫�鍑虹櫥褰�
     let _this = this
     confirm({
-      title: this.state.dict['main.logout.hint'],
+      title: '鎮ㄧ‘瀹氳閫�鍑哄悧?',
       content: '',
       onOk() {
         sessionStorage.clear()
@@ -82,11 +83,7 @@
       if (window.GLOB.systemType !== 'production') { // 闈炴寮忕郴缁熼�夋嫨绗竴椤�
         this.props.modifyMainMenu(menulist[0] || null)
       } else {
-        this.props.resetEditLevel('HS')
-        window.GLOB.mkHS = true
-        this.props.modifyMainMenu({
-          MenuID: 'systemManageView'
-        })
+
       }
     } else {
       notification.error({
@@ -196,42 +193,42 @@
     // 杩涘叆缂栬緫鐘舵��
     this.props.resetEditLevel('level1')
   }
-
-  enterEditManage = () => {
-    const { editLevel } = this.props
-
-    if (editLevel === 'HS')  return
-
-    window.GLOB.mkHS = true
-    this.props.resetEditLevel('HS')
-    this.props.modifyMainMenu({
-      MenuID: 'systemManageView'
-    })
-  }
-
-  /**
-   * @description 閫�鍑虹鐞嗙晫闈㈣彍鍗�
-   */
-  exitManage = () => {
-    const { menulist } = this.state
-
-    if (window.GLOB.systemType === 'production') { // 姝e紡绯荤粺鐗堟湰鍗囩骇鍚庯紝椤甸潰鍒锋柊
-      this.props.history.replace('/main')
-      window.location.reload()
-      return
-    }
-
-    this.props.modifyMainMenu(menulist[0] || null)
-    this.props.resetEditLevel(false)
-    window.GLOB.mkHS = false
-
-    MKEmitter.emit('modifyTabs', null, 'replace')
-  }
   
   exitEdit = () => {
     // 閫�鍑虹紪杈戠姸鎬�
     this.props.resetEditLevel(false)
-    window.GLOB.mkHS = false
+  }
+
+  
+  addMemuSubmit = () => {
+    // 鏂板缓鑿滃崟锛氭彁浜�
+    this.addMenuFormRef.handleConfirm().then(param => {
+      param.func = 'sPC_MainMenu_Add'
+      param.Sort = (this.state.menulist.length + 1) * 10
+
+      this.setState({
+        loading: true
+      })
+      Api.getSystemConfig(param).then(res => {
+        if (res.status) {
+          this.setState({
+            loading: false,
+            visible: false,
+          })
+          
+          this.loadmenu()
+        } else {
+          this.setState({
+            loading: false
+          })
+          notification.warning({
+            top: 92,
+            message: res.message,
+            duration: 5
+          })
+        }
+      })
+    }, () => {})
   }
   
   UNSAFE_componentWillMount () {
@@ -289,6 +286,7 @@
 
       this.reload()
     })
+    MKEmitter.addListener('mkUpdateMenuList', this.reload)
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -302,6 +300,7 @@
     this.setState = () => {
       return
     }
+    MKEmitter.removeListener('mkUpdateMenuList', this.reload)
   }
 
   gotoDoc = () => {
@@ -316,10 +315,10 @@
 
   render () {
     const { mainMenu, editLevel } = this.props
-    const { menulist, memberLevel } = this.state
+    const { menulist, memberLevel, visible, loading } = this.state
 
     return (
-      <header className={'sys-header-container ant-menu-dark ' + (['level2', 'level3', 'HS'].includes(editLevel) ? 'mask' : '')} id="main-header-container">
+      <header className={'sys-header-container ant-menu-dark ' + (['level2', 'level3'].includes(editLevel) ? 'mask' : '')} id="main-header-container">
         <div className="header-logo"><img src={MainLogo} alt=""/></div>
         <div className="header-collapse">
           <MenuFoldOutlined/>
@@ -334,48 +333,46 @@
                 </li>
               )
             })}
-            {!editLevel || editLevel === 'HS' ?
-              <li key="HS" onClick={this.enterEditManage} className={editLevel === 'HS' ? 'active' : ''}>
+            {!editLevel ?
+              <li key="HS" onClick={() => window.open('#/hs')}>
                 <span>HS</span>
               </li> : null
             }
           </ul> : null
         }
-        {editLevel === 'HS' ? <Button className="level4-close" type="primary" onClick={this.exitManage}>閫�鍑�</Button> : null}
         {/* 杩涘叆缂栬緫鎸夐挳 */}
-        {!editLevel && menulist ? <EditOutlined onClick={this.enterEdit} className="edit-check" /> : null}
-        {!editLevel && window.GLOB.systemType !== 'production' ?
-          <div className="app-entrance entrance">
-            <div className="icon"><AppstoreOutlined /></div>
-            <div className="title">搴旂敤绠$悊</div>
-            <div className="detail">鍙垱寤哄強绠$悊PC銆乸ad鍙婄Щ鍔ㄧ绛変笉鍚岃澶囩殑搴旂敤锛屽疄鐜版槑绉戜簯APP銆佸井淇″叕浼楀彿銆佸皬绋嬪簭绛夊骞冲彴鐨勫簲鐢ㄥ叡浜��</div>
+        {!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>
+          </div>
+        } trigger="hover">
+          <SettingOutlined className="edit-check"/>
+        </Popover> : null}
+        <div className="app-entrance entrance">
+          <div className="icon"><AppstoreOutlined /></div>
+          <div className="title">搴旂敤绠$悊</div>
+          <div className="detail">鍙垱寤哄強绠$悊PC銆乸ad鍙婄Щ鍔ㄧ绛変笉鍚岃澶囩殑搴旂敤锛屽疄鐜版槑绉戜簯APP銆佸井淇″叕浼楀彿銆佸皬绋嬪簭绛夊骞冲彴鐨勫簲鐢ㄥ叡浜��</div>
+          {window.GLOB.systemType !== 'production' ? 
             <Button type="primary" disabled={!(memberLevel >= 20)} title={memberLevel >= 20 ? '' : '浼氬憳绛夌骇涓嶅锛屾棤寮�鍙戞潈闄愩��'} onClick={() => {window.open('#/appmanage')}}>
               缂栬緫
-            </Button>
-          </div> : null
-        }
-        {editLevel === 'HS' && window.GLOB.systemType === 'production' ?
-          <div className="app-prod-entrance entrance">
-            <div className="icon"><AppstoreOutlined /></div>
-            <div className="title">搴旂敤绠$悊</div>
-            <div className="detail">鍙垱寤哄強绠$悊PC銆乸ad鍙婄Щ鍔ㄧ绛変笉鍚岃澶囩殑搴旂敤锛屽疄鐜版槑绉戜簯APP銆佸井淇″叕浼楀彿銆佸皬绋嬪簭绛夊骞冲彴鐨勫簲鐢ㄥ叡浜��</div>
+            </Button> :
             <Button type="primary" disabled={!(memberLevel >= 20)} title={memberLevel >= 20 ? '' : '浼氬憳绛夌骇涓嶅锛屾棤寮�鍙戞潈闄愩��'} onClick={() => {window.open('#/appcheck')}}>
               鏌ョ湅
             </Button>
-          </div> : null
-        }
-        {!editLevel ?
-          <div className="api-entrance entrance">
-            <div className="icon"><ApiOutlined /></div>
-            <div className="title">鎺ュ彛璋冭瘯</div>
-            <div className="detail">鍙嚜鍔ㄥ鐞嗙櫥褰曟帴鍙g殑鍙傛暟鍔犲瘑锛屼互鍙婁笟鍔℃帴鍙g殑绛惧悕璁$畻锛屾柟渚垮紑鍙戜汉鍛樼殑鎺ュ彛娴嬭瘯宸ヤ綔銆�</div>
-            <Button type="primary" disabled={!(memberLevel >= 20)} title={memberLevel >= 20 ? '' : '浼氬憳绛夌骇涓嶅锛屾棤寮�鍙戞潈闄愩��'} onClick={() => {window.open('#/interface')}}>
-              缂栬緫
-            </Button>
-          </div> : null
-        }
+          }
+        </div>
+        <div className="api-entrance entrance">
+          <div className="icon"><ApiOutlined /></div>
+          <div className="title">鎺ュ彛璋冭瘯</div>
+          <div className="detail">鍙嚜鍔ㄥ鐞嗙櫥褰曟帴鍙g殑鍙傛暟鍔犲瘑锛屼互鍙婁笟鍔℃帴鍙g殑绛惧悕璁$畻锛屾柟渚垮紑鍙戜汉鍛樼殑鎺ュ彛娴嬭瘯宸ヤ綔銆�</div>
+          <Button type="primary" disabled={!(memberLevel >= 20)} title={memberLevel >= 20 ? '' : '浼氬憳绛夌骇涓嶅锛屾棤寮�鍙戞潈闄愩��'} onClick={() => {window.open('#/interface')}}>
+            缂栬緫
+          </Button>
+        </div>
         {/* window.btoa(window.encodeURIComponent(JSON.stringify({ MenuType: 'home', MenuId: 'home_page_id', MenuName: '棣栭〉' }))) */}
-        {!editLevel && window.GLOB.systemType !== 'production' ?
+        {window.GLOB.systemType !== 'production' ?
           <div className="home-entrance entrance">
             <div className="icon"><HomeOutlined /></div>
             <div className="title">棣栭〉</div>
@@ -391,14 +388,14 @@
         <Dropdown className="header-setting" overlay={
           <Menu className="header-dropdown">
             <Menu.Item key="switch">
-              {this.state.dict['main.edit']}
+              缂栬緫
               <Switch size="small" style={{marginLeft: '7px'}} disabled={!!editLevel} checked={true} onChange={this.changeEditState} />
             </Menu.Item>
-            <Menu.Item key="doc" onClick={this.gotoDoc}>{this.state.dict['main.doc']}</Menu.Item>
+            <Menu.Item key="doc" onClick={this.gotoDoc}>鏂囨。涓績</Menu.Item>
             {options.sysType !== 'cloud' ? <Menu.Item style={{padding: 0}} key="verup">
               <VersionsUp />
             </Menu.Item> : null}
-            <Menu.Item key="logout" onClick={this.logout}>{this.state.dict['main.logout']}</Menu.Item>
+            <Menu.Item key="logout" onClick={this.logout}>閫�鍑�</Menu.Item>
           </Menu>
         }>
           <div style={{zIndex: 1, position: 'relative'}}>
@@ -408,6 +405,20 @@
             </span>
           </div>
         </Dropdown>
+        <Modal
+          title="娣诲姞鑿滃崟"
+          visible={visible}
+          onOk={this.addMemuSubmit}
+          confirmLoading={loading}
+          onCancel={() => this.setState({visible: false})}
+          destroyOnClose
+        >
+          <MenuForm
+            menu={null}
+            inputSubmit={this.addMemuSubmit}
+            wrappedComponentRef={(inst) => this.addMenuFormRef = inst}
+          />
+        </Modal>
       </header>
     )
   }
@@ -417,8 +428,7 @@
   return {
     menuTree: state.menuTree,
     mainMenu: state.mainMenu,
-    editLevel: state.editLevel,
-    permAction: state.permAction
+    editLevel: state.editLevel
   }
 }
 

--
Gitblit v1.8.0