From deb2536eaaa559d6c8ec94f81afb94b6c7806b4d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 29 三月 2024 16:15:14 +0800
Subject: [PATCH] 2024-03-29

---
 src/tabviews/custom/components/chart/antv-G6/index.jsx |   92 ++++++++++++++++-----------------------------
 1 files changed, 33 insertions(+), 59 deletions(-)

diff --git a/src/tabviews/custom/components/chart/antv-G6/index.jsx b/src/tabviews/custom/components/chart/antv-G6/index.jsx
index 53d4d4f..c7dd705 100644
--- a/src/tabviews/custom/components/chart/antv-G6/index.jsx
+++ b/src/tabviews/custom/components/chart/antv-G6/index.jsx
@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Modal, notification, Spin, Empty } from 'antd'
+import { Spin, Empty } from 'antd'
 import G6 from '@antv/g6'
 
 import Api from '@/api'
@@ -805,7 +805,6 @@
     BID: '',
     BData: '',
     plot: null,
-    arr_field : '',
     chartId: Utils.getuuid(),
     empty: true
   }
@@ -838,7 +837,7 @@
         this.data = window.GLOB.SyncData.get(_config.dataName) || []
   
         if (_config.$cache) {
-          Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS())
+          Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS(), BID)
         }
   
         _config.setting.sync = 'false'
@@ -860,7 +859,6 @@
       config: _config,
       BID: BID || '',
       BData: BData || '',
-      arr_field: _config.columns.map(col => col.field).join(','),
       plot: _config.plot
     })
     
@@ -1026,21 +1024,21 @@
   }
 
   initExec = () => {
-    const { config } = this.state
+    const { config, BID } = this.state
 
     if (config.$cache) {
       if (config.$time) {
         if (!this.loaded) {
-          Api.getLCacheConfig(config.uuid, config.$time).then(res => {
-            if (!res && config.setting.onload === 'true') {
+          Api.getLCacheConfig(config.uuid, config.$time, BID).then(res => {
+            if (!res.valid && config.setting.onload === 'true') {
               setTimeout(() => {
-                this.loadData()
+                this.loadData('init')
               }, config.setting.delay || 0)
             }
   
-            if (!res || this.loaded) return
+            if (!res.data || this.loaded) return
 
-            this.data = res
+            this.data = res.data
             this.handleData()
           })
         } else {
@@ -1048,17 +1046,17 @@
         }
       } else {
         if (!this.loaded) {
-          Api.getLCacheConfig(config.uuid, 0).then(res => {
-            if (!res || this.loaded) return
+          Api.getLCacheConfig(config.uuid, 0, BID).then(res => {
+            if (!res.data || this.loaded) return
     
-            this.data = res
+            this.data = res.data
             this.handleData()
           })
         }
 
         if (config.setting.onload === 'true') {
           setTimeout(() => {
-            this.loadData()
+            this.loadData('init')
           }, config.setting.delay || 0)
         } else if (this.loaded) {
           this.handleData()
@@ -1074,14 +1072,14 @@
   }
 
   transferSyncData = (syncId) => {
-    const { config } = this.state
+    const { config, BID } = this.state
 
     if (config.$syncId !== syncId) return
 
     let _data = window.GLOB.SyncData.get(config.dataName) || []
 
     if (config.$cache) {
-      Api.writeCacheConfig(config.uuid, fromJS(_data).toJS())
+      Api.writeCacheConfig(config.uuid, fromJS(_data).toJS(), BID)
     }
 
     if (!is(fromJS(this.data), fromJS(_data))) {
@@ -1125,8 +1123,8 @@
     }
   }
 
-  async loadData () {
-    const { config, arr_field, BID } = this.state
+  async loadData (type) {
+    const { config, BID } = this.state
 
     if (config.setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇�
       if (!is(fromJS(this.data), fromJS([]))) {
@@ -1151,12 +1149,12 @@
     })
 
     let _orderBy = config.setting.order || ''
-    let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, '', '', BID)
+    let param = UtilsDM.getQueryDataParams(config.setting, searches, _orderBy, '', '', BID)
 
     let result = await Api.genericInterface(param)
     if (result.status) {
-      if (config.$cache && config.setting.onload !== 'false') {
-        Api.writeCacheConfig(config.uuid, result.data || [])
+      if (config.$cache && type === 'init') {
+        Api.writeCacheConfig(config.uuid, result.data || [], BID)
       }
 
       this.loaded = true
@@ -1169,36 +1167,14 @@
         this.data = result.data || []
         this.handleData()
       }
-      if (result.message) {
-        if (result.ErrCode === 'Y') {
-          Modal.success({
-            title: result.message
-          })
-        } else if (result.ErrCode === 'S') {
-          notification.success({
-            top: 92,
-            message: result.message,
-            duration: 2
-          })
-        }
-      }
+      
+      UtilsDM.querySuccess(result)
     } else {
       this.setState({
         loading: false
       })
       
-      if (!result.message) return
-      if (result.ErrCode === 'N') {
-        Modal.error({
-          title: result.message,
-        })
-      } else if (result.ErrCode !== '-2') {
-        notification.error({
-          top: 92,
-          message: result.message,
-          duration: 10
-        })
-      }
+      UtilsDM.queryFail(result)
     }
   }
 
@@ -1662,34 +1638,32 @@
       if (!data) return
       
       let menuId = plot.menu.slice(-1)[0]
-      let newtab = window.GLOB.mkThdMenus.filter(m => m.MenuID === menuId)[0]
+      let menu = null
 
-      if (!newtab && plot.MenuID) {
-        newtab = {
+      if (window.GLOB.mkThdMenus.has(menuId)) {
+        menu = {...window.GLOB.mkThdMenus.get(menuId)}
+      } else if (plot.MenuID) {
+        menu = {
           MenuID: plot.MenuID,
           MenuName: plot.MenuName,
-          MenuNo: plot.MenuNo,
           type: plot.tabType
         }
-      } else if (!newtab) {
-        return
       }
 
-      newtab = {
-        ...newtab,
-        param: {}
-      }
+      if (!menu) return
+
+      menu.param = {}
 
       if (plot.joint === 'true') {
-        newtab.param.$BID = data.$$uuid || ''
+        menu.param.$BID = data.$$uuid || ''
 
         Object.keys(data).forEach(key => {
           if (/^\$/.test(key)) return
-          newtab.param[key] = data[key]
+          menu.param[key] = data[key]
         })
       }
 
-      MKEmitter.emit('modifyTabs', newtab, true)
+      MKEmitter.emit('modifyTabs', menu, true)
     } else {
       if (data) {
         this.selectedId = data.$$uuid || ''

--
Gitblit v1.8.0