From 51a60b5cb00fdeaf9e42c29341242460bf2154e8 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 18 九月 2020 09:37:22 +0800
Subject: [PATCH] 2020-09-18

---
 src/menu/components/tabs/antv-tabs/index.jsx |   37 +++++++++++++++++++++++++++++++++----
 1 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/src/menu/components/tabs/antv-tabs/index.jsx b/src/menu/components/tabs/antv-tabs/index.jsx
index 4c572a4..c36136a 100644
--- a/src/menu/components/tabs/antv-tabs/index.jsx
+++ b/src/menu/components/tabs/antv-tabs/index.jsx
@@ -40,12 +40,14 @@
         uuid: tabs.uuid,
         type: tabs.type,
         floor: tabs.floor,
+        tabId: tabs.tabId || '',
+        parentId: tabs.parentId || '',
         subtype: tabs.subtype,
         setting: {span: 12, position: 'top', tabStyle: 'line', name: tabs.name},
         subtabs: [
-          { uuid: Utils.getuuid(), label: 'Tab 1', icon: '', components: [] },
-          { uuid: Utils.getuuid(), label: 'Tab 2', icon: '', components: [] },
-          { uuid: Utils.getuuid(), label: 'Tab 3', icon: '', components: [] }
+          { uuid: Utils.getuuid(), parentId: tabs.uuid, floor: tabs.floor, label: 'Tab 1', icon: '', components: [] },
+          { uuid: Utils.getuuid(), parentId: tabs.uuid, floor: tabs.floor, label: 'Tab 2', icon: '', components: [] },
+          { uuid: Utils.getuuid(), parentId: tabs.uuid, floor: tabs.floor, label: 'Tab 3', icon: '', components: [] }
         ]
       }
       this.setState({
@@ -61,6 +63,28 @@
 
   shouldComponentUpdate (nextProps, nextState) {
     return !is(fromJS(this.state), fromJS(nextState))
+  }
+
+  componentDidMount () {
+    MKEmitter.addListener('tabsChange', this.handleTabsChange)
+  }
+
+  /**
+   * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆
+   */
+  componentWillUnmount () {
+    this.setState = () => {
+      return
+    }
+    MKEmitter.removeListener('tabsChange', this.handleTabsChange)
+  }
+
+  handleTabsChange = (parentId) => {
+    const { tabs } = this.state
+
+    if (parentId === tabs.parentId) {
+      MKEmitter.emit('tabsChange', tabs.uuid)
+    }
   }
 
   updateComponent = (component) => {
@@ -93,10 +117,15 @@
   }
 
   tabAdd = (e) => {
+    const { tabs } = this.state
+
     e.stopPropagation()
+
     this.setState({
       editab: {
         uuid: '',
+        parentId: tabs.uuid,
+        floor: tabs.floor,
         label: '',
         icon: '',
         components: []
@@ -188,7 +217,7 @@
                 <span>{tab.icon ? <Icon type={tab.icon} /> : null}{tab.label}</span>
               </Popover>
             } key={tab.uuid}>
-              <TabComponents menu={menu} parentId={tabs.uuid} config={tab} handleList={this.updateTabComponent} deleteCard={this.deleteCard} />
+              <TabComponents menu={menu} config={tab} handleList={this.updateTabComponent} deleteCard={this.deleteCard} />
             </TabPane>
           ))}
           <TabPane className="tab-add" disabled tab={<Icon onClick={this.tabAdd} type="plus" />} key="add"></TabPane>

--
Gitblit v1.8.0