From a9b02f6862522b54d0824152017bf2acfec2af7b Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 21 三月 2024 10:29:50 +0800
Subject: [PATCH] 2024-03-21

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

diff --git a/src/tabviews/custom/components/table/base-table/index.jsx b/src/tabviews/custom/components/table/base-table/index.jsx
index 2fd32cd..ec29c8f 100644
--- a/src/tabviews/custom/components/table/base-table/index.jsx
+++ b/src/tabviews/custom/components/table/base-table/index.jsx
@@ -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,12 @@
     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)
 
@@ -261,8 +268,13 @@
   /**
    * @description 鑾峰彇鍗曡鏁版嵁
    */ 
-  async loadmainLinedata (id) {
+  async loadLinedata (id, position) {
     const { setting, config, search, orderBy, BID, pageIndex, pageSize, BData } = this.state
+
+    if (config.forbidLine) {
+      this.reloadtable()
+      return
+    }
 
     let searches = fromJS(search).toJS()
     if (config.setting.useMSearch) { // 涓昏〃鎼滅储鏉′欢
@@ -284,6 +296,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()
 
@@ -380,6 +397,8 @@
   getStatFieldsValue = () => {
     const { setting, config, search, BID, orderBy } = this.state
 
+    if (!config.statFields) return
+    
     if (setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇�
       this.setState({
         statFValue: []
@@ -540,7 +559,7 @@
     if (!id) {
       this.reloadtable()
     } else {
-      this.loadmainLinedata(id)
+      this.loadLinedata(id)
     }
   }
 
@@ -554,8 +573,10 @@
         BID: id,
         BData: data
       }, () => {
-        this.loadmaindata(true, 'true')
-        this.getStatFieldsValue()
+        if (!setting.checkBid) {
+          this.loadmaindata(true, 'true')
+          this.getStatFieldsValue()
+        }
       })
     }
   }
@@ -571,9 +592,9 @@
 
     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)
       }
@@ -594,6 +615,25 @@
     })
   }
 
+  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) {
     return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
   }
@@ -609,6 +649,8 @@
     if (config.setting.useMSearch) {
       MKEmitter.addListener('searchRefresh', this.searchRefresh)
     }
+
+    this.autoExec()
   }
 
   /**
@@ -641,22 +683,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