From 1ed217be1abce1a1da18d90a1a9f358beef79acd Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 30 十二月 2020 18:31:28 +0800
Subject: [PATCH] 2020-12-30

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

diff --git a/src/tabviews/custom/components/share/normalTable/index.jsx b/src/tabviews/custom/components/share/normalTable/index.jsx
index e377073..65f1256 100644
--- a/src/tabviews/custom/components/share/normalTable/index.jsx
+++ b/src/tabviews/custom/components/share/normalTable/index.jsx
@@ -381,13 +381,15 @@
 
   state = {
     dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
+    tableId: '',          // 琛ㄦ牸ID
     selectedRowKeys: [],  // 琛ㄦ牸涓�変腑琛�
     pageIndex: 1,         // 鍒濆椤甸潰绱㈠紩
     pageSize: 10,         // 姣忛〉鏁版嵁鏉℃暟
     columns: null,        // 鏄剧ず鍒�
     activeIndex: null,    // 鏍囪褰撳墠閫変腑琛�
     rowspans: null,       // 琛屽悎骞跺瓧娈典俊鎭�
-    pickup: false
+    pickup: false,        // 鏀惰捣鏈�夋嫨椤�
+    orderfields: {}       // 鎺掑簭id涓巉ield杞崲
   }
 
   UNSAFE_componentWillMount () {
@@ -395,6 +397,7 @@
     let radio = 5          // 铏氬寲姣斾緥
     let _format = false    // 鏄惁铏氬寲澶勭悊
     let rowspans = []
+    let orderfields = {}
 
     if (window.GLOB.dataFormat && menuType !== 'HS' && memberLevel) {
       _format = true
@@ -424,7 +427,11 @@
           if (item.marks && item.marks.length === 0) {
             item.marks = ''
           }
-  
+
+          if (item.field) {
+            orderfields[item.uuid] = item.field
+          }
+
           cell = {
             align: item.Align,
             dataIndex: item.uuid,
@@ -451,9 +458,27 @@
       rowspans = null
     }
 
+    let tableId = (() => {
+      let uuid = []
+      let _options = 'abcdefghigklmnopqrstuv'
+      for (let i = 0; i < 19; i++) {
+        uuid.push(_options.substr(Math.floor(Math.random() * 0x20), 1))
+      }
+      return uuid.join('')
+    }) ()
+
+    if (setting.borderColor) { // 杈规棰滆壊
+      let style = `#${tableId} table, #${tableId} tr, #${tableId} th, #${tableId} td {border-color: ${setting.borderColor}}`
+      let ele = document.createElement('style')
+      ele.innerHTML = style
+      document.getElementsByTagName('head')[0].appendChild(ele)
+    }
+
     this.setState({
       columns: _columns,
-      rowspans
+      rowspans,
+      tableId,
+      orderfields
     })
   }
 
@@ -606,6 +631,8 @@
   }
 
   changeTable = (pagination, filters, sorter) => {
+    const { orderfields } = this.state
+
     this.setState({
       pageIndex: pagination.current,
       pageSize: pagination.pageSize,
@@ -613,6 +640,9 @@
       activeIndex: null,
       pickup: false
     })
+
+    sorter.field = orderfields[sorter.field] || ''
+
     this.props.refreshdata(pagination, filters, sorter)
   }
 
@@ -721,7 +751,7 @@
 
   render() {
     const { setting, statFValue, lineMarks, data } = this.props
-    const { selectedRowKeys, activeIndex, pickup } = this.state
+    const { selectedRowKeys, activeIndex, pickup, tableId } = this.state
 
     // 璁剧疆琛ㄦ牸閫夋嫨灞炴�э細鍗曢�夈�佸閫夈�佷笉鍙��
     let rowSelection = null
@@ -768,7 +798,7 @@
     }
 
     return (
-      <div className="normal-custom-table">
+      <div className={'normal-custom-table ' + setting.tableHeader} id={tableId}>
         {(setting.tableType === 'radio' || setting.tableType === 'checkbox') && data && data.length > 0 ?
           <Switch title="鏀惰捣" className="main-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={pickup} onChange={this.pickupChange} /> : null
         }

--
Gitblit v1.8.0