From 004176924ce35c96600f5c18e85478944de8bec6 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 14 一月 2023 16:46:50 +0800
Subject: [PATCH] 2023-01-14

---
 src/tabviews/custom/components/card/data-card/index.jsx |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/src/tabviews/custom/components/card/data-card/index.jsx b/src/tabviews/custom/components/card/data-card/index.jsx
index 121091a..59573bf 100644
--- a/src/tabviews/custom/components/card/data-card/index.jsx
+++ b/src/tabviews/custom/components/card/data-card/index.jsx
@@ -196,7 +196,7 @@
   }
 
   componentDidMount () {
-    const { config } = this.state
+    const { config, sync } = this.state
 
     MKEmitter.addListener('reloadData', this.reloadData)
     MKEmitter.addListener('mkCheckAll', this.mkCheckAll)
@@ -212,6 +212,28 @@
         }, () => {
           this.loadData('', 'timer')
         })
+      })
+    }
+
+    if (config.$cache && (config.setting.sync !== 'true' || sync)) {
+      Api.getLCacheConfig(config.uuid).then(res => {
+        if (!res) return
+
+        let _data = res.map((item, index) => {
+          item.key = index
+          item.$$uuid = item[config.setting.primaryKey] || ''
+          item.$Index = index + 1 + ''
+
+          if (config.wrap.controlField) {
+            if (config.wrap.controlVal.includes(item[config.wrap.controlField])) {
+              item.$disabled = true
+            }
+          }
+
+          return item
+        })
+
+        this.setState({data: _data})
       })
     }
   }
@@ -583,6 +605,10 @@
         start = config.setting.pageSize * (pageIndex - 1) + 1
       }
 
+      if (config.$cache && pageIndex === 1) {
+        Api.writeCacheConfig(config.uuid, result.data || '')
+      }
+
       if (selected !== 'false' || (id && config.wrap.selected !== 'false')) {
         setTimeout(() => {
           this.checkTopLine(id)

--
Gitblit v1.8.0