From 96455706619a0a2a96a836714e106f4c7a3bfd40 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 04 三月 2020 13:18:26 +0800 Subject: [PATCH] 2020-03-04 --- src/tabviews/subtable/subTable/index.jsx | 17 ++++++++++++++--- 1 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/tabviews/subtable/subTable/index.jsx b/src/tabviews/subtable/subTable/index.jsx index 6aea1fa..502df0d 100644 --- a/src/tabviews/subtable/subTable/index.jsx +++ b/src/tabviews/subtable/subTable/index.jsx @@ -1,5 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' +import { is, fromJS } from 'immutable' import { Table, message, Button, Typography } from 'antd' import './index.scss' @@ -16,7 +17,8 @@ loading: PropTypes.bool, // 琛ㄦ牸鍔犺浇涓� refreshdata: PropTypes.func, // 琛ㄦ牸涓帓搴忓垪銆侀〉鐮佺殑鍙樺寲鏃跺埛鏂� buttonTrigger: PropTypes.func, // 琛ㄦ牸涓寜閽Е鍙戞搷浣� - handleTableId: PropTypes.func // 鎺у埗琛ㄦ牸鏁版嵁鍒囨崲鏃讹紝鏇存柊鍦ㄤ富琛ㄤ腑鐨刬d + handleTableId: PropTypes.func, // 鎺у埗琛ㄦ牸鏁版嵁鍒囨崲鏃讹紝鏇存柊鍦ㄤ富琛ㄤ腑鐨刬d + pickup: PropTypes.any // 鏁版嵁灞曞紑鍚堝苟鎺у埗 } state = { @@ -142,7 +144,7 @@ <div className={match ? item.color : ''}> <div className="background"></div> <div className="content" style={{ minWidth: (item.Width || 120) + 'px' }}> - <Paragraph copyable ellipsis={{ rows: 3, expandable: true }}>{content}</Paragraph> + {content ? <Paragraph copyable ellipsis={{ rows: 3, expandable: true }}>{content}</Paragraph> : null} </div> </div> ) @@ -313,6 +315,10 @@ this.props.handleTableId(_id, _data) } + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + render() { let { selectedRowKeys } = this.state @@ -325,6 +331,11 @@ } } + let _data = this.props.data ? this.props.data : [] + if (this.props.pickup) { + _data = _data.filter((item, index) => selectedRowKeys.includes(index)) + } + return ( <div className="sub-table"> <Table @@ -332,7 +343,7 @@ bordered={true} rowSelection={rowSelection} columns={this.state.columns} - dataSource={this.props.data ? this.props.data : []} + dataSource={_data} loading={this.props.loading} scroll={{ x: '100%', y: false }} onRow={(record, index) => { -- Gitblit v1.8.0