From e0f1f05b7567a7bfd29fd5ad54e4b2222ddfcb94 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 26 三月 2020 20:19:06 +0800
Subject: [PATCH] 2020-03-26

---
 src/tabviews/commontable/index.jsx |   62 ++++++++++++++++++++++++------
 1 files changed, 49 insertions(+), 13 deletions(-)

diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx
index ce24774..a43dc50 100644
--- a/src/tabviews/commontable/index.jsx
+++ b/src/tabviews/commontable/index.jsx
@@ -68,7 +68,8 @@
     refreshtabs: null,    // 闇�瑕佸埛鏂扮殑鏍囩闆�
     confirmLoading: false,// 鑷畾涔夎缃ā鎬佹鍔犺浇涓�
     settingVisible: false,// 鑷畾涔夎缃ā鎬佹
-    triggerBtn: null      // 鐐瑰嚮琛ㄦ牸涓垨蹇嵎閿Е鍙戠殑鎸夐挳
+    triggerBtn: null,     // 鐐瑰嚮琛ㄦ牸涓垨蹇嵎閿Е鍙戠殑鎸夐挳
+    tabActive: null       // 鏍囩椤靛睍寮�鎺у埗
   }
 
   /**
@@ -188,6 +189,13 @@
         })
       }
 
+      let _tabActive = {} // 绛涢�夊睍寮�鐨則ab椤�
+
+      config.tabgroups.forEach(groupId => {
+        if (!config[groupId] || config[groupId].length === 0) return
+        _tabActive[groupId] = config[groupId][0].uuid
+      })
+
       let _arrField = []     // 瀛楁闆�
       let _columns = []      // 鏄剧ず鍒�
       let _logcolumns = []   // 鏃ュ織鏄剧ず鍒�
@@ -274,6 +282,7 @@
       this.setState({
         loadingview: false,
         config: config,
+        tabActive: _tabActive,
         userConfig: userConfig,
         setting: config.setting,
         searchlist: config.search,
@@ -303,7 +312,7 @@
   }
 
   setShortcut = () => {
-    const { actions, userConfig } = this.state
+    const { actions, userConfig, config } = this.state
     if (!userConfig) return
 
     document.onkeydown = (event) => {
@@ -357,14 +366,41 @@
             e.preventDefault()
             istrigger = true
 
-            this.setState({
-              triggerBtn: {
-                uuid: new Date().getTime(),
-                parentId: key,
-                button: {...item, uuid: btnkey},
-                data: null
+            let _groupId = ''
+            let _ActiveTabId = ''
+            config.tabgroups.forEach(groupId => {
+              if (!config[groupId] || config[groupId].length === 0) return
+
+              let _tab = config[groupId].filter(tab => tab.uuid === key)[0]
+              if (_tab) {
+                _groupId = groupId
+                _ActiveTabId = _tab.uuid
               }
             })
+
+            if (this.state.tabActive[_groupId] === _ActiveTabId) {
+              this.setState({
+                triggerBtn: {
+                  uuid: new Date().getTime(),
+                  parentId: key,
+                  button: {...item, uuid: btnkey},
+                  data: null
+                }
+              })
+            } else {
+              this.setState({
+                tabActive: {...this.state.tabActive, [_groupId]: _ActiveTabId}
+              }, () => {
+                this.setState({
+                  triggerBtn: {
+                    uuid: new Date().getTime(),
+                    parentId: key,
+                    button: {...item, uuid: btnkey},
+                    data: null
+                  }
+                })
+              })
+            }
           }
         })
       })
@@ -1070,7 +1106,7 @@
   }
 
   render() {
-    const { view, setting, searchlist, actions, columns, loadingview, viewlost, pickup, config, triggerBtn, userConfig } = this.state
+    const { view, setting, searchlist, actions, columns, loadingview, viewlost, pickup, config, triggerBtn, userConfig, tabActive } = this.state
 
     return (
       <div>
@@ -1133,21 +1169,21 @@
               if (config[group].length === 0) return null
 
               return (
-                <Tabs defaultActiveKey="0" key={group}>
-                  {config[group].map((_tab, index) => {
+                <Tabs activeKey={tabActive[group]} key={group} onChange={(key) => this.setState({tabActive: {...tabActive, [group]: key}})}>
+                  {config[group].map(_tab => {
                     return (
                       <TabPane tab={
                         <span>
                           {_tab.icon ? <Icon type={_tab.icon} /> : null}
                           {_tab.label}
                         </span>
-                      } key={`${index}`}>
+                      } key={_tab.uuid}>
                         {_tab.type === 'SubTable' ?
                           <SubTable
                             Tab={_tab}
                             menuType="main"
                             MenuID={_tab.linkTab}
-                            userConfig={userConfig ? userConfig[_tab.linkTab] : null}
+                            userConfig={userConfig ? userConfig[_tab.uuid] : null}
                             triggerBtn={triggerBtn}
                             SupMenuID={this.props.MenuID}
                             refreshtabs={this.state.refreshtabs}

--
Gitblit v1.8.0