From d59f518f466274b2caeb2e01c10c92deafe7c93b Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 09 二月 2022 11:48:29 +0800
Subject: [PATCH] 2022-02-09

---
 src/components/tabview/index.jsx |   35 +++++++++++++++++++++++++----------
 1 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/src/components/tabview/index.jsx b/src/components/tabview/index.jsx
index a853921..d5320f5 100644
--- a/src/components/tabview/index.jsx
+++ b/src/components/tabview/index.jsx
@@ -2,7 +2,8 @@
 import PropTypes from 'prop-types'
 import {connect} from 'react-redux'
 import { fromJS } from 'immutable'
-import {Tabs, Icon, BackTop, notification} from 'antd'
+import {Tabs, BackTop, notification} from 'antd'
+import { RedoOutlined, CloseOutlined } from '@ant-design/icons'
 import moment from 'moment'
 import 'moment/locale/zh-cn'
 
@@ -10,8 +11,6 @@
 import asyncComponent from '@/utils/asyncLoadComponent'
 import NotFount from '@/components/404'
 import options from '@/store/options.js'
-import mzhCN from '@/locales/zh-CN/main.js'
-import menUS from '@/locales/en-US/main.js'
 import MKEmitter from '@/utils/events.js'
 import Api from '@/api'
 import './index.scss'
@@ -45,7 +44,6 @@
     activeId: '',
     tabviews: null, // 鏍囩闆�
     iFrameHeight: 0,
-    dict: sessionStorage.getItem('lang') !== 'en-US' ? mzhCN : menUS,
   }
 
   // 鍏抽棴tab椤碉紝閲嶆柊閫夋嫨鏄剧ず椤�
@@ -136,10 +134,27 @@
     }
   }
 
-  modifyTabs = (tab, type) => {
-    const { tabviews } = this.state
+  modifyTabs = (tab, type, fixed) => {
+    const { tabviews, activeId } = this.state
 
-    if (type === 'plus') {
+    if (type === 'plus' && fixed) {
+      let _tabs = tabviews.filter(item => item.MenuID !== tab.MenuID)
+      let index = _tabs.findIndex(item => item.MenuID === activeId)
+
+      this.setState({
+        tabviews: _tabs
+      }, () => {
+        if (index > -1) {
+          _tabs.splice(index + 1, 0, tab)
+        } else {
+          _tabs.push(tab)
+        }
+        this.setState({
+          tabviews: _tabs,
+          activeId: tab.MenuID
+        })
+      })
+    } else if (type === 'plus') {
       if (tabviews.findIndex(item => item.MenuID === tab.MenuID) > -1) {
         let _tabs = tabviews.filter(item => item.MenuID !== tab.MenuID)
         this.setState({
@@ -255,7 +270,7 @@
     const { tabviews, activeId } = this.state
 
     return (
-      <section id="mk-tabview-wrap" className={'mk-tabview-wrap' + (this.props.collapse ? ' collapsed' : '')}>
+      <section id="mk-tabview-wrap" className={'mk-tabview-wrap' + (this.props.collapse ? ' collapsed' : '') + (tabviews && tabviews.length > 0 ? ' hastab' : '')}>
         <div className="content-header">
           {tabviews && tabviews.length > 0 &&
             <Tabs activeKey={activeId}>
@@ -264,12 +279,12 @@
                   <Tabs.TabPane
                     tab={
                       <span className="tab-control">
-                        <Icon type="redo" onClick={(e) => {this.refreshTabview(e, view)}}/>
+                        <RedoOutlined onClick={(e) => {this.refreshTabview(e, view)}}/>
                         <span className="tab-name" onClick={(e) => {this.changeTab(e, view)}}>
                           {view.MenuName}
                         </span>
                         {view.type !== 'Home' ?
-                          <Icon type="close" onClick={(e) => {e.stopPropagation();this.closeTabView(view.MenuID)}}/> : null
+                          <CloseOutlined onClick={(e) => {e.stopPropagation();this.closeTabView(view.MenuID)}}/> : null
                         }
                       </span>
                     }

--
Gitblit v1.8.0