From c51f5e007a3e03c9d6731ab7f28f0080de009990 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 17 十一月 2021 18:38:32 +0800
Subject: [PATCH] 2021-11-17

---
 src/tabviews/subtabtable/index.jsx |  100 +++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 82 insertions(+), 18 deletions(-)

diff --git a/src/tabviews/subtabtable/index.jsx b/src/tabviews/subtabtable/index.jsx
index 68ab680..c3d2df2 100644
--- a/src/tabviews/subtabtable/index.jsx
+++ b/src/tabviews/subtabtable/index.jsx
@@ -28,7 +28,6 @@
     BID: PropTypes.string,           // 涓婄骇鏁版嵁ID
     BData: PropTypes.any,            // 涓婄骇鏁版嵁
     MenuID: PropTypes.string,        // 鑿滃崟Id
-    mainSearch: PropTypes.any,       // 涓昏〃鎼滅储鏉′欢
     SupMenuID: PropTypes.string,     // 涓婄骇鑿滃崟Id
   }
 
@@ -315,13 +314,9 @@
   }
 
   loadData = () => {
-    const { mainSearch } = this.props
     const { setting, search, hasReqFields, loadCustomApi } = this.state
 
     let searches = fromJS(search).toJS()
-    if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
-      searches = [...mainSearch, ...searches]
-    }
 
     if (hasReqFields) {
       let requireFields = searches.filter(item => item.required && item.value === '')
@@ -532,13 +527,10 @@
    * @description 瀛愯〃鏁版嵁鍔犺浇
    */
   async loadmaindata () {
-    const { mainSearch, BID } = this.props
+    const { BID } = this.props
     const { setting, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state
 
     let searches = fromJS(search).toJS()
-    if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
-      searches = [...mainSearch, ...searches]
-    }
 
     this.setState({
       loading: true
@@ -644,6 +636,79 @@
   }
 
   /**
+   * @description 鑾峰彇鍗曡鏁版嵁
+   */ 
+  async loadmainLinedata (id) {
+    const { BID } = this.props
+    const { setting, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state
+
+    let searches = fromJS(search).toJS()
+
+    this.setState({
+      loading: true
+    })
+
+    let _orderBy = orderBy || setting.order
+    let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, this.props.menuType, id)
+
+    let result = await Api.genericInterface(param)
+    if (result.status) {
+      let data = fromJS(this.state.data).toJS()
+      let selectedData = fromJS(this.state.selectedData).toJS()
+      if (result.data && result.data[0]) {
+        let _data = result.data[0] || {}
+
+        if (absFields.length) {
+          absFields.forEach(field => {
+            if (!_data[field]) return
+            if (isNaN(Math.abs(_data[field]))) return
+            
+            _data[field] = Math.abs(_data[field])
+          })
+        }
+
+        _data.$$uuid = _data[setting.primaryKey] || ''
+        _data.$$BID = BID || ''
+
+        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
+            }
+            return item
+          })
+        } catch (e) {
+          console.warn('鏁版嵁鏌ヨ閿欒')
+        }
+      }
+
+      this.setState({
+        data,
+        selectedData,
+        loading: false
+      })
+    } else {
+      this.setState({
+        loading: false
+      })
+      notification.error({
+        top: 92,
+        message: result.message,
+        duration: 10
+      })
+    }
+  }
+
+  /**
    * @description 鎼滅储鏉′欢鏀瑰彉鏃讹紝閲嶇疆琛ㄦ牸鏁版嵁
    * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃�
    */
@@ -707,20 +772,15 @@
    * @description 瀵煎嚭Excel鏃讹紝鑾峰彇椤甸潰鎼滅储鎺掑簭绛夊弬鏁�
    */
   queryModuleParam = (menuId, btnId) => {
-    const { Tab, mainSearch, MenuID } = this.props
+    const { Tab, MenuID } = this.props
     const { arr_field, orderBy, search, setting} = this.state
 
     if (MenuID !== menuId) return
 
-    let searches = search
-    if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
-      searches = [...mainSearch, ...search]
-    }
-
     MKEmitter.emit('returnModuleParam', MenuID, btnId, {
       arr_field: arr_field,
       orderBy: orderBy || setting.order,
-      search: searches,
+      search: search,
       menuName: Tab.label
     })
   }
@@ -731,12 +791,16 @@
    * @param {*} position   // 鍒锋柊浣嶇疆
    * @param {*} btn        // 鎵ц鐨勬寜閽�
    */
-  refreshByButtonResult = (menuId, position, btn) => {
+  refreshByButtonResult = (menuId, position, btn, id, lines) => {
     const { MenuID } = this.props
 
     if (MenuID !== menuId) return
 
-    this.reloadtable(btn)
+    if (position === 'line' && lines && lines.length === 1) {
+      this.loadmainLinedata(lines[0].$$uuid)
+    } else {
+      this.reloadtable(btn)
+    }
     MKEmitter.emit('refreshPopButton', this.props.Tab.uuid)
   }
 

--
Gitblit v1.8.0