From 31df729bbc664b826536a344e2bf7dd81854c477 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 30 七月 2024 17:21:43 +0800
Subject: [PATCH] 2024-07-30

---
 src/tabviews/custom/components/table/base-table/index.jsx |  139 +++++++++++++++++++++++++---------------------
 1 files changed, 76 insertions(+), 63 deletions(-)

diff --git a/src/tabviews/custom/components/table/base-table/index.jsx b/src/tabviews/custom/components/table/base-table/index.jsx
index 538a792..2dadeda 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,14 +104,17 @@
       this.setState({
         data: [],
         selectedData: [],
+        loading: false,
         total: 0
       })
       
       MKEmitter.emit('resetSelectLine', config.uuid, '', '') // 骞挎挱鏁版嵁鍒囨崲
       reset && MKEmitter.emit('resetTable', config.uuid, 'true') // 鍒楄〃閲嶇疆
-      if (setting.$hasSyncModule) {
-        MKEmitter.emit('syncBalconyData', config.uuid, [], false)
-      }
+      // 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)
 
@@ -165,9 +173,9 @@
         }
       } else {
         MKEmitter.emit('resetSelectLine', config.uuid, '', '') // 骞挎挱鏁版嵁鍒囨崲
-        if (setting.$hasSyncModule) {
-          MKEmitter.emit('syncBalconyData', config.uuid, [], false)
-        }
+        // if (setting.$hasSyncModule) {
+        //   MKEmitter.emit('syncBalconyData', config.uuid, [], false)
+        // }
       }
       
       reset && MKEmitter.emit('resetTable', config.uuid, repage) // 鍒楄〃閲嶇疆
@@ -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,18 +239,7 @@
         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)
     }
   }
 
@@ -376,11 +361,8 @@
       this.setState({
         loading: false
       })
-      notification.error({
-        top: 92,
-        message: result.message,
-        duration: 10
-      })
+      
+      UtilsDM.queryFail(result)
     }
   }
 
@@ -457,7 +439,19 @@
    * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃�
    */
   refreshbysearch = (searches) => {
-    const { config} = this.state
+    const { config, BID } = this.state
+
+    if (config.setting.supModule && !BID) {
+      notification.warning({
+        top: 92,
+        message: window.GLOB.dict['sup_key_req'] || '闇�瑕佷笂绾т富閿�硷紒',
+        duration: 5
+      })
+      this.setState({
+        search: searches
+      })
+      return
+    }
 
     this.setState({
       pageIndex: 1,
@@ -566,8 +560,10 @@
         BID: id,
         BData: data
       }, () => {
-        this.loadmaindata(true, 'true')
-        this.getStatFieldsValue()
+        if (!setting.checkBid) {
+          this.loadmaindata(true, 'true')
+          this.getStatFieldsValue()
+        }
       })
     }
   }
@@ -584,13 +580,13 @@
     if (config.uuid !== menuId) return
 
     if (position === 'line' || position === 'line_grid') {
-      if (lines && lines.length === 1) {
+      if (lines && lines.length === 1 && !config.forbidLine) {
         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)
     }
@@ -601,9 +597,26 @@
 
     if (config.$searchId !== searchId) return
     
-    this.setState({pageIndex: 1}, () => {
-      this.reloadtable()
-    })
+    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) {
@@ -621,6 +634,8 @@
     if (config.setting.useMSearch) {
       MKEmitter.addListener('searchRefresh', this.searchRefresh)
     }
+
+    this.autoExec()
   }
 
   /**
@@ -653,22 +668,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