From d5ce81026882ada34e5d49411be7c90ee96cc102 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 17 一月 2023 18:20:11 +0800
Subject: [PATCH] 2023-01-17

---
 src/tabviews/custom/components/card/prop-card/index.jsx |   42 ++++++++++++++++++++++++++++++++++++++----
 1 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/src/tabviews/custom/components/card/prop-card/index.jsx b/src/tabviews/custom/components/card/prop-card/index.jsx
index 14185b5..2ad4a02 100644
--- a/src/tabviews/custom/components/card/prop-card/index.jsx
+++ b/src/tabviews/custom/components/card/prop-card/index.jsx
@@ -31,6 +31,8 @@
     selected: 'false',
   }
 
+  loaded = false
+
   UNSAFE_componentWillMount () {
     const { data, initdata } = this.props
     let _config = fromJS(this.props.config).toJS()
@@ -60,16 +62,21 @@
           _data = _data[0] || {$$empty: true}
         }
         _sync = false
+        this.loaded = true
       } else if (_sync && initdata) {
         _data = initdata
         if (Array.isArray(_data)) {
           _data = _data[0] || {$$empty: true}
         }
         _sync = false
+        this.loaded = true
       }
     } 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()
+      this.loaded = true
+    } else if (_config.wrap.datatype === 'static') {
+      this.loaded = true
     }
 
     _data.$$BID = BID || ''
@@ -172,6 +179,17 @@
       this.timer = new TimerTask()
       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]
+        _data.$$uuid = _data[config.setting.primaryKey] || ''
+
+        this.setState({data: _data})
+      })
+    }
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -210,6 +228,8 @@
       _data.$$BData = BData || ''
       _data.$$uuid = _data[config.setting.primaryKey] || ''
 
+      this.loaded = true
+
       this.setState({sync: false, data: _data}, () => {
         if (selected !== 'false') {
           this.checkTopLine()
@@ -234,6 +254,8 @@
       _data.$$BID = BID || ''
       _data.$$BData = BData || ''
       _data.$$uuid = _data[config.setting.primaryKey] || ''
+
+      this.loaded = true
 
       this.setState({data: _data}, () => {
         if (selected !== 'false') {
@@ -360,6 +382,7 @@
       this.setState({
         data: {$$BID: BID || '', $$BData: BData, $$empty: true},
       })
+      this.loaded = true
       return
     }
 
@@ -383,6 +406,11 @@
     if (result.status) {
       let _data = {}
 
+      this.loaded = true
+      if (config.$cache) {
+        Api.writeCacheConfig(config.uuid, result.data || '')
+      }
+
       if (!result.data || !result.data[0]) {
         _data.$$empty = true
       } else {
@@ -397,12 +425,18 @@
         data: _data,
         loading: false
       }, () => {
-        if (selected !== 'false') {
-          this.checkTopLine()
+        if (config.wrap.goback === 'true' && _data.$$empty) {
+          this.timer && this.timer.stop()
+
+          MKEmitter.emit('closeTabView', config.$pageId)
         } else {
-          this.transferLine()
+          if (selected !== 'false') {
+            this.checkTopLine()
+          } else {
+            this.transferLine()
+          }
+          this.autoExec()
         }
-        this.autoExec()
       })
 
       if (config.timer && config.clearField) {

--
Gitblit v1.8.0