From da7068bd48791cdee966c786ce0dfd46f6e03df9 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 08 一月 2021 19:02:24 +0800
Subject: [PATCH] 2021-01-08

---
 src/tabviews/custom/components/card/prop-card/index.jsx |   51 ++++++++++++++++++++++++++++++++-------------------
 1 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/src/tabviews/custom/components/card/prop-card/index.jsx b/src/tabviews/custom/components/card/prop-card/index.jsx
index a313c2e..f621976 100644
--- a/src/tabviews/custom/components/card/prop-card/index.jsx
+++ b/src/tabviews/custom/components/card/prop-card/index.jsx
@@ -106,8 +106,9 @@
   }
 
   componentDidMount () {
-    MKEmitter.addListener('syncRefreshComponentId', this.reload)
+    MKEmitter.addListener('reloadData', this.reloadData)
     MKEmitter.addListener('resetSelectLine', this.resetParentParam)
+    MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -118,8 +119,9 @@
     this.setState = () => {
       return
     }
-    MKEmitter.removeListener('syncRefreshComponentId', this.reload)
+    MKEmitter.removeListener('reloadData', this.reloadData)
     MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
+    MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
   }
 
   /**
@@ -151,6 +153,31 @@
     }
   }
 
+  /**
+   * @description 鎸夐挳鎵ц瀹屾垚鍚庨〉闈㈠埛鏂�
+   * @param {*} menuId     // 鑿滃崟Id
+   * @param {*} position   // 鍒锋柊浣嶇疆
+   * @param {*} btn        // 鎵ц鐨勬寜閽�
+   */
+  refreshByButtonResult = (menuId, position, btn) => {
+    const { config, BID } = this.state
+
+    if (config.uuid !== menuId) return
+
+    this.loadData()                                                            // 鏁版嵁鍒锋柊
+
+    if (btn.syncComponentId && btn.syncComponentId !== config.uuid && btn.syncComponentId !== config.setting.supModule) {
+      MKEmitter.emit('reloadData', btn.syncComponentId)                        // 鍚岀骇鏍囩鍒锋柊
+    }
+
+    if (position === 'mainline' && config.setting.supModule) {                 // 涓昏〃琛屽埛鏂�
+      MKEmitter.emit('reloadData', config.setting.supModule, (BID || 'empty'))
+    } else if (position === 'popclose') {                                      // 鏍囩鍏抽棴鍒锋柊
+      config.setting.supModule && MKEmitter.emit('reloadData', config.setting.supModule, (BID || 'empty'))
+      btn.$tabId && MKEmitter.emit('refreshPopButton', btn.$tabId)
+    }
+  }
+
   resetParentParam = (MenuID, id) => {
     const { config } = this.state
 
@@ -162,10 +189,10 @@
     }
   }
 
-  reload = (syncId) => {
+  reloadData = (menuId) => {
     const { config } = this.state
 
-    if (syncId && syncId !== config.uuid) return
+    if (menuId !== config.uuid) return
 
     this.loadData()
   }
@@ -227,20 +254,6 @@
     }
   }
 
-  updateStatus = (type, position, btn) => {
-    const { config } = this.state
-
-    if (type === 'refresh' && position === 'grid') {
-      this.loadData()
-      if (btn && btn.syncComponent && btn.syncComponent[0]) {
-        let syncId = btn.syncComponent.slice(-1)[0]
-        if (config.uuid !== syncId) {
-          MKEmitter.emit('syncRefreshComponentId', syncId)
-        }
-      }
-    }
-  }
-
   changeCard = (index, item) => {
     const { config, data, activeKey } = this.state
 
@@ -268,7 +281,7 @@
         <div className={`card-row-list ${config.wrap.cardType || ''} ${config.wrap.scale || ''}`}>
           {config.subcards.map((item, index) => (
             <Col className={activeKey === index ? 'active' : ''} key={index} span={item.setting.width || 6} offset={item.offset || 0} onClick={() => {this.changeCard(index, item)}}>
-              <CardItem card={item} cards={config} data={data} updateStatus={this.updateStatus}/>
+              <CardItem card={item} cards={config} data={data}/>
             </Col>
           ))}
         </div>

--
Gitblit v1.8.0