| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | // import { is, fromJS } from 'immutable' |
| | | import { Table, message, Affix } from 'antd' |
| | | import './index.scss' |
| | | |
| | |
| | | selectedRowKeys: [], |
| | | pageIndex: 1, |
| | | pageSize: 10, |
| | | columns: this.props.columns.map((item, index) => { |
| | | columns: this.props.columns.map(item => { |
| | | let _width = parseInt(item.Width) || 50 |
| | | // if (/ID$/.test(item.FieldName) || item.FieldName.includes('PassWord')) { |
| | | // _width = _width * 3 |
| | | // } else if (item.FieldName.includes('Date')) { |
| | | // _width = _width * 2 |
| | | // } |
| | | return { |
| | | align: item.Align, |
| | | dataIndex: item.FieldName, |
| | | title: item.Label, |
| | | sorter: item.IsSort === 'true', |
| | | width: _width, |
| | | render: (text, record) => ( |
| | | render: (text) => ( |
| | | <div style={{ wordWrap: 'break-word', wordBreak: 'break-word', minWidth: _width + 'px' }}> |
| | | {item.Type === 'image' ? text : text} |
| | | {item.Type === 'Image' ? <img width={_width * 0.9} src={text} alt={text}/> : text} |
| | | </div> |
| | | ) |
| | | // onHeaderCell: () => ({style:{textAlign: 'center'}}) |
| | |
| | | } |
| | | |
| | | changeRow = (record, index) => { |
| | | // 点击整行,触发切换,判断是否可选,单选或多选,进行对应操作 |
| | | if (!this.props.select || !this.props.select.selectable) return |
| | | // 点击整行,触发切换,判断是否可选,进行对应操作 |
| | | if (!this.props.selectable) return |
| | | |
| | | let newkeys = JSON.parse(JSON.stringify(this.state.selectedRowKeys)) |
| | | let _re = newkeys.includes(index) |
| | | |
| | | if (this.props.select.selectType === 'radio') { |
| | | this.setState({ selectedRowKeys: [index] }) |
| | | } else { |
| | | if (_re) { |
| | | if (newkeys.includes(index)) { |
| | | newkeys = newkeys.filter(item => item !== index) |
| | | } else { |
| | | newkeys.push(index) |
| | | } |
| | | this.setState({ selectedRowKeys: newkeys }) |
| | | } |
| | | } |
| | | |
| | | changeTable = (pagination, filters, sorter) => { |
| | |
| | | /> |
| | | </Affix>} |
| | | <Table |
| | | className={this.state.fixed ? 'fixed' : ''} |
| | | bordered={true} |
| | | rowSelection={rowSelection} |
| | | size="middle" |