king
2019-10-15 ee32a69f9a7f25c37757325dc28ac7b5127dceca
src/tabviews/datamanage/modules/table/index.jsx
@@ -1,6 +1,5 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
// import { is, fromJS } from 'immutable'
import { Table, message, Affix } from 'antd'
import './index.scss'
@@ -23,17 +22,22 @@
    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'}})
@@ -59,22 +63,17 @@
  }
  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) => {
@@ -127,6 +126,7 @@
          />
        </Affix>}
        <Table
          className={this.state.fixed ? 'fixed' : ''}
          bordered={true}
          rowSelection={rowSelection}
          size="middle"