From c34bcb0a3054bdab29fbaff17e587c19d7b5de28 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 16 九月 2020 23:39:28 +0800
Subject: [PATCH] 2020-09-16

---
 src/menu/components/chart/antv-bar/index.jsx |   35 ++++++++++++++++++++++++++++-------
 1 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/src/menu/components/chart/antv-bar/index.jsx b/src/menu/components/chart/antv-bar/index.jsx
index 0b0c8f3..6c216a0 100644
--- a/src/menu/components/chart/antv-bar/index.jsx
+++ b/src/menu/components/chart/antv-bar/index.jsx
@@ -4,6 +4,7 @@
 import { Chart } from '@antv/g2'
 import DataSet from '@antv/data-set'
 
+import MKEmitter from '@/utils/events.js'
 import asyncComponent from '@/utils/asyncComponent'
 
 import Utils from '@/utils/utils.js'
@@ -25,7 +26,8 @@
 
   state = {
     dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
-    card: null
+    card: null,
+    eventListener: null
   }
 
   UNSAFE_componentWillMount () {
@@ -66,6 +68,7 @@
         uuid: card.uuid,
         type: card.type,
         floor: card.floor,
+        parentId: card.parentId || '',
         format: 'array',   // 缁勪欢灞炴�� - 鏁版嵁鏍煎紡
         pageable: false,   // 缁勪欢灞炴�� - 鏄惁鍙垎椤�
         switchable: false, // 缁勪欢灞炴�� - 鏁版嵁鏄惁鍙垏鎹�
@@ -91,11 +94,33 @@
 
   componentDidMount () {
     this.viewrender()
+    MKEmitter.addListener('tabsChange', this.handleTabsChange)
   }
 
-  UNSAFE_componentWillReceiveProps (nextProps) {
-    if (!is(fromJS(this.props.plot), fromJS(nextProps.plot))) {
+  shouldComponentUpdate (nextProps, nextState) {
+    return !is(fromJS(this.state), fromJS(nextState))
+  }
 
+  /**
+   * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆
+   */
+  componentWillUnmount () {
+    this.setState = () => {
+      return
+    }
+    MKEmitter.removeListener('tabsChange', this.handleTabsChange)
+  }
+
+  handleTabsChange = (parentId) => {
+    const { card } = this.state
+
+    if (parentId === card.parentId) {
+      let _element = document.getElementById(card.uuid)
+      if (_element) {
+        _element.innerHTML = ''
+      }
+
+      setTimeout(this.viewrender, 100)
     }
   }
 
@@ -495,10 +520,6 @@
     } else {
       this.customrender(data, transfield)
     }
-  }
-
-  shouldComponentUpdate (nextProps, nextState) {
-    return !is(fromJS(this.state), fromJS(nextState))
   }
 
   updateComponent = (component) => {

--
Gitblit v1.8.0