From 2a3cc4e6cecfc6dab8b60adf93f7fde898ddc939 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 25 七月 2023 16:36:23 +0800
Subject: [PATCH] 2023-07-25

---
 src/tabviews/custom/components/card/prop-card/index.jsx |  157 +++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 111 insertions(+), 46 deletions(-)

diff --git a/src/tabviews/custom/components/card/prop-card/index.jsx b/src/tabviews/custom/components/card/prop-card/index.jsx
index fbec582..3ea4c17 100644
--- a/src/tabviews/custom/components/card/prop-card/index.jsx
+++ b/src/tabviews/custom/components/card/prop-card/index.jsx
@@ -36,8 +36,6 @@
 
     let _config = fromJS(config).toJS()
     let _data = { $$empty: true }
-    let _sync = false
-
     let BID = ''
     let BData = ''
 
@@ -51,6 +49,8 @@
     }
     
     if (_config.wrap.datatype === 'dynamic') {
+      _config.setting.onload = _config.setting.sync === 'true' ? 'false' : 'true'
+
       if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) {
         _data = window.GLOB.SyncData.get(_config.dataName) || []
 
@@ -119,40 +119,7 @@
       BID: BID || '',
       BData: BData || '',
       config: _config,
-      arr_field: _config.columns.map(col => col.field).join(','),
-    }, () => {
-      if (_config.wrap.datatype === 'dynamic' && config.setting.sync !== 'true' && _config.setting.onload === 'true') {
-        setTimeout(() => {
-          this.loadData()
-        }, _config.setting.delay || 0)
-      } else if (_config.wrap.datatype === 'public') {
-        if (_data.$$loaded && selected !== 'false') {
-          setTimeout(() => {
-            this.checkTopLine()
-          }, 200)
-        }
-      } else if (!_sync && selected !== 'false') {
-        setTimeout(() => {
-          this.checkTopLine()
-        }, 200)
-      }
-
-      if (_config.wrap.datatype === 'dynamic' && this.loaded) {
-        if (_config.wrap.goback === 'true' && _data.$$empty) {
-          this.timer && this.timer.stop()
-
-          MKEmitter.emit('closeTabView', _config.$pageId)
-        } else {
-          this.autoExec()
-        }
-      } else if (_config.wrap.datatype === 'static') {
-        this.autoExec()
-      }
-      if (_data.$$uuid) {
-        setTimeout(() => {
-          this.transferLine()
-        }, 200)
-      }
+      arr_field: _config.columns.map(col => col.field).join(',')
     })
   }
 
@@ -182,16 +149,7 @@
       this.timer.init(config.uuid, config.timer, config.timerRepeats, () => {this.loadData(true)})
     }
 
-    if (config.$cache && !this.loaded) {
-      Api.getLCacheConfig(config.uuid).then(res => {
-        if (!res || this.loaded) return
-
-        let _data = res[0] || {$$empty: true}
-        _data.$$uuid = _data[config.setting.primaryKey] || ''
-
-        this.setState({data: _data})
-      })
-    }
+    this.initExec()
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -214,6 +172,113 @@
     this.timer && this.timer.stop()
   }
 
+  initExec = () => {
+    const { config, selected, data } = this.state
+
+    if (config.wrap.datatype === 'dynamic') {
+      if (config.$cache) {
+        if (config.$time) {
+          if (!this.loaded) {
+            Api.getLCacheConfig(config.uuid, config.$time).then(res => {
+              if (!res && config.setting.onload === 'true') {
+                setTimeout(() => {
+                  this.loadData()
+                }, config.setting.delay || 0)
+              }
+    
+              if (!res || this.loaded) return
+  
+              let _data = res[0] || {$$empty: true}
+              _data.$$uuid = _data[config.setting.primaryKey] || ''
+      
+              this.setState({data: _data})
+            })
+          }
+        } else {
+          if (!this.loaded) {
+            Api.getLCacheConfig(config.uuid, 0).then(res => {
+              if (!res || this.loaded) return
+      
+              let _data = res[0] || {$$empty: true}
+              _data.$$uuid = _data[config.setting.primaryKey] || ''
+      
+              this.setState({data: _data})
+            })
+          }
+  
+          if (config.setting.onload === 'true') {
+            setTimeout(() => {
+              this.loadData()
+            }, config.setting.delay || 0)
+          } else if (this.loaded) {
+            if (config.wrap.goback === 'true' && data.$$empty) {
+              this.timer && this.timer.stop()
+    
+              MKEmitter.emit('closeTabView', config.$pageId)
+            } else {
+              if (selected !== 'false') {
+                this.checkTopLine()
+              } else {
+                this.transferLine()
+              }
+              this.autoExec()
+            }
+          }
+        }
+      } else if (config.setting.onload === 'true') {
+        setTimeout(() => {
+          this.loadData()
+        }, config.setting.delay || 0)
+      } else if (this.loaded) {
+        if (config.wrap.goback === 'true' && data.$$empty) {
+          this.timer && this.timer.stop()
+
+          MKEmitter.emit('closeTabView', config.$pageId)
+        } else {
+          if (selected !== 'false') {
+            this.checkTopLine()
+          } else {
+            this.transferLine()
+          }
+          this.autoExec()
+        }
+      }
+    } else if (config.wrap.datatype === 'public') {
+      if (this.loaded) {
+        if (config.wrap.goback === 'true' && data.$$empty) {
+          this.timer && this.timer.stop()
+  
+          MKEmitter.emit('closeTabView', config.$pageId)
+        } else {
+          if (selected !== 'false') {
+            this.checkTopLine()
+          } else if (data.$$uuid) {
+            this.transferLine()
+          }
+          this.autoExec()
+        }
+      }
+    } else {
+      if (selected !== 'false') {
+        setTimeout(() => {
+          this.checkTopLine()
+        }, 200)
+      }
+
+      if (config.$cache && config.$time && config.wrap.autoExec) {
+        Api.getLCacheConfig(config.uuid, config.$time).then(res => {
+          if (!res) {
+            this.autoExec()
+          } else {
+            Api.writeCacheConfig(config.uuid, [])
+          }
+        })
+      } else {
+        this.autoExec()
+      }
+    }
+  }
+
   transferSyncData = (syncId) => {
     const { config } = this.state
 

--
Gitblit v1.8.0