From 2388f6ea547f53b20a4b9b64efc8aa6dc33e013b Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 06 十一月 2023 15:23:54 +0800
Subject: [PATCH] 2023-11-06

---
 src/tabviews/custom/components/table/edit-table/normalTable/index.jsx |   58 ++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 40 insertions(+), 18 deletions(-)

diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
index 4c039a7..fcdad35 100644
--- a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
+++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
@@ -1345,6 +1345,7 @@
   timer = null
   focusId = ''
   blurId = ''
+  colId = ''
 
   UNSAFE_componentWillMount () {
     const { setting, fields, columns, BID, colsCtrls } = this.props
@@ -1562,8 +1563,9 @@
     }, 150)
   }
 
-  colFocus = (lineId) => {
+  colFocus = (lineId, colId) => {
     this.focusId = lineId
+    this.colId = colId
   }
 
   checkLine = () => {
@@ -1705,9 +1707,11 @@
   }
 
   transferData = (data, type) => {
-    const { edData } = this.state
+    const { edData, tableId } = this.state
 
-    if (type === 'line') {
+    if (type === 'delete') {
+
+    } else if (type === 'line') {
       let value = ''
       Object.keys(data).sort().forEach(key => {
         if (/^\$/.test(key)) return
@@ -1725,14 +1729,18 @@
       })
     }
 
-    if (type !== 'line') {
-      let index = edData.findIndex(item => !item.$origin && !item.$forbid)
+    if (type === 'delete') {
+      let _edData = this.state.edData.filter(item => item.$$uuid !== data)
 
-      if (index > -1) {
-        this.setState({visible: true, midData: data})
-      } else {
-        this.updateMutil(data)
-      }
+      this.setState({edData: _edData, reseting: true}, () => {
+        this.setState({reseting: false})
+
+        if (this.focusId) {
+          setTimeout(() => {
+            MKEmitter.emit('setFocus' + tableId, this.focusId, this.colId)
+          }, 10)
+        }
+      })
     } else if (type === 'line') {
       let _edData = this.state.edData.map(item => {
         if (item.$$uuid === data.$$uuid) {
@@ -1744,7 +1752,21 @@
 
       this.setState({edData: _edData, reseting: true}, () => {
         this.setState({reseting: false})
+
+        if (this.focusId) {
+          setTimeout(() => {
+            MKEmitter.emit('setFocus' + tableId, this.focusId, this.colId)
+          }, 10)
+        }
       })
+    } else {
+      let index = edData.findIndex(item => !item.$origin && !item.$forbid)
+
+      if (index > -1) {
+        this.setState({visible: true, midData: data})
+      } else {
+        this.updateMutil(data)
+      }
     }
   }
 
@@ -2298,9 +2320,9 @@
 
       Api.genericInterface(param).then((res) => {
         if (res.status) {
-          this.execSuccess(res)
+          this.execSuccess(res, record)
         } else {
-          this.execError(res)
+          this.execError(res, record)
         }
       }, (error) => {
         if (error && error.ErrCode === 'LoginError') return
@@ -2317,9 +2339,9 @@
 
       Api.genericInterface(param).then((res) => {
         if (res.status) {
-          this.execSuccess(res)
+          this.execSuccess(res, record)
         } else {
-          this.execError(res)
+          this.execError(res, record)
         }
       }, (error) => {
         if (error && error.ErrCode === 'LoginError') return
@@ -2329,7 +2351,7 @@
     }
   }
 
-  execSuccess = (res) => {
+  execSuccess = (res, record) => {
     const { submit } = this.props
     const { edData } = this.state
 
@@ -2379,13 +2401,13 @@
     }
 
     if (submit.execSuccess !== 'never') {
-      MKEmitter.emit('refreshByButtonResult', submit.$menuId, submit.execSuccess, submit)
+      MKEmitter.emit('refreshByButtonResult', submit.$menuId, submit.execSuccess, submit, '', record ? [record] : null)
     }
 
     submit.syncComponentId && MKEmitter.emit('reloadData', submit.syncComponentId)
   }
 
-  execError = (res) => {
+  execError = (res, record) => {
     const { submit } = this.props
 
     if (res.ErrCode === 'E') {
@@ -2414,7 +2436,7 @@
     })
 
     if (submit.execError !== 'never') {
-      MKEmitter.emit('refreshByButtonResult', submit.$menuId, submit.execError, submit)
+      MKEmitter.emit('refreshByButtonResult', submit.$menuId, submit.execError, submit, '', record ? [record] : null)
     }
   }
 

--
Gitblit v1.8.0