From 742f7d11557526038d332e60a8c8ca18177bc4e4 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 26 十月 2023 15:51:58 +0800
Subject: [PATCH] Merge branch 'master' into positec

---
 src/tabviews/custom/components/share/normalTable/index.jsx |   97 ++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 85 insertions(+), 12 deletions(-)

diff --git a/src/tabviews/custom/components/share/normalTable/index.jsx b/src/tabviews/custom/components/share/normalTable/index.jsx
index be531d2..b090fc7 100644
--- a/src/tabviews/custom/components/share/normalTable/index.jsx
+++ b/src/tabviews/custom/components/share/normalTable/index.jsx
@@ -132,9 +132,9 @@
       }
 
       if (col.marks) {
-        let mark = getMark(col.marks, record, style)
+        style = style ? {...style} : {}
 
-        style = mark.style
+        let mark = getMark(col.marks, record, style)
 
         if (mark.icon) {
           if (mark.position === 'front') {
@@ -204,9 +204,9 @@
       }
 
       if (col.marks) {
-        let mark = getMark(col.marks, record, style)
+        style = style ? {...style} : {}
 
-        style = mark.style
+        let mark = getMark(col.marks, record, style)
 
         if (mark.icon) {
           if (mark.position === 'front') {
@@ -389,9 +389,9 @@
       }
 
       if (col.marks) {
-        let mark = getMark(col.marks, record, style)
+        style = style ? {...style} : {}
 
-        style = mark.style
+        let mark = getMark(col.marks, record, style)
 
         if (mark.icon) {
           if (mark.position === 'front') {
@@ -442,7 +442,9 @@
     loading: PropTypes.bool,         // 琛ㄦ牸鍔犺浇涓�
     refreshdata: PropTypes.func,     // 琛ㄦ牸涓帓搴忓垪銆侀〉鐮佺殑鍙樺寲鏃跺埛鏂�
     chgSelectData: PropTypes.func,   // 鏁版嵁鍒囨崲
-    autoMatic: PropTypes.any
+    autoMatic: PropTypes.any,
+    allSearch: PropTypes.any,
+    colsCtrls: PropTypes.any
   }
 
   state = {
@@ -455,11 +457,13 @@
     rowspans: null,       // 琛屽悎骞跺瓧娈典俊鎭�
     pickup: false,        // 鏀惰捣鏈�夋嫨椤�
     orderfields: {},      // 鎺掑簭id涓巉ield杞崲
-    pageOptions: []
+    pageOptions: [],
+    allColumns: null,
+    reseting: false
   }
 
   UNSAFE_componentWillMount () {
-    const { setting, fields, columns } = this.props
+    const { setting, columns, fields, colsCtrls } = this.props
     let radio = 5          // 铏氬寲姣斾緥
     let _format = false    // 鏄惁铏氬寲澶勭悊
     let rowspans = []
@@ -483,7 +487,7 @@
           let cell = null
     
           if (item.type === 'colspan') {
-            cell = { title: item.label, align: item.Align }
+            cell = { title: item.label, align: item.Align, $key: item.uuid }
             cell.children = getColumns(item.subcols)
           } else {
             if (item.rowspan === 'true') {
@@ -502,13 +506,16 @@
   
             if (item.field) {
               orderfields[item.uuid] = item.field
+            } else if (item.sortField) {
+              orderfields[item.uuid] = item.sortField
             }
   
             cell = {
+              $key: item.uuid,
               align: item.Align,
               dataIndex: item.uuid,
               title: item.label,
-              sorter: item.field && item.IsSort === 'true',
+              sorter: (item.field || item.sortField) && item.IsSort === 'true',
               width: item.Width || 120,
               onCell: record => ({
                 record,
@@ -530,6 +537,7 @@
         fields.push(item.field)
 
         _columns.push({
+          $key: item.uuid,
           align: item.Align,
           dataIndex: item.field,
           title: item.label,
@@ -562,9 +570,17 @@
       pageOptions = pageOptions.sort((a, b) => a - b)
     }
 
+    let allColumns = null
+    if (colsCtrls) {
+      rowspans = null
+      allColumns = [..._columns]
+      _columns = this.getCurColumns(_columns, this.props.allSearch)
+    }
+
     this.setState({
       pageSize: setting.pageSize || 10,
       pageOptions,
+      allColumns,
       columns: _columns,
       rowspans,
       tableId,
@@ -580,6 +596,20 @@
 
   shouldComponentUpdate (nextProps, nextState) {
     return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
+  }
+
+  UNSAFE_componentWillReceiveProps(nextProps) {
+    const { allSearch } = this.props
+    const { allColumns } = this.state
+
+    if (allSearch && !is(fromJS(allSearch), fromJS(nextProps.allSearch))) {
+      this.setState({
+        reseting: true,
+        columns: this.getCurColumns(allColumns, nextProps.allSearch)
+      }, () => {
+        this.setState({reseting: false})
+      })
+    }
   }
 
   componentDidMount () {
@@ -608,6 +638,47 @@
     MKEmitter.removeListener('autoQueryData', this.autoQueryData)
     MKEmitter.removeListener('autoSelectData', this.autoSelectData)
     MKEmitter.removeListener('mkCheckTopLine', this.mkCheckTopLine)
+  }
+
+  getCurColumns = (columns, allSearch) => {
+    const { colsCtrls } = this.props
+
+    let values = {}
+    allSearch.forEach(item => {
+      values[item.key] = item.value
+    })
+    let cols = null
+    colsCtrls.some(item => {
+      let originVal = item.field.map(f => values[f] || '').join('')
+      let contrastVal = item.contrastValue
+      let result = false
+
+      if (item.match === '=') {
+        result = originVal === contrastVal
+      } else if (item.match === '!=') {
+        result = originVal !== contrastVal
+      } else {
+        originVal = isNaN(originVal) ? originVal : +originVal
+        contrastVal = isNaN(contrastVal) ? contrastVal : +contrastVal
+        if (item.match === '>') {
+          result = originVal > contrastVal
+        } else if (item.match === '<') {
+          result = originVal < contrastVal
+        }
+      }
+
+      if (!result) return false
+
+      cols = item.cols
+
+      return true
+    })
+
+    if (cols) {
+      return columns.filter(col => cols.includes(col.$key))
+    }
+
+    return columns
   }
 
   autoSelectData = (id, index) => {
@@ -1002,7 +1073,9 @@
 
   render() {
     const { setting, statFValue, lineMarks, data } = this.props
-    const { selectedRowKeys, activeIndex, pickup, tableId, pageOptions, columns } = this.state
+    const { selectedRowKeys, activeIndex, pickup, tableId, pageOptions, columns, reseting } = this.state
+
+    if (reseting) return null
 
     // 璁剧疆琛ㄦ牸閫夋嫨灞炴�э細鍗曢�夈�佸閫夈�佷笉鍙��
     let rowSelection = null

--
Gitblit v1.8.0