From d08fba77101b83f211738c722403506cc7dab50b Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 08 五月 2024 22:41:50 +0800
Subject: [PATCH] 2024-05-08

---
 src/tabviews/custom/components/share/normalTable/index.jsx |   40 ++++++++++++++++++++++++++++++++++------
 1 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/src/tabviews/custom/components/share/normalTable/index.jsx b/src/tabviews/custom/components/share/normalTable/index.jsx
index 04f091d..f2f8eb5 100644
--- a/src/tabviews/custom/components/share/normalTable/index.jsx
+++ b/src/tabviews/custom/components/share/normalTable/index.jsx
@@ -507,7 +507,8 @@
     chgSelectData: PropTypes.func,   // 鏁版嵁鍒囨崲
     autoMatic: PropTypes.any,
     allSearch: PropTypes.any,
-    colsCtrls: PropTypes.any
+    colsCtrls: PropTypes.any,
+    parCtrl: PropTypes.any
   }
 
   state = {
@@ -556,10 +557,7 @@
             if (item.rowspan === 'true') {
               rowspans.push(item.field)
             }
-            if (item.type === 'index') {
-              item.field = '$Index'
-              item.type = 'text'
-            } else if (_format && !Math.floor(Math.random() * radio)) {
+            if (_format && !Math.floor(Math.random() * radio)) {
               item.blur = true
             }
   
@@ -655,7 +653,7 @@
   }
 
   UNSAFE_componentWillReceiveProps(nextProps) {
-    const { allSearch } = this.props
+    const { allSearch, parCtrl } = this.props
     const { allColumns } = this.state
 
     if (allSearch && !is(fromJS(allSearch), fromJS(nextProps.allSearch))) {
@@ -665,6 +663,36 @@
       }, () => {
         this.setState({reseting: false})
       })
+    } else if (parCtrl && !is(fromJS(this.props.columns), fromJS(nextProps.columns))) {
+      let getColumns = (cols) => {
+        return cols.map(item => {
+          let cell = null
+    
+          if (item.type === 'colspan') {
+            cell = { title: item.label, align: item.Align }
+            cell.children = getColumns(item.subcols)
+          } else {
+            cell = {
+              align: item.Align,
+              dataIndex: item.uuid,
+              title: item.label,
+              sorter: (item.field || item.sortField) && item.IsSort === 'true',
+              width: item.Width || 120,
+              onCell: record => ({
+                record,
+                col: item,
+                config: item.type === 'custom' ? {setting: this.props.setting, columns: this.props.fields} : null,
+              })
+            }
+          }
+    
+          return cell
+        })
+      }
+
+      this.setState({
+        columns: getColumns(nextProps.columns)
+      })
     }
   }
 

--
Gitblit v1.8.0