| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | // import { is, fromJS } from 'immutable' |
| | | import { Table, Icon, message, Affix } from 'antd' |
| | | import { Table, message, Affix } from 'antd' |
| | | import './index.scss' |
| | | |
| | | export default class MainTable extends Component { |
| | | static propTpyes = { |
| | | MenuNo: PropTypes.string, // 菜单参数 |
| | | fixed: PropTypes.object, // 表格头部是否固定于页面上方 |
| | | MenuID: PropTypes.string, // 菜单参数 |
| | | setting: PropTypes.object, // 表格头部是否固定于页面上方 |
| | | loading: PropTypes.bool, |
| | | total: PropTypes.number, |
| | | select: PropTypes.object, |
| | |
| | | pageIndex: 1, |
| | | pageSize: 10, |
| | | columns: this.props.columns.map((item, index) => { |
| | | let _width = parseInt(item.Width) || 50 |
| | | return { |
| | | align: item.Align, |
| | | dataIndex: item.FieldName, |
| | | title: item.Label, |
| | | dataIndex: item.field, |
| | | title: item.label, |
| | | // fixed: index < 3, |
| | | sorter: item.IsSort === 'true', |
| | | filterMultiple: item.CDefine1 === 'true', |
| | | filters: item.CDefine2 && JSON.parse(item.CDefine2), |
| | | width: _width * 30, |
| | | width: item.Width || 120, |
| | | render: (text, record) => ( |
| | | <div style={{ wordWrap: 'break-word', wordBreak: 'break-word', minWidth: _width + 'px' }}> |
| | | <div style={{ wordWrap: 'break-word', wordBreak: 'break-word', minWidth: (item.Width || 120) + 'px' }}> |
| | | {text} |
| | | {item.FieldName === 'MenuNo' ? <Icon onClick={(e) => {this.copycontent(e, record[item.FieldName])}} type="copy"/> : ''} |
| | | {/* {item.FieldName === 'MenuNo' ? <Icon onClick={(e) => {this.copycontent(e, record[item.FieldName])}} type="copy"/> : ''} */} |
| | | </div> |
| | | ) |
| | | // onHeaderCell: () => ({style:{textAlign: 'center'}}) |
| | | } |
| | | }) |
| | | } |
| | |
| | | |
| | | render() { |
| | | let { selectedRowKeys } = this.state |
| | | |
| | | let rowSelection = null |
| | | if (this.props.select && this.props.select.selectable) { |
| | | if (this.props.setting.tableType) { |
| | | rowSelection = { |
| | | selectedRowKeys, |
| | | type: this.props.select.selectType === 'radio' ? 'radio' : 'checkbox', |
| | | type: this.props.setting.tableType === 'radio' ? 'radio' : 'checkbox', |
| | | onChange: this.onSelectChange |
| | | } |
| | | } |
| | | let offset = null |
| | | if (this.props.fixed.fixtable) { |
| | | if (this.props.setting.columnfixed) { |
| | | // 表格头部固定于顶部时,判断距顶部高度 |
| | | if (!this.props.fixed.fixaction) { |
| | | if (!this.props.setting.actionfixed) { |
| | | offset = 48 |
| | | } else { |
| | | let box = document.getElementById(this.props.MenuNo + 'mainaction') |
| | | let box = document.getElementById(this.props.MenuID + 'mainaction') |
| | | if (box) { |
| | | offset = 48 + box.offsetHeight |
| | | } else { |
| | |
| | | } |
| | | return ( |
| | | <div className="main-table"> |
| | | {this.props.fixed.fixtable && <Affix offsetTop={offset} className="fix-header"> |
| | | {this.props.setting.columnfixed && <Affix offsetTop={offset} className="fix-header"> |
| | | <Table |
| | | bordered={true} |
| | | rowSelection={rowSelection} |