From 34e7681fd12b1c4e4994d3bea1a553870e10bc50 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 11 三月 2023 17:58:54 +0800
Subject: [PATCH] 2023-03-11

---
 src/components/header/index.jsx |  117 ++++++++++++++++++----------------------------------------
 1 files changed, 36 insertions(+), 81 deletions(-)

diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx
index 7f2669a..cfbbe05 100644
--- a/src/components/header/index.jsx
+++ b/src/components/header/index.jsx
@@ -3,7 +3,6 @@
 import PropTypes from 'prop-types'
 import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
-import moment from 'moment'
 import { Dropdown, Menu, Modal, notification, Switch, Input } from 'antd'
 import { SearchOutlined, DownOutlined, MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons'
 
@@ -16,15 +15,13 @@
 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 './index.scss'
 
 const { confirm } = Modal
 const { Search } = Input
-const Resetpwd = asyncComponent(() => import('./resetpwd'))
+const Resetpwd = asyncComponent(() => import('@/components/resetPassword'))
 const LoginForm = asyncComponent(() => import('./loginform'))
 
 class Header extends Component {
@@ -33,9 +30,6 @@
   }
   state = {
     menulist: null, // 涓�绾ц彍鍗�
-    visible: false, // 淇敼瀵嗙爜妯℃�佹
-    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
-    confirmLoading: false,
     userName: '',
     fullName: '',
     logourl: window.GLOB.mainlogo,
@@ -57,60 +51,12 @@
 
   changePassword = () => {
     // 鐐瑰嚮淇敼瀵嗙爜锛屾樉绀哄脊绐�
-    this.setState({
-      visible: true
-    })
-  }
-
-  resetPwdSubmit = () => {
-    if (!this.formRef) return
-
-    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: '淇敼鎴愬姛锛岃閲嶆柊鐧诲綍銆�',
-            duration: 2
-          })
-          setTimeout(() => {
-            sessionStorage.clear()
-            this.props.logout()
-            this.props.history.replace('/login')
-          }, 2000)
-        } 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)
     })
   }
 
@@ -118,8 +64,10 @@
     // 閫�鍑虹櫥褰�
     let _this = this
     confirm({
-      title: this.state.dict['main.logout.hint'],
+      title: '鎮ㄧ‘瀹氳閫�鍑哄悧?',
       content: '',
+      okText: '纭畾',
+      cancelText: '鍙栨秷',
       onOk() {
         sessionStorage.clear()
         _this.props.logout()
@@ -225,6 +173,8 @@
   getMenulist = (result) => {
     let thdMenuList = []
     let menulist = []
+    let names = new Map()
+    let doublenames = new Map()
     result.fst_menu && result.fst_menu.forEach(fst => {
       let fstItem = {
         MenuID: fst.MenuID,
@@ -268,6 +218,7 @@
                 ParentId: snd.MenuID,
                 MenuID: trd.MenuID,
                 MenuName: trd.MenuName,
+                menu_name: trd.MenuName,
                 ParentNames: [fst.MenuName, snd.MenuName],
                 MenuNo: trd.MenuNo,
                 EasyCode: trd.EasyCode,
@@ -296,6 +247,12 @@
 
               trdItem.OpenType = trdItem.OpenType.toLowerCase() // NewPage涓烘墦寮�澶栭儴椤甸潰鍦板潃
 
+              if (names.has(trdItem.menu_name)) {
+                doublenames.set(trdItem.menu_name, true)
+              } else {
+                names.set(trdItem.menu_name, true)
+              }
+
               thdMenuList.push(trdItem)
 
               return trdItem
@@ -309,6 +266,13 @@
       }
 
       menulist.push(fstItem)
+    })
+
+    thdMenuList = thdMenuList.map(item => {
+      if (doublenames.has(item.menu_name)) {
+        item.menu_name += '锛�' + item.ParentNames.join('-') + '锛�'
+      }
+      return item
     })
 
     return { menulist, thdMenuList }
@@ -594,23 +558,23 @@
     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>
+        <Menu.Item key="doc" onClick={this.gotoDoc}>鏂囨。涓績</Menu.Item>
         <Menu.Item key="verup" onClick={this.verup}>
           椤甸潰鏇存柊
         </Menu.Item>
         {appVersion ? <Menu.Item key="version" onClick={this.about}>
           鍏充簬
         </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>
     )
 
@@ -740,12 +704,12 @@
                         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>
@@ -763,29 +727,20 @@
             </span>
           </div>
         </Dropdown>
-        {/* 淇敼瀵嗙爜 */}
-        <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>
         {/* 缂栬緫鐘舵�佺櫥褰� */}
         <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>
     )
   }

--
Gitblit v1.8.0