From 04b5222fcf0c8f24b3a577cf3a05fb57462982a5 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 11 八月 2020 09:18:27 +0800
Subject: [PATCH] 2020-08-11

---
 src/components/header/index.jsx |   69 +++++++++++++++++++++++++++++-----
 1 files changed, 59 insertions(+), 10 deletions(-)

diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx
index 40bbeb0..eb80ffe 100644
--- a/src/components/header/index.jsx
+++ b/src/components/header/index.jsx
@@ -4,7 +4,7 @@
 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 {
@@ -55,7 +55,9 @@
     avatar: avatar,
     systems: [],
     searchkey: '',
-    thdMenuList: []
+    thdMenuList: [],
+    oriVersion: '',
+    newVersion: ''
   }
 
   handleCollapse = () => {
@@ -633,10 +635,54 @@
         })
       }
     })
+
+    // 鑾峰彇绯荤粺鐨勭増鏈俊鎭�
+    new Promise((resolve, reject) => {
+      Api.getAppVersion(resolve, reject)
+    }).then(res => {
+      this.setState({
+        oriVersion: res.oldVersion,
+        newVersion: res.newVersion
+      })
+    })
   }
 
   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}`,
+      okText: this.state.dict['main.confirm'],
+      cancelText: this.state.dict['main.cancel'],
+      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 = () => {
@@ -650,22 +696,25 @@
   }
 
   render () {
-    const { thdMenuList, searchkey } = this.state
+    const { thdMenuList, searchkey, oriVersion, newVersion } = this.state
 
     const menu = (
-      <Menu overlayclassname="header-dropdown">
-        {this.props.debug && <Menu.Item key="0">
+      <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['main.password']}</Menu.Item> : null}
+        {!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 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.gotoDoc}>{this.state.dict['main.doc']}</Menu.Item>
-        <Menu.Item key="3" onClick={this.logout}>{this.state.dict['main.logout']}</Menu.Item>
+        <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>
     )
 
@@ -695,9 +744,9 @@
         {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.sysType === 'local' && window.GLOB.systemType !== 'production' ?
+        {/* {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
-        }
+        } */}
         {/* 缂栬緫鑿滃崟 */}
         {this.props.editLevel === 'level1' ? <EditMenu menulist={this.state.menulist} reload={this.reload} exitEdit={this.exitEdit}/> : null}
         {/* 澶村儚銆佺敤鎴峰悕 */}

--
Gitblit v1.8.0