| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | // import { is, fromJS } from 'immutable' |
| | | import { Table, message, Affix } from 'antd' |
| | | import { Table, message, Affix, Button } from 'antd' |
| | | import './index.scss' |
| | | |
| | | export default class MainTable extends Component { |
| | |
| | | sorter: item.field && item.IsSort === 'true', |
| | | width: item.Width || 120, |
| | | render: (text, record) => { |
| | | let content = '' |
| | | if (item.field) { |
| | | content = record[item.field] || '' |
| | | } |
| | | return ( |
| | | <div className="content" style={{ minWidth: (item.Width || 120) + 'px' }}> |
| | | {content} |
| | | </div> |
| | | ) |
| | | return this.getContent(item, record) |
| | | // let content = '' |
| | | // if (item.field) { |
| | | // content = record[item.field] || '' |
| | | // } |
| | | // return ( |
| | | // <div className="content" style={{ minWidth: (item.Width || 120) + 'px' }}> |
| | | // {content} |
| | | // </div> |
| | | // ) |
| | | } |
| | | } |
| | | _columns.push(cell) |
| | |
| | | this.setState({columns: _columns}) |
| | | } |
| | | |
| | | getContent = (item, record) => { |
| | | if (item.type === 'operation') { |
| | | return ( |
| | | <div className={item.style} style={{ minWidth: (item.Width || 120) + 'px' }}> |
| | | {item.operations.map(btn => { |
| | | return <Button |
| | | className={'mk-btn mk-' + btn.class} |
| | | icon={btn.icon} |
| | | key={btn.uuid} |
| | | onClick={(e) => {this.actionTrigger(e, btn, record)}} |
| | | >{btn.label}</Button> |
| | | })} |
| | | </div> |
| | | ) |
| | | } else { |
| | | let content = '' |
| | | if (item.field) { |
| | | content = record[item.field] || '' |
| | | } |
| | | return ( |
| | | // <div className="content" style={{ minWidth: (item.Width || 120) + 'px' }}> |
| | | <div> |
| | | <div className={'background'}></div> |
| | | <div className="content" style={{ minWidth: (item.Width || 120) + 'px' }}> |
| | | {content} |
| | | </div> |
| | | </div> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | actionTrigger = (e, btn, record) => { |
| | | e.stopPropagation() |
| | | console.log(btn) |
| | | console.log(record) |
| | | } |
| | | |
| | | copycontent = (e, content) => { |
| | | // 表格中内容复制 |
| | | e.stopPropagation() |