From d6dfba48678e1107a9e7c6524e1dfa2d3fdff03c Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 08 十月 2021 19:29:21 +0800
Subject: [PATCH] 2021-10-08

---
 src/tabviews/custom/components/share/normalTable/index.jsx |  132 +++++++++++++++++++++++++++++++------------
 1 files changed, 94 insertions(+), 38 deletions(-)

diff --git a/src/tabviews/custom/components/share/normalTable/index.jsx b/src/tabviews/custom/components/share/normalTable/index.jsx
index 24682cc..800a973 100644
--- a/src/tabviews/custom/components/share/normalTable/index.jsx
+++ b/src/tabviews/custom/components/share/normalTable/index.jsx
@@ -3,9 +3,8 @@
 import md5 from 'md5'
 import { connect } from 'react-redux'
 import { is, fromJS } from 'immutable'
-import { Table, Typography, Icon, Col, Switch } from 'antd'
+import { Table, Typography, Icon, Col, Switch, message } from 'antd'
 
-import { modifyTabview } from '@/store/action'
 import asyncComponent from '@/utils/asyncComponent'
 import MKEmitter from '@/utils/events.js'
 import zhCN from '@/locales/zh-CN/main.js'
@@ -51,7 +50,7 @@
           try {
             originVal = parseFloat(originVal)
             contrastVal = parseFloat(contrastVal)
-          } catch {
+          } catch (e) {
             originVal = NaN
           }
   
@@ -62,7 +61,7 @@
           try {
             originVal = parseFloat(originVal)
             contrastVal = parseFloat(contrastVal)
-          } catch {
+          } catch (e) {
             originVal = NaN
           }
   
@@ -120,7 +119,7 @@
         try {
           originVal = parseFloat(originVal)
           contrastVal = parseFloat(contrastVal)
-        } catch {
+        } catch (e) {
           originVal = NaN
         }
 
@@ -131,7 +130,7 @@
         try {
           originVal = parseFloat(originVal)
           contrastVal = parseFloat(contrastVal)
-        } catch {
+        } catch (e) {
           originVal = NaN
         }
 
@@ -191,7 +190,7 @@
           content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)} ${content.substr(11, 2)}:${content.substr(14, 2)}:${content.substr(17, 2)}`
         }
   
-        content = col.prefix + content + col.postfix
+        content = (col.prefix || '') + content + (col.postfix || '')
       }
 
       if (col.marks) {
@@ -223,7 +222,7 @@
         if (isNaN(content)) {
           content = ''
         }
-      } catch {
+      } catch (e) {
         content = ''
       }
 
@@ -275,6 +274,7 @@
 
       let cols = 24 / (col.picSort || 1)
       let paddingTop = '100%'
+      let scale = col.scale === 'true'
 
       if (PicRadio[col.lenWidRadio]) {
         paddingTop = PicRadio[col.lenWidRadio]
@@ -282,9 +282,12 @@
 
       resProps.children = (
         <div>
-          {photos.map((url, i) => (
+          {photos && photos.map((url, i) => (
             <Col key={i} span={cols}>
-              <div className="ant-mk-picture" style={{paddingTop, backgroundImage: `url('${url}')`}}></div>
+              <div className={'ant-mk-picture' + (scale ? ' scale' : '')} onClick={() => {
+                if (!scale) return
+                MKEmitter.emit('mkImageScale', url, photos)
+              }} style={{paddingTop, backgroundImage: `url('${url}')`}}></div>
             </Col>
           ))}
         </div>
@@ -328,7 +331,7 @@
         
         try {
           _param = window.btoa(_quary)
-        } catch {
+        } catch (e) {
           _param = window.btoa(window.encodeURIComponent(_quary))
         }
         
@@ -350,6 +353,10 @@
       )
     } else if (col.type === 'custom') {
       style.padding = '0px'
+      if (col.style) {
+        style = {...style, ...col.style}
+      }
+
       resProps.children = (
         <CardCellComponent data={record} cards={config} elements={col.elements}/>
       )
@@ -423,7 +430,10 @@
           if (item.rowspan === 'true') {
             rowspans.push(item.field)
           }
-          if (_format && !Math.floor(Math.random() * radio)) {
+          if (item.type === 'index') {
+            item.field = '$Index'
+            item.type = 'text'
+          } else if (_format && !Math.floor(Math.random() * radio)) {
             item.blur = true
           }
   
@@ -489,6 +499,8 @@
   }
 
   componentDidMount () {
+    MKEmitter.addListener('mkCheckTopLine', this.mkCheckTopLine)
+    MKEmitter.addListener('mkCheckAll', this.mkCheckAll)
     MKEmitter.addListener('resetTable', this.resetTable)
   }
 
@@ -499,12 +511,58 @@
     this.setState = () => {
       return
     }
+    MKEmitter.removeListener('mkCheckTopLine', this.mkCheckTopLine)
+    MKEmitter.removeListener('mkCheckAll', this.mkCheckAll)
     MKEmitter.removeListener('resetTable', this.resetTable)
+  }
+
+  mkCheckTopLine = (menuId) => {
+    const { MenuID, data, setting } = this.props
+
+    if (MenuID !== menuId || !data || data.length === 0) return
+
+    this.changedata(0)
+    this.setState({ selectedRowKeys: [0], activeIndex: 0 })
+    this.props.chgSelectData([data[0]])
+
+    if (setting.$hasSyncModule) {
+      MKEmitter.emit('syncBalconyData', MenuID, [data[0]], data.length === 1)
+    }
+  }
+
+  mkCheckAll = (menuId, checked) => {
+    const { MenuID, data } = this.props
+
+    if (MenuID !== menuId) return
+
+    if (checked) {
+      this.setState({
+        activeIndex: '',
+        selectedRowKeys: data.map((item, index) => index)
+      })
+
+      this.props.chgSelectData(data)
+
+      MKEmitter.emit('resetSelectLine', MenuID, '', '')
+      MKEmitter.emit('syncBalconyData', MenuID, data, data.length > 0)
+      if (data.length === 0) {
+        message.warning('鏈幏鍙栧埌鏁版嵁锛�')
+      }
+    } else {
+      this.setState({
+        activeIndex: '',
+        selectedRowKeys: [],
+      })
+
+      this.props.chgSelectData([])
+  
+      MKEmitter.emit('resetSelectLine', MenuID, '', '')
+      MKEmitter.emit('syncBalconyData', MenuID, [], false)
+    }
   }
 
   // 瀛楁閫忚
   triggerLink = (e, item, record) => {
-    const { tabviews } = this.props
     e.stopPropagation()
 
     let __param = {
@@ -523,21 +581,12 @@
       let tabmenu = item.linkThdMenu
 
       tabmenu.param = __param
-      tabmenu.selected = true
-  
-      let tabs = tabviews.filter((tab, i) => {
-        tab.selected = false
-        return tab.MenuID !== tabmenu.MenuID
-      })
-  
-      if (tabviews.length > tabs.length) {
-        this.props.modifyTabview(fromJS(tabs).toJS())
+
+      if (['linkage_navigation', 'linkage', 'menu_board'].includes(window.GLOB.navBar)) {
+        MKEmitter.emit('modifyTabs', tabmenu, 'replace')
+      } else {
+        MKEmitter.emit('modifyTabs', tabmenu, 'plus', true)
       }
-  
-      this.setState({}, () => {
-        tabs.push(tabmenu)
-        this.props.modifyTabview(tabs)
-      })
     } else if (item.linkurl) {
       let src = item.linkurl
 
@@ -550,7 +599,7 @@
           _param.User_Name = sessionStorage.getItem('User_Name')
           _param.param = __param
           src = _url + window.btoa(window.encodeURIComponent(JSON.stringify(_param)))
-        } catch {
+        } catch (e) {
           console.warn('鑿滃崟鍙傛暟瑙f瀽閿欒锛�')
         }
       } else {
@@ -578,7 +627,7 @@
    * 
    */
   onSelectChange = selectedRowKeys => {
-    const { setting } = this.props
+    const { setting, MenuID, data } = this.props
 
     let index = ''
     let _activeIndex = null
@@ -597,13 +646,16 @@
     let selects = this.props.data.filter((item, _index) => selectedRowKeys.includes(_index))
 
     this.props.chgSelectData(selects)
+    if (setting.$hasSyncModule) {
+      MKEmitter.emit('syncBalconyData', MenuID, selects, data.length === selects.length)
+    }
   }
 
   /**
    * @description 鐐瑰嚮鏁磋锛岃Е鍙戝垏鎹紝 鍒ゆ柇鏄惁鍙�夛紝鍗曢�夋垨澶氶�夛紝杩涜瀵瑰簲鎿嶄綔
    */
   changeRow = (record, index) => {
-    const { setting } = this.props
+    const { setting, MenuID, data } = this.props
 
     if (!setting.tableType || this.state.pickup) return
     
@@ -633,6 +685,10 @@
     let selects = this.props.data.filter((item, _index) => newkeys.includes(_index))
     
     this.props.chgSelectData(selects)
+
+    if (setting.$hasSyncModule) {
+      MKEmitter.emit('syncBalconyData', MenuID, selects, data.length === selects.length)
+    }
   }
 
   changeTable = (pagination, filters, sorter) => {
@@ -802,20 +858,23 @@
       _footer = statFValue.map(f => `${f.label}(鍚堣)锛�${f.value}`).join('锛�')
     }
 
+    let height = setting.height || false
+
     return (
-      <div className={'normal-custom-table ' + setting.tableHeader} id={tableId}>
+      <div className={`normal-custom-table ${setting.tableHeader || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''}`} 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
+          <Switch title="鏀惰捣" className="main-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" checked={pickup} onChange={this.pickupChange} /> : null
         }
         <Table
           components={components}
+          style={setting.style}
           size={setting.size || 'middle'}
           bordered={setting.bordered !== 'false'}
           rowSelection={rowSelection}
           columns={this.state.columns}
           dataSource={_data}
           loading={this.props.loading}
-          scroll={{ x: '100%', y: false }}
+          scroll={{ x: '100%', y: height }}
           onRow={(record, index) => {
             return {
               lineMarks,
@@ -837,15 +896,12 @@
 const mapStateToProps = (state) => {
   return {
     menuType: state.editLevel,
-    tabviews: state.tabviews,
     memberLevel: state.memberLevel
   }
 }
 
-const mapDispatchToProps = (dispatch) => {
-  return {
-    modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews))
-  }
+const mapDispatchToProps = () => {
+  return {}
 }
 
 export default connect(mapStateToProps, mapDispatchToProps)(NormalTable)
\ No newline at end of file

--
Gitblit v1.8.0