From 8a6ce370f1aa1c061b76fa3e9d2d4d1df53ca4c5 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 21 五月 2024 16:38:09 +0800
Subject: [PATCH] Merge branch 'master' into positec

---
 src/tabviews/custom/components/table/base-table/index.jsx |  120 ++++++++++++++++++++++++++++++++----------------------------
 1 files changed, 64 insertions(+), 56 deletions(-)

diff --git a/src/tabviews/custom/components/table/base-table/index.jsx b/src/tabviews/custom/components/table/base-table/index.jsx
index 91cbbff..bc2b635 100644
--- a/src/tabviews/custom/components/table/base-table/index.jsx
+++ b/src/tabviews/custom/components/table/base-table/index.jsx
@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { notification, Modal } from 'antd'
+import { notification } from 'antd'
 
 import Api from '@/api'
 import UtilsDM from '@/utils/utils-datamanage.js'
@@ -104,6 +104,7 @@
       this.setState({
         data: [],
         selectedData: [],
+        loading: false,
         total: 0
       })
       
@@ -112,6 +113,8 @@
       if (setting.$hasSyncModule) {
         MKEmitter.emit('syncBalconyData', config.uuid, [], false)
       }
+
+      this.requestId = ''
       return
     }
 
@@ -137,8 +140,13 @@
     let _orderBy = orderBy || setting.order
     let param = UtilsDM.getQueryDataParams(setting, searches, _orderBy, pageIndex, pageSize, BID)
 
-    let result = await Api.genericInterface(param)
+    this.requestId = config.uuid + new Date().getTime()
+
+    let result = await Api.genericInterface(param, setting.js_script, '', this.requestId)
+
     if (result.status) {
+      if (result.$requestId && this.requestId !== result.$requestId) return
+
       if (repage === 'false' && result.data && result.data.length === 0 && result.total > 0 && pageIndex > 1) {
         let _pageIndex = Math.ceil(result.total / pageSize)
 
@@ -221,19 +229,7 @@
         }
       }
 
-      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
@@ -243,25 +239,14 @@
         MKEmitter.emit('autoMaticError', config.MenuID)
       }
       
-      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)
     }
   }
 
   /**
    * @description 鑾峰彇鍗曡鏁版嵁
    */ 
-  async loadmainLinedata (id) {
+  async loadLinedata (id, position) {
     const { setting, config, search, orderBy, BID, pageIndex, pageSize, BData } = this.state
 
     if (config.forbidLine) {
@@ -289,6 +274,11 @@
 
     let result = await Api.genericInterface(param)
     if (result.status) {
+      if (position === 'line_grid' && (!result.data || !result.data[0])) {
+        this.loadmaindata(true, 'false')
+        return
+      }
+
       let data = fromJS(this.state.data).toJS()
       let selectedData = fromJS(this.state.selectedData).toJS()
 
@@ -371,11 +361,8 @@
       this.setState({
         loading: false
       })
-      notification.error({
-        top: 92,
-        message: result.message,
-        duration: 10
-      })
+      
+      UtilsDM.queryFail(result)
     }
   }
 
@@ -547,7 +534,7 @@
     if (!id) {
       this.reloadtable()
     } else {
-      this.loadmainLinedata(id)
+      this.loadLinedata(id)
     }
   }
 
@@ -561,8 +548,10 @@
         BID: id,
         BData: data
       }, () => {
-        this.loadmaindata(true, 'true')
-        this.getStatFieldsValue()
+        if (!setting.checkBid) {
+          this.loadmaindata(true, 'true')
+          this.getStatFieldsValue()
+        }
       })
     }
   }
@@ -578,14 +567,14 @@
 
     if (config.uuid !== menuId) return
 
-    if (position === 'line') {
+    if (position === 'line' || position === 'line_grid') {
       if (lines && lines.length === 1) {
-        this.loadmainLinedata(lines[0].$$uuid)
+        this.loadLinedata(lines[0].$$uuid, position)
       } else {
         this.reloadtable(btn, id)
       }
-    } else if ((position === 'mainline' || position === 'popclose') && config.setting.supModule && BID) { // 鍒锋柊婧愮粍浠舵椂锛岄檮甯﹀埛鏂颁笂绾ц涓庡綋鍓嶇粍浠�
-      MKEmitter.emit('reloadData', config.setting.supModule, BID)
+    } else if (['mainline', 'maingrid', 'popclose'].includes(position) && config.setting.supModule) {
+      MKEmitter.emit('reloadData', config.setting.supModule, position === 'maingrid' ? '' : BID)
     } else {
       this.reloadtable(btn, id)
     }
@@ -599,6 +588,25 @@
     this.setState({pageIndex: 1}, () => {
       this.reloadtable()
     })
+  }
+
+  autoExec = (times) => {
+    const { config } = this.state
+
+    if (!config.wrap.autoExec) return
+
+    let btn = document.getElementById('button' + config.wrap.autoExec)
+
+    this.autoTimer && clearTimeout(this.autoTimer)
+
+    if (btn) {
+      MKEmitter.emit('triggerBtnId', config.wrap.autoExec, [])
+    } else if (!times || times < 20) {
+      times = times ? times + 1 : 1
+      this.autoTimer = setTimeout(() => {
+        this.autoExec(times)
+      }, 1000)
+    }
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -616,6 +624,8 @@
     if (config.setting.useMSearch) {
       MKEmitter.addListener('searchRefresh', this.searchRefresh)
     }
+
+    this.autoExec()
   }
 
   /**
@@ -648,22 +658,20 @@
           columns={config.columns}
           selectedData={selectedData}
         /> : <div style={{height: '25px'}}></div>}
-        <div className="main-table-box">
-          <MainTable
-            data={data}
-            setting={setting}
-            columns={columns}
-            MenuID={config.uuid}
-            fields={config.columns}
-            total={this.state.total}
-            autoMatic={config.autoMatic}
-            lineMarks={config.lineMarks}
-            loading={this.state.loading}
-            refreshdata={this.refreshbytable}
-            statFValue={this.state.statFValue}
-            chgSelectData={(selects) => this.setState({selectedData: selects})}
-          />
-        </div>
+        <MainTable
+          data={data}
+          setting={setting}
+          columns={columns}
+          MenuID={config.uuid}
+          fields={config.columns}
+          total={this.state.total}
+          autoMatic={config.autoMatic}
+          lineMarks={config.lineMarks}
+          loading={this.state.loading}
+          refreshdata={this.refreshbytable}
+          statFValue={this.state.statFValue}
+          chgSelectData={(selects) => this.setState({selectedData: selects})}
+        />
       </div>
     )
   }

--
Gitblit v1.8.0