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/popview/index.jsx |   26 ++++++++++++++++++++------
 1 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/src/tabviews/custom/popview/index.jsx b/src/tabviews/custom/popview/index.jsx
index 1f5597a..6862c55 100644
--- a/src/tabviews/custom/popview/index.jsx
+++ b/src/tabviews/custom/popview/index.jsx
@@ -129,7 +129,9 @@
       })
     }
 
-    config.components = this.filterComponent(config.components, roleId, balMap, param, Tab)
+    config.$cache = config.cacheLocal === 'true'
+
+    config.components = this.filterComponent(config.components, roleId, balMap, param, Tab, config.$cache)
     
     // 鑾峰彇涓绘悳绱㈡潯浠�
     let mainSearch = []
@@ -175,9 +177,10 @@
     })
   }
 
-  filterComponent = (components, roleId, balMap, urlparam, Tab) => {
+  filterComponent = (components, roleId, balMap, urlparam, Tab, cache) => {
     return components.filter(item => {
       item.$pageId = Tab.uuid
+      item.$cache = cache
       
       if (item.style && item.style.boxShadow) {
         delete item.style.hShadow
@@ -261,7 +264,7 @@
         item.subtabs = item.subtabs.map(tab => {
           tab.$pageId = Tab.uuid
 
-          tab.components = this.filterComponent(tab.components, roleId, balMap, urlparam, Tab)
+          tab.components = this.filterComponent(tab.components, roleId, balMap, urlparam, Tab, cache)
           return tab
         })
 
@@ -274,7 +277,7 @@
           return false
         }
 
-        item.components = this.filterComponent(item.components, roleId, balMap, urlparam, Tab)
+        item.components = this.filterComponent(item.components, roleId, balMap, urlparam, Tab, cache)
 
         return true
       } else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart'].includes(item.type)) {
@@ -754,7 +757,8 @@
    * @description 涓昏〃鏁版嵁鍔犺浇
    */ 
   loadmaindata = (params) => {
-    let param = getStructuredParams(params, this.state.config, this.state.BID || '')
+    const { config } = this.state
+    let param = getStructuredParams(params, config, this.state.BID || '')
 
     this.setState({loading: true})
 
@@ -764,6 +768,16 @@
         delete result.message
         delete result.ErrMesg
         delete result.ErrCode
+
+        if (config.$cache) {
+          params.forEach((item) => {
+            let _data = result[item.name] || ''
+            if (_data && !Array.isArray(_data)) {
+              _data = [_data]
+            }
+            Api.writeCacheConfig(item.uuid, _data)
+          })
+        }
 
         this.setState({
           data: result,
@@ -1011,7 +1025,7 @@
 
     return (
       <div className={'pop-page-wrap ' + (loading ? 'loading' : '')} style={config ? config.style : null}>
-        {loading ? <Spin className="view-spin" size="large" /> : null}
+        {loading && !config.$cache ? <Spin className="view-spin" size="large" /> : null}
         <Row className="component-wrap">{this.getComponents()}</Row>
         {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
       </div>

--
Gitblit v1.8.0