From af6486b3629d23e426ce85b87dbc20dfa15b1afe Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 07 十一月 2022 18:50:27 +0800
Subject: [PATCH] 2022-11-07

---
 src/tabviews/custom/components/share/normalTable/index.jsx |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/src/tabviews/custom/components/share/normalTable/index.jsx b/src/tabviews/custom/components/share/normalTable/index.jsx
index b009cc7..09611a8 100644
--- a/src/tabviews/custom/components/share/normalTable/index.jsx
+++ b/src/tabviews/custom/components/share/normalTable/index.jsx
@@ -409,6 +409,7 @@
     loading: PropTypes.bool,         // 琛ㄦ牸鍔犺浇涓�
     refreshdata: PropTypes.func,     // 琛ㄦ牸涓帓搴忓垪銆侀〉鐮佺殑鍙樺寲鏃跺埛鏂�
     chgSelectData: PropTypes.func,   // 鏁版嵁鍒囨崲
+    autoMatic: PropTypes.any
   }
 
   state = {
@@ -548,9 +549,17 @@
   }
 
   componentDidMount () {
-    MKEmitter.addListener('mkCheckTopLine', this.mkCheckTopLine)
+    const { autoMatic } = this.props
+
     MKEmitter.addListener('mkCheckAll', this.mkCheckAll)
     MKEmitter.addListener('resetTable', this.resetTable)
+
+    if (autoMatic === true) {
+      MKEmitter.addListener('autoQueryData', this.autoQueryData)
+      MKEmitter.addListener('autoSelectData', this.autoSelectData)
+    }
+
+    MKEmitter.addListener('mkCheckTopLine', this.mkCheckTopLine)
   }
 
   /**
@@ -560,9 +569,50 @@
     this.setState = () => {
       return
     }
-    MKEmitter.removeListener('mkCheckTopLine', this.mkCheckTopLine)
     MKEmitter.removeListener('mkCheckAll', this.mkCheckAll)
     MKEmitter.removeListener('resetTable', this.resetTable)
+    MKEmitter.removeListener('autoQueryData', this.autoQueryData)
+    MKEmitter.removeListener('autoSelectData', this.autoSelectData)
+    MKEmitter.removeListener('mkCheckTopLine', this.mkCheckTopLine)
+  }
+
+  autoSelectData = (id, index) => {
+    if (id !== this.props.MenuID) return
+
+    const { pageSize, pageIndex } = this.state
+
+    let i = index - (pageIndex - 1) * pageSize - 1
+
+    if (this.props.data[i]) {
+      this.changeRow(this.props.data[i], i)
+      MKEmitter.emit('autoTransSelectData', this.props.MenuID, this.props.data[i])
+    } else {
+      MKEmitter.emit('autoMaticOver', this.props.MenuID)
+    }
+  }
+
+  autoQueryData = (id, index) => {
+    if (id !== this.props.MenuID) return
+
+    const { total } = this.props
+    const { pageSize } = this.state
+
+    if (index !== 1 && (!total || index > total)) {
+      MKEmitter.emit('autoMaticOver', this.props.MenuID)
+      return
+    }
+
+    console.clear()
+
+    let pageIndex = Math.ceil(index / pageSize)
+
+    this.setState({
+      pageIndex: pageIndex,
+      selectedRowKeys: [],
+      activeIndex: null
+    })
+
+    this.props.refreshdata({pageIndex})
   }
 
   mkCheckTopLine = (menuId, id) => {

--
Gitblit v1.8.0