From 84804b405cb88f659d055b16eb3bd00b813ccb4a Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 10 十二月 2020 10:58:38 +0800
Subject: [PATCH] 2020-12-10

---
 src/tabviews/custom/components/chart/antv-pie/index.jsx |   51 ++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 36 insertions(+), 15 deletions(-)

diff --git a/src/tabviews/custom/components/chart/antv-pie/index.jsx b/src/tabviews/custom/components/chart/antv-pie/index.jsx
index 910d172..14e691d 100644
--- a/src/tabviews/custom/components/chart/antv-pie/index.jsx
+++ b/src/tabviews/custom/components/chart/antv-pie/index.jsx
@@ -12,6 +12,7 @@
 import { modifyTabview } from '@/store/action'
 import { chartColors } from '@/utils/option.js'
 import UtilsDM from '@/utils/utils-datamanage.js'
+import MKEmitter from '@/utils/events.js'
 import './index.scss'
 
 class PieChart extends Component {
@@ -66,16 +67,10 @@
       _config.style = {minHeight: (config.plot.height || 400)}
     }
 
-    let _BID = BID || ''
-    if (config.setting.supModule && config.setting.supModule[0] !== 'empty') {
-      _BID = ''
-    }
-    sessionStorage.setItem(config.uuid, 'bid')
-
     this.setState({
       config: _config,
       data: _data,
-      BID: _BID,
+      BID: BID || '',
       arr_field: _config.columns.map(col => col.field).join(','),
       plot: _config.plot,
       sync: _sync,
@@ -89,14 +84,6 @@
         this.handleData()
       }
     })
-  }
-
-  /**
-   * @description 缁勪欢閿�姣�
-   */
-  componentWillUnmount () {
-    const { config } = this.state
-    sessionStorage.removeItem(config.uuid)
   }
 
   /**
@@ -127,6 +114,31 @@
     return !is(fromJS(this.state), fromJS(nextState))
   }
 
+  componentDidMount () {
+    MKEmitter.addListener('resetSelectLine', this.resetParentParam)
+  }
+
+  /**
+   * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆
+   */
+  componentWillUnmount () {
+    this.setState = () => {
+      return
+    }
+    MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
+  }
+
+  resetParentParam = (MenuID, id) => {
+    const { config } = this.state
+
+    if (!config.setting.supModule || config.setting.supModule !== MenuID) return
+    if (id !== this.state.BID) {
+      this.setState({ BID: id }, () => {
+        this.loadData()
+      })
+    }
+  }
+
   handleData = () => {
     let _element = document.getElementById(this.state.chartId)
     if (_element) {
@@ -139,6 +151,15 @@
     const { mainSearch, menuType } = this.props
     const { config, arr_field, search, BID } = this.state
 
+    if (config.setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇�
+      this.setState({
+        data: []
+      }, () => {
+        this.handleData()
+      })
+      return
+    }
+
     let searches = fromJS(search).toJS()
     if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
       let keys = searches.map(item => item.key)

--
Gitblit v1.8.0