From 365ea069f179ee71a7a8cc7785ccd2d86bd4881c Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 03 二月 2021 18:33:45 +0800
Subject: [PATCH] 2021-02-03

---
 src/tabviews/custom/components/share/normalTable/index.jsx |   52 +++++++++++++++++++++++++++++++++-------------------
 1 files changed, 33 insertions(+), 19 deletions(-)

diff --git a/src/tabviews/custom/components/share/normalTable/index.jsx b/src/tabviews/custom/components/share/normalTable/index.jsx
index 5d403fe..255cfa3 100644
--- a/src/tabviews/custom/components/share/normalTable/index.jsx
+++ b/src/tabviews/custom/components/share/normalTable/index.jsx
@@ -170,7 +170,7 @@
   }
 
   render() {
-    let { col, config, record, className, style, triggerLink, updateStatus, ...resProps } = this.props
+    let { col, config, record, className, style, triggerLink, ...resProps } = this.props
 
     if (!col) return (<td {...resProps} className={className} style={style}/>)
     
@@ -246,6 +246,10 @@
 
       if (col.blur) {
         content = md5(content)
+      }
+
+      if (col.rowspan === 'true') {
+        resProps.rowSpan = record['$$' + col.field]
       }
 
       if (col.linkThdMenu || col.linkurl) {
@@ -347,12 +351,12 @@
     } else if (col.type === 'custom') {
       style.padding = '0px'
       resProps.children = (
-        <CardCellComponent data={record} cards={config} elements={col.elements} updateStatus={this.props.updateStatus}/>
+        <CardCellComponent data={record} cards={config} elements={col.elements}/>
       )
     } else if (col.type === 'action') {
       style.padding = '0px 5px'
       resProps.children = (
-        <CardCellComponent data={record} cards={config} elements={col.elements} updateStatus={this.props.updateStatus}/>
+        <CardCellComponent data={record} cards={config} elements={col.elements}/>
       )
     }
 
@@ -376,11 +380,11 @@
     loading: PropTypes.bool,         // 琛ㄦ牸鍔犺浇涓�
     refreshdata: PropTypes.func,     // 琛ㄦ牸涓帓搴忓垪銆侀〉鐮佺殑鍙樺寲鏃跺埛鏂�
     chgSelectData: PropTypes.func,   // 鏁版嵁鍒囨崲
-    refreshbyaction: PropTypes.func, // 鎸夐挳鎵ц瀹屾垚鍚庡埛鏂�
   }
 
   state = {
     dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
+    tableId: '',          // 琛ㄦ牸ID
     selectedRowKeys: [],  // 琛ㄦ牸涓�変腑琛�
     pageIndex: 1,         // 鍒濆椤甸潰绱㈠紩
     pageSize: 10,         // 姣忛〉鏁版嵁鏉℃暟
@@ -441,8 +445,7 @@
               record,
               col: item,
               config: item.type === 'custom' || item.type === 'action' ? {setting, columns: fields} : null,
-              triggerLink: this.triggerLink,
-              updateStatus: this.updateStatus
+              triggerLink: this.triggerLink
             })
           }
         }
@@ -457,9 +460,26 @@
       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,
+      tableId,
       orderfields
     })
   }
@@ -480,12 +500,6 @@
       return
     }
     MKEmitter.removeListener('resetTable', this.resetTable)
-  }
-
-  updateStatus = (type, positon, btn) => {
-    if (type === 'refresh') {
-      this.props.refreshbyaction(positon, btn)
-    }
   }
 
   // 瀛楁閫忚
@@ -563,7 +577,7 @@
       index = selectedRowKeys.slice(-1)[0]
     }
 
-    if (setting.tableType === 'checkbox') {
+    if (setting.tableType === 'checkbox' || setting.tableType === 'radio') {
       _activeIndex = index === '' ? null : index
     }
 
@@ -589,7 +603,7 @@
     if (setting.tableType === 'radio') {
       newkeys = [index]
       this.changedata(index)
-      this.setState({ selectedRowKeys: newkeys })
+      this.setState({ selectedRowKeys: newkeys, activeIndex: index })
     } else {
       let _index = ''
       if (newkeys.includes(index)) {
@@ -679,13 +693,13 @@
         let preItem = data[index - 1]
         rowspans.forEach((cell, i) => {
           if (i === 0) {
-            if ((item[cell] || item[cell] === 0) && preItem[cell] === item[cell]) {
+            if (preItem[cell] === item[cell]) {
               item['$' + cell] = preItem['$' + cell] + 1
             } else {
               item['$' + cell] = 1
             }
           } else {
-            if ((item[cell] || item[cell] === 0) && preItem[cell] === item[cell]) {
+            if (preItem[cell] === item[cell]) {
               item['$' + cell] = preItem['$' + cell] + 1
             } else {
               item['$' + cell] = 1
@@ -733,7 +747,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
@@ -780,13 +794,13 @@
     }
 
     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
         }
         <Table
-          size="middle"
           components={components}
+          size={setting.size || 'middle'}
           bordered={setting.bordered !== 'false'}
           rowSelection={rowSelection}
           columns={this.state.columns}

--
Gitblit v1.8.0