From 97e18fa9b628357fa43013cfefc96eec078de25e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 16 一月 2023 15:58:12 +0800
Subject: [PATCH] 2023-01-16

---
 src/tabviews/custom/components/card/table-card/index.jsx |   66 +++++++++++++++++++++++++-------
 1 files changed, 51 insertions(+), 15 deletions(-)

diff --git a/src/tabviews/custom/components/card/table-card/index.jsx b/src/tabviews/custom/components/card/table-card/index.jsx
index f2616d8..5629e18 100644
--- a/src/tabviews/custom/components/card/table-card/index.jsx
+++ b/src/tabviews/custom/components/card/table-card/index.jsx
@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Spin, notification, Row, Col, Empty, Pagination } from 'antd'
+import { Spin, notification, Row, Col, Empty, Pagination, Modal } from 'antd'
 import { DownOutlined } from '@ant-design/icons'
 
 import Api from '@/api'
@@ -33,6 +33,8 @@
     data: null,                // 鏁版嵁
     BData: ''
   }
+
+  loaded = false
 
   /**
    * @description 鍒濆鍖栧鐞�
@@ -104,6 +106,8 @@
 
     _config.wrap.pagestyle = _config.wrap.pagestyle || 'page'
 
+    this.loaded = _data !== null
+
     this.setState({
       sync: _sync,
       BID: BID || '',
@@ -137,6 +141,21 @@
         }, () => {
           this.loadData('timer')
         })
+      })
+    }
+
+    if (config.$cache && !this.loaded) {
+      Api.getLCacheConfig(config.uuid).then(res => {
+        if (!res || this.loaded) return
+
+        let _data = res.map((item, index) => {
+          item.key = index
+          item.$$uuid = item[config.setting.primaryKey] || ''
+          item.$Index = index + 1 + ''
+          return item
+        })
+
+        this.setState({data: _data})
       })
     }
   }
@@ -178,8 +197,10 @@
         return item
       })
 
+      this.loaded = true
+
       this.setState({sync: false, data: _data})
-    } else if (config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
+    } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
       this.setState({}, () => {
         this.loadData()
       })
@@ -263,6 +284,8 @@
         data: [],
         total: 0
       })
+
+      this.loaded = true
       return
     }
 
@@ -295,6 +318,11 @@
       let start = 1
       if (config.setting.laypage) {
         start = config.setting.pageSize * (pageIndex - 1) + 1
+      }
+
+      this.loaded = true
+      if (config.$cache && pageIndex === 1) {
+        Api.writeCacheConfig(config.uuid, result.data || '')
       }
 
       let data = []
@@ -330,11 +358,18 @@
         loading: false
       })
       this.timer && this.timer.stop()
-      notification.error({
-        top: 92,
-        message: result.message,
-        duration: 10
-      })
+      
+      if (result.ErrCode === 'N') {
+        Modal.error({
+          title: result.message,
+        })
+      } else {
+        notification.error({
+          top: 92,
+          message: result.message,
+          duration: 10
+        })
+      }
     }
   }
 
@@ -348,12 +383,12 @@
 
   openView = (card, data) => {
     if (card.setting.click === 'menu' && card.setting.menu) {
-      let menuId = card.setting.MenuID || card.setting.menu.slice(-1)[0]
+      let menuId = card.setting.menu.slice(-1)[0]
       let menu = window.GLOB.mkThdMenus.filter(m => m.MenuID === menuId)[0]
 
-      if (!menu && card.setting.MenuName && card.setting.tabType) {
+      if (!menu && card.setting.MenuName && card.setting.MenuID) {
         menu = {
-          MenuID: menuId,
+          MenuID: card.setting.MenuID,
           MenuName: card.setting.MenuName,
           MenuNo: card.setting.MenuNo || '',
           type: card.setting.tabType
@@ -376,13 +411,14 @@
 
       if (card.setting.joint === 'true') {
         newtab.param.$BID = data.$$uuid || ''
+
+        Object.keys(data).forEach(key => {
+          if (/^\$/.test(key)) return
+          newtab.param[key] = data[key]
+        })
       }
 
-      if (['linkage_navigation', 'linkage', 'menu_board'].includes(window.GLOB.navBar)) {
-        MKEmitter.emit('modifyTabs', newtab, 'replace')
-      } else {
-        MKEmitter.emit('modifyTabs', newtab, 'plus', true)
-      }
+      MKEmitter.emit('modifyTabs', newtab, true)
     } else if (card.setting.click === 'link') {
       let src = card.setting.linkurl
 

--
Gitblit v1.8.0