From b59a321435b48626ab268d48df841923f86f1451 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 19 八月 2022 17:51:40 +0800
Subject: [PATCH] 2022-08-19

---
 src/tabviews/custom/components/card/balcony/index.jsx |  125 +++++++++++++++++++++++++++--------------
 1 files changed, 81 insertions(+), 44 deletions(-)

diff --git a/src/tabviews/custom/components/card/balcony/index.jsx b/src/tabviews/custom/components/card/balcony/index.jsx
index 8f0c7e6..b491908 100644
--- a/src/tabviews/custom/components/card/balcony/index.jsx
+++ b/src/tabviews/custom/components/card/balcony/index.jsx
@@ -15,10 +15,8 @@
 
 class BalconyComponent extends Component {
   static propTpyes = {
-    BID: PropTypes.any,
     data: PropTypes.array,
     config: PropTypes.object,
-    menuType: PropTypes.any,
   }
 
   state = {
@@ -35,20 +33,37 @@
   }
 
   UNSAFE_componentWillMount () {
-    const { data, BID } = this.props
+    const { data, initdata } = this.props
     let _config = fromJS(this.props.config).toJS()
-    let _cols = new Map()
 
     let _data = { $$empty: true }
     let _sync = false
+
+    let BID = ''
+    let BData = ''
+
+    if (_config.setting.supModule) {
+      BData = window.GLOB.CacheData.get(_config.setting.supModule)
+    } else {
+      BData = window.GLOB.CacheData.get(_config.$pageId)
+    }
+    if (BData) {
+      BID = BData.$BID || ''
+    }
     
-    if (_config.setting && _config.wrap.datatype !== 'static') {
+    if (_config.wrap.datatype !== 'static') {
       _sync = _config.setting.sync === 'true'
 
       if (_sync && data) {
         _data = data[_config.dataName] || {}
         if (_data && Array.isArray(_data)) {
           _data = _data[0] || {}
+        }
+        _sync = false
+      } else if (_sync && initdata) {
+        _data = initdata
+        if (Array.isArray(_data)) {
+          _data = _data[0] || {$$empty: true}
         }
         _sync = false
       }
@@ -58,19 +73,21 @@
       _data.$$BID = BID || ''
     }
 
-    _config.columns.forEach(item => {
-      _cols.set(item.field, item)
-    })
-
-    if (_config.wrap.position === 'fixed') {
-      _config.style.position = 'fixed'
-      _config.style.zIndex = 2
+    if (_config.wrap.position === 'fixed' || _config.wrap.position === 'absolute') {
+      _config.style.position = _config.wrap.position
+      _config.style.zIndex = 3
       _config.style.left = _config.wrap.left || ''
       _config.style.right = _config.wrap.right || ''
       _config.style.top = _config.wrap.top || ''
       _config.style.bottom = _config.wrap.bottom || ''
       _config.style.transform = _config.wrap.transform || ''
       _config.style.width = _config.wrap.realwidth || ''
+    } else {
+      _config.style.zIndex = 3
+      _config.style.left = _config.wrap.left || ''
+      _config.style.right = _config.wrap.right || ''
+      _config.style.top = _config.wrap.top || ''
+      _config.style.bottom = _config.wrap.bottom || ''
     }
 
     let show = true
@@ -84,11 +101,8 @@
         }
         return item
       })
-    } else if (_config.wrap.linkType === 'sup') {
-      _config.wrap.supModule = _config.wrap.supModule.pop()
-      if (_config.wrap.supControl === 'hidden') {
-        show = false
-      }
+    } else if (_config.wrap.linkType === 'sup' && _config.wrap.supControl === 'hidden') {
+      show = false
     }
 
     this.setState({
@@ -100,8 +114,10 @@
       config: _config,
       arr_field: _config.columns.map(col => col.field).join(','),
     }, () => {
-      if (_config.wrap.datatype !== 'static' && _config.setting && _config.setting.sync !== 'true' && _config.setting.onload === 'true') {
-        this.loadData()
+      if (_config.wrap.datatype !== 'static' && _config.setting && _config.setting.sync !== 'true') {
+        setTimeout(() => {
+          this.loadData()
+        }, _config.setting.delay || 0)
       }
     })
   }
@@ -110,6 +126,7 @@
     MKEmitter.addListener('reloadData', this.reloadData)
     MKEmitter.addListener('syncBalconyData', this.syncBalconyData)
     MKEmitter.addListener('resetSelectLine', this.resetParentParam)
+    MKEmitter.addListener('queryModuleParam', this.queryModuleParam)
     MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult)
     this.handleTimer()
   }
@@ -126,6 +143,7 @@
     MKEmitter.removeListener('reloadData', this.reloadData)
     MKEmitter.removeListener('syncBalconyData', this.syncBalconyData)
     MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
+    MKEmitter.removeListener('queryModuleParam', this.queryModuleParam)
     MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
   }
 
@@ -183,22 +201,30 @@
         })
         return
       } else if (result.run_type) {
-        this.setState({timer})
+        let repeats = config.timerRepeats || 0
+        this.setState({timer, repeats})
         this.timer = setTimeout(() => {
-          this.timerTask()
+          this.timerTask(repeats)
         }, timer)
       }
     })
   }
 
-  timerTask = () => {
-    const { timer } = this.state
+  timerTask = (times) => {
+    const { timer, repeats } = this.state
     if (!timer) return
     
     this.loadData(true)
 
+    if (repeats) {
+      times = times - 1
+      if (times <= 0) {
+        clearTimeout(this.timer)
+        return
+      }
+    }
     this.timer = setTimeout(() => {
-      this.timerTask()
+      this.timerTask(times)
     }, timer)
   }
 
@@ -208,30 +234,25 @@
    * @param {*} position   // 鍒锋柊浣嶇疆
    * @param {*} btn        // 鎵ц鐨勬寜閽�
    */
-  refreshByButtonResult = (menuId, position, btn) => {
+  refreshByButtonResult = (menuId, position, btn, id, lines) => {
     const { config, BID, syncConfig } = this.state
 
     if (config.uuid !== menuId) return
 
-    this.loadData()                                                            // 鏁版嵁鍒锋柊
-
-    let supModule = config.wrap.supModule
-
     if (syncConfig) {
-      supModule = syncConfig.setting.supModule
+      MKEmitter.emit('refreshByButtonResult', syncConfig.uuid, position, btn, id, lines)
 
-      MKEmitter.emit('refreshByButtonResult', syncConfig.uuid, position, btn)
-    }
-
-    if (btn.syncComponentId && btn.syncComponentId !== config.uuid && btn.syncComponentId !== supModule) {
-      MKEmitter.emit('reloadData', btn.syncComponentId)                        // 鍚岀骇鏍囩鍒锋柊
-    }
-
-    if (position === 'mainline' && supModule) {                                // 涓昏〃琛屽埛鏂�
-      MKEmitter.emit('reloadData', supModule, (BID || 'empty'))
-    } else if (position === 'popclose') {                                      // 鏍囩鍏抽棴鍒锋柊
-      supModule && MKEmitter.emit('reloadData', supModule, (BID || 'empty'))
-      btn.$tabId && MKEmitter.emit('refreshPopButton', btn.$tabId)
+      this.loadData()
+    } else {
+      if ((position === 'mainline' || position === 'popclose') && config.wrap.supModule && BID) { // 鍒锋柊婧愮粍浠舵椂锛岄檮甯﹀埛鏂颁笂绾ц涓庡綋鍓嶇粍浠�
+        MKEmitter.emit('reloadData', config.wrap.supModule, BID)
+      } else {
+        this.loadData()
+      }
+      
+      if (position === 'popclose') {                                      // 鏍囩鍏抽棴鍒锋柊
+        btn.$tabId && MKEmitter.emit('refreshPopButton', btn.$tabId)
+      }
     }
   }
 
@@ -269,6 +290,22 @@
     }
   }
 
+  /**
+   * @description 瀵煎嚭Excel鏃讹紝鑾峰彇椤甸潰鎼滅储鎺掑簭绛夊弬鏁�
+   */
+  queryModuleParam = (menuId, callback) => {
+    const { config } = this.state
+
+    if (config.uuid !== menuId) return
+
+    callback({
+      arr_field: '',
+      orderBy: '',
+      search: [],
+      menuName: config.name
+    })
+  }
+
   reloadData = (menuId) => {
     const { config } = this.state
 
@@ -278,7 +315,6 @@
   }
 
   async loadData (hastimer) {
-    const { menuType } = this.props
     const { config, arr_field, BID, BData } = this.state
 
     if (config.wrap.datatype === 'static') {
@@ -302,7 +338,7 @@
     }
 
     let _orderBy = config.setting.order || ''
-    let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, 1, 1, BID, menuType)
+    let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, 1, 1, BID)
 
     let result = await Api.genericInterface(param)
     if (result.status) {
@@ -316,6 +352,7 @@
 
       _data.$$BID = BID || ''
       _data.$$BData = BData
+      _data.$$uuid = _data[config.setting.primaryKey] || ''
 
       this.setState({
         data: _data,

--
Gitblit v1.8.0