From 76a4300654a18d228838c3f27455dc8e7a8cd616 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 15 一月 2021 17:04:42 +0800
Subject: [PATCH] Merge branch 'master' into bms

---
 src/tabviews/custom/components/card/table-card/index.jsx |   86 +++++++++++++++++++++++++++++++------------
 1 files changed, 62 insertions(+), 24 deletions(-)

diff --git a/src/tabviews/custom/components/card/table-card/index.jsx b/src/tabviews/custom/components/card/table-card/index.jsx
index 4fb7168..a557611 100644
--- a/src/tabviews/custom/components/card/table-card/index.jsx
+++ b/src/tabviews/custom/components/card/table-card/index.jsx
@@ -102,8 +102,10 @@
   }
 
   componentDidMount () {
-    MKEmitter.addListener('syncRefreshComponentId', this.reload)
+    MKEmitter.addListener('reloadData', this.reloadData)
     MKEmitter.addListener('resetSelectLine', this.resetParentParam)
+    MKEmitter.addListener('getexceloutparam', this.getexceloutparam)
+    MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult)
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -114,8 +116,10 @@
     this.setState = () => {
       return
     }
-    MKEmitter.removeListener('syncRefreshComponentId', this.reload)
+    MKEmitter.removeListener('reloadData', this.reloadData)
     MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
+    MKEmitter.removeListener('getexceloutparam', this.getexceloutparam)
+    MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
   }
 
   /**
@@ -147,6 +151,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(btn)                                                         // 鏁版嵁鍒锋柊
+
+    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
 
@@ -158,15 +187,38 @@
     }
   }
 
-  reload = (syncId) => {
+  reloadData = (menuId) => {
     const { config } = this.state
 
-    if (syncId && syncId !== config.uuid) return
+    if (config.uuid !== menuId) return
 
-    this.setState({
-      pageIndex: 1
-    }, () => {
-      this.loadData()
+    this.loadData()
+  }
+
+   /**
+   * @description 瀵煎嚭Excel鏃讹紝鑾峰彇椤甸潰鎼滅储鎺掑簭绛夊弬鏁�
+   */
+  getexceloutparam = (menuId, btnId) => {
+    const { mainSearch } = this.props
+    const { arr_field, config, search } = this.state
+
+    if (config.uuid !== menuId) return
+
+    let searches = search ? fromJS(search).toJS() : []
+    if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
+      let keys = searches.map(item => item.key.toLowerCase())
+      mainSearch.forEach(item => {
+        if (!keys.includes(item.key.toLowerCase())) {
+          searches.push(item)
+        }
+      })
+    }
+
+    MKEmitter.emit('execExcelout', config.uuid, btnId, {
+      arr_field: arr_field,
+      orderBy: config.setting.order || '',
+      search: searches,
+      menuName: config.name
     })
   }
 
@@ -183,7 +235,7 @@
       return
     }
 
-    let searches = fromJS(search).toJS()
+    let searches = search ? fromJS(search).toJS() : []
     if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
       let keys = searches.map(item => item.key)
       mainSearch.forEach(item => {
@@ -230,20 +282,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)
-        }
-      }
-    }
-  }
-
   changePageIndex = (page) => {
     this.setState({
       pageIndex: page
@@ -283,7 +321,7 @@
       line.push(
         <Col key={index} span={24}>
           <div className="card-item-box" style={item.style}>
-            <CardCellComponent seq={seq} data={data} cards={config} cardCell={item} elements={item.elements} updateStatus={this.updateStatus}/>
+            <CardCellComponent seq={seq} data={data} cards={config} cardCell={item} elements={item.elements}/>
           </div>
         </Col>
       )

--
Gitblit v1.8.0