From ba9e189dd33c8d48f7f4ac36bcefeef9afb426f8 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 17 七月 2023 23:40:49 +0800
Subject: [PATCH] 2023-07-17

---
 src/tabviews/custom/components/table/edit-table/index.jsx |  114 +++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 70 insertions(+), 44 deletions(-)

diff --git a/src/tabviews/custom/components/table/edit-table/index.jsx b/src/tabviews/custom/components/table/edit-table/index.jsx
index d0802d5..cbbbbed 100644
--- a/src/tabviews/custom/components/table/edit-table/index.jsx
+++ b/src/tabviews/custom/components/table/edit-table/index.jsx
@@ -37,7 +37,7 @@
     pageIndex: 1,         // 椤电爜
     pageSize: 10,         // 姣忛〉鏁版嵁鏉℃暟
     orderBy: '',          // 鎺掑簭
-    search: '',           // 鎼滅储鏉′欢鏁扮粍锛屼娇鐢ㄦ椂闇�鍒嗗満鏅鐞�
+    search: ''            // 鎼滅储鏉′欢鏁扮粍锛屼娇鐢ㄦ椂闇�鍒嗗満鏅鐞�
   }
 
   /**
@@ -79,6 +79,7 @@
     let _columns = []
     setting.initId = ''
     let triMap = new Map()
+    setting.hasSubmit = false
 
     let getColumns = (cols) => {
       return cols.filter(item => {
@@ -92,8 +93,9 @@
           if (item.subcols.length === 0) {
             return false
           }
-        } else if (item.type === 'action') {
+        } else if (item.type === 'custom') {
           item.elements.forEach(btn => {
+            if (btn.eleType !== 'button') return
             if (btn.funcType === 'addline') {
               setting.addable = true
             }
@@ -114,6 +116,7 @@
           }
 
           if (item.editable === 'true') {
+            setting.hasSubmit = true
             if (!setting.initId) {
               setting.initId = item.uuid
             }
@@ -259,16 +262,31 @@
       })
 
       MKEmitter.emit('transferData', config.uuid, data)
+
+      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
+          })
+        }
+      }
     } else {
       this.setState({
         loading: false
       })
       
+      if (!result.message) return
       if (result.ErrCode === 'N') {
         Modal.error({
           title: result.message,
         })
-      } else {
+      } else if (result.ErrCode !== '-2') {
         notification.error({
           top: 92,
           message: result.message,
@@ -330,25 +348,21 @@
         })
       }
 
-      try {
-        data = data.map(item => {
-          if (item.$$uuid === _data.$$uuid) {
-            _data.key = item.key
-            _data.$Index = item.$Index
-            return _data
-          } else {
-            return item
-          }
-        })
-        selectedData = selectedData.map(item => {
-          if (_data.$$uuid === item.$$uuid) {
-            return _data
-          }
+      data = data.map(item => {
+        if (item.$$uuid === _data.$$uuid) {
+          _data.key = item.key
+          _data.$Index = item.$Index
+          return _data
+        } else {
           return item
-        })
-      } catch (e) {
-        console.warn('鏁版嵁鏌ヨ閿欒')
-      }
+        }
+      })
+      selectedData = selectedData.map(item => {
+        if (_data.$$uuid === item.$$uuid) {
+          return _data
+        }
+        return item
+      })
 
       MKEmitter.emit('transferData', config.uuid, _data, 'line')
       MKEmitter.emit('resetSelectLine', config.uuid, _data.$$uuid, _data)
@@ -375,24 +389,12 @@
    * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃�
    */
   refreshbysearch = (searches) => {
-    const { setting } = this.state
-
-    if (setting.onload === 'false') {
-      this.setState({
-        pageIndex: 1,
-        search: searches,
-        setting: {...setting, onload: 'true'}
-      }, () => {
-        this.loadmaindata()
-      })
-    } else {
-      this.setState({
-        pageIndex: 1,
-        search: searches
-      }, () => {
-        this.loadmaindata(true, 'true')
-      })
-    }
+    this.setState({
+      pageIndex: 1,
+      search: searches
+    }, () => {
+      this.loadmaindata(true, 'true')
+    })
   }
 
   /**
@@ -480,7 +482,9 @@
         BID: id,
         BData: data
       }, () => {
-        this.loadmaindata(true, 'true')
+        setTimeout(() => {
+          this.loadmaindata(true, 'true')
+        }, setting.delay || 0)
       })
     }
   }
@@ -507,10 +511,30 @@
     } else {
       this.reloadtable(btn)
     }
+  }
 
-    if (position === 'popclose') { // 鎵ц鍚姩寮圭獥鐨勬寜閽墍閫夋嫨鐨勫埛鏂伴」
-      btn.$tabId && MKEmitter.emit('refreshPopButton', btn.$tabId)
-    }
+  refreshLineData = (menuId, btn, uuid, count) => {
+    const { config } = this.state
+
+    if (config.uuid !== menuId) return
+    
+    let _data = fromJS(this.state.data).toJS().map(item => {
+      if (item.$$uuid === uuid) {
+        item[btn.field] = count
+      }
+      return item
+    })
+    let _selectedData = fromJS(this.state.selectedData).toJS().map(item => {
+      if (item.$$uuid === uuid) {
+        item[btn.field] = count
+      }
+      return item
+    })
+
+    this.setState({
+      data: _data,
+      selectedData: _selectedData
+    })
   }
 
   UNSAFE_componentWillReceiveProps(nextProps) {
@@ -531,6 +555,7 @@
     MKEmitter.addListener('reloadData', this.reloadData)
     MKEmitter.addListener('resetSelectLine', this.resetParentParam)
     MKEmitter.addListener('queryModuleParam', this.queryModuleParam)
+    MKEmitter.addListener('refreshLineData', this.refreshLineData)
     MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult)
   }
 
@@ -544,6 +569,7 @@
     MKEmitter.removeListener('reloadData', this.reloadData)
     MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
     MKEmitter.removeListener('queryModuleParam', this.queryModuleParam)
+    MKEmitter.removeListener('refreshLineData', this.refreshLineData)
     MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
   }
 
@@ -556,7 +582,7 @@
     }
 
     return (
-      <div className="custom-edit-table" id={'anchor' + config.uuid} style={style}>
+      <div className={'custom-edit-table' + (setting.hasSubmit ? '' : ' withnot-submit')} id={'anchor' + config.uuid} style={style}>
         <NormalHeader config={config}/>
         {config.search && config.search.length ?
           <MainSearch BID={BID} config={config} refreshdata={this.refreshbysearch}/> : null

--
Gitblit v1.8.0