king
2019-12-03 265102e3b6c9865f0e9f1e035e7b1aba281dc8c1
src/tabviews/commontable/mainTable/index.jsx
@@ -1,7 +1,7 @@
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 {
@@ -38,15 +38,16 @@
        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)
@@ -56,6 +57,43 @@
    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()