From ff4295358a99b2d35265a5fed445e4407cf6ed9a Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 18 五月 2020 14:48:10 +0800
Subject: [PATCH] 2020-05-18

---
 src/templates/sharecomponent/tabscomponent/index.jsx |   37 +++++++++++++++++++++++++++----------
 1 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/src/templates/sharecomponent/tabscomponent/index.jsx b/src/templates/sharecomponent/tabscomponent/index.jsx
index 7238978..5749ffe 100644
--- a/src/templates/sharecomponent/tabscomponent/index.jsx
+++ b/src/templates/sharecomponent/tabscomponent/index.jsx
@@ -1,6 +1,6 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
-import { fromJS } from 'immutable'
+import { is, fromJS } from 'immutable'
 import { Icon, Tooltip, Modal, notification } from 'antd'
 
 import Utils from '@/utils/utils.js'
@@ -43,6 +43,17 @@
   }
 
   /**
+   * @description 鏍囩缁勫彉鍖栨椂锛屾洿鏂版爣绛�
+   */
+  UNSAFE_componentWillReceiveProps (nextProps) {
+    const { tabgroups } = this.state
+
+    if (!is(fromJS(nextProps.config.tabgroups), fromJS(this.props.config.tabgroups)) && !is(fromJS(nextProps.config.tabgroups), fromJS(tabgroups))) {
+      this.setState({tabgroups: fromJS(nextProps.config.tabgroups).toJS()})
+    }
+  }
+
+  /**
    * @description 鍏冪礌娣诲姞鎴栨嫋鍔ㄦ椂椤哄簭鍙樺寲
    */
   handleList = (list, card, groupId) => {
@@ -62,8 +73,9 @@
       this.setState({tabgroups: _tabgroups})
       this.handleTab(card, _group)
     } else {
-      this.setState({tabgroups: _tabgroups})
-      this.props.updatetabs({...config, tabgroups: _tabgroups})
+      this.setState({tabgroups: _tabgroups}, () => {
+        this.props.updatetabs({...config, tabgroups: _tabgroups})
+      })
     }
   }
 
@@ -169,8 +181,9 @@
         group: null,
         tabgroups: tabgroups, 
         visible: false
+      }, () => {
+        this.props.updatetabs({...config, tabgroups: tabgroups})
       })
-      this.props.updatetabs({...config, tabgroups: tabgroups})
     })
   }
   
@@ -196,8 +209,9 @@
 
         _this.setState({
           tabgroups: tabgroups
+        }, () => {
+          _this.props.updatetabs({...config, tabgroups: tabgroups}, [card])
         })
-        _this.props.updatetabs({...config, tabgroups: tabgroups}, [card])
       },
       onCancel() {}
     })
@@ -229,8 +243,9 @@
 
         _this.setState({
           tabgroups: _tabgroups
+        }, () => {
+          _this.props.updatetabs({...config, tabgroups: _tabgroups})
         })
-        _this.props.updatetabs({...config, tabgroups: _tabgroups})
       },
       onCancel() {}
     })
@@ -249,13 +264,13 @@
       okText: this.state.dict['model.confirm'],
       cancelText: this.state.dict['header.cancel'],
       onOk() {
-
         _tabgroups = _tabgroups.filter(_group => _group.uuid !== group.uuid)
 
         _this.setState({
           tabgroups: _tabgroups
+        }, () => {
+          _this.props.updatetabs({...config, tabgroups: _tabgroups}, group.sublist)
         })
-        _this.props.updatetabs({...config, tabgroups: _tabgroups}, group.sublist)
       },
       onCancel() {}
     })
@@ -276,8 +291,9 @@
 
     this.setState({
       tabgroups: _tabgroups
+    }, () => {
+      this.props.updatetabs({...config, tabgroups: _tabgroups})
     })
-    this.props.updatetabs({...config, tabgroups: _tabgroups})
 
     notification.success({
       top: 92,
@@ -308,8 +324,9 @@
         group: null,
         tabgroups: _tabgroups,
         visible: false
+      }, () => {
+        this.props.updatetabs({...config, tabgroups: _tabgroups})
       })
-      this.props.updatetabs({...config, tabgroups: _tabgroups})
     } else {
       this.setState({
         card: null,

--
Gitblit v1.8.0