From 78eed586f6a0d15162c89878c53a301e7b142a8a Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 10 十月 2022 00:07:06 +0800
Subject: [PATCH] Merge branch 'master' into positec

---
 src/tabviews/custom/components/card/balcony/index.jsx |   48 ++++++++++++++++++++++++++++++++++++------------
 1 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/src/tabviews/custom/components/card/balcony/index.jsx b/src/tabviews/custom/components/card/balcony/index.jsx
index c00e0fa..e9aa506 100644
--- a/src/tabviews/custom/components/card/balcony/index.jsx
+++ b/src/tabviews/custom/components/card/balcony/index.jsx
@@ -50,13 +50,13 @@
       BID = BData.$BID || ''
     }
     
-    if (_config.wrap.datatype !== 'static') {
+    if (_config.wrap.datatype === 'dynamic') {
       _sync = _config.setting.sync === 'true'
 
       if (_sync && data) {
-        _data = data[_config.dataName] || {}
+        _data = data[_config.dataName] || {$$empty: true}
         if (_data && Array.isArray(_data)) {
-          _data = _data[0] || {}
+          _data = _data[0] || {$$empty: true}
         }
         _sync = false
       } else if (_sync && initdata) {
@@ -66,10 +66,15 @@
         }
         _sync = false
       }
+    } else if (_config.wrap.datatype === 'public' && window.GLOB.CacheData.get(_config.wrap.publicId)) {
+      _data = window.GLOB.CacheData.get(_config.wrap.publicId)
+      _data = fromJS(_data).toJS()
     }
 
-    if (_data) {
-      _data.$$BID = BID || ''
+    _data.$$BID = BID || ''
+    _data.$$BData = BData || ''
+    if (_config.setting.primaryKey) {
+      _data.$$uuid = _data[_config.setting.primaryKey] || ''
     }
 
     if (_config.wrap.position === 'fixed' || _config.wrap.position === 'absolute') {
@@ -113,7 +118,7 @@
       config: _config,
       arr_field: _config.columns.map(col => col.field).join(','),
     }, () => {
-      if (_config.wrap.datatype !== 'static' && _config.setting && _config.setting.sync !== 'true') {
+      if (_config.wrap.datatype === 'dynamic' && _config.setting && _config.setting.sync !== 'true') {
         setTimeout(() => {
           this.loadData()
         }, _config.setting.delay || 0)
@@ -129,8 +134,12 @@
     MKEmitter.addListener('resetSelectLine', this.resetParentParam)
     MKEmitter.addListener('queryModuleParam', this.queryModuleParam)
     MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult)
+
+    if (config.wrap.datatype === 'public') {
+      MKEmitter.addListener('mkPublicData', this.mkPublicData)
+    }
     
-    if (config.timer) {
+    if (config.timer && config.wrap.datatype === 'dynamic') {
       this.timer = new TimerTask()
       this.timer.init(config.uuid, config.timer, config.timerRepeats, () => {this.loadData(true)})
     }
@@ -145,6 +154,7 @@
       return
     }
     MKEmitter.removeListener('reloadData', this.reloadData)
+    MKEmitter.removeListener('mkPublicData', this.mkPublicData)
     MKEmitter.removeListener('syncBalconyData', this.syncBalconyData)
     MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
     MKEmitter.removeListener('queryModuleParam', this.queryModuleParam)
@@ -157,25 +167,39 @@
    * @description 鍥捐〃鏁版嵁鏇存柊锛屽埛鏂板唴瀹�
    */
   UNSAFE_componentWillReceiveProps (nextProps) {
-    const { sync, config, BID } = this.state
+    const { sync, config, BID, BData } = this.state
 
     if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) {
       let _data = {$$empty: true}
       if (nextProps.data && nextProps.data[config.dataName]) {
         _data = nextProps.data[config.dataName]
         if (_data && Array.isArray(_data)) {
-          _data = _data[0]
+          _data = _data[0] || {$$empty: true}
         }
       }
 
-      if (_data) {
-        _data.$$BID = BID || ''
-      }
+      _data.$$BID = BID || ''
+      _data.$$BData = BData || ''
+      _data.$$uuid = _data[config.setting.primaryKey] || ''
 
       this.setState({sync: false, data: _data})
     }
   }
 
+  mkPublicData = (publicId, data) => {
+    const { config, BID, BData } = this.state
+
+    if (config.wrap.datatype === 'public' && config.wrap.publicId === publicId) {
+      let _data = fromJS(data).toJS()
+
+      _data.$$BID = BID || ''
+      _data.$$BData = BData || ''
+      _data.$$uuid = _data[config.setting.primaryKey] || ''
+
+      this.setState({data: _data})
+    }
+  }
+
   /**
    * @description 鎸夐挳鎵ц瀹屾垚鍚庨〉闈㈠埛鏂�
    * @param {*} menuId     // 鑿滃崟Id

--
Gitblit v1.8.0