king
2020-09-18 2404d8a1bed5509432652f11aba6a1efa04aa160
src/tabviews/zshare/normalTable/index.jsx
@@ -5,6 +5,7 @@
import {connect} from 'react-redux'
import { Table, message, Affix, Button, Typography, Modal, Icon } from 'antd'
import Utils from '@/utils/utils.js'
import { modifyTabview } from '@/store/action'
import '@/assets/css/table.scss'
import './index.scss'
@@ -19,6 +20,7 @@
  static propTpyes = {
    tableId: PropTypes.string,     // 列表Id
    resetTable: PropTypes.bool,    // 表格重置
    statFValue: PropTypes.any,     // 合计字段数据
    pageSize: PropTypes.any,       // 每页数据
    dict: PropTypes.object,        // 字典项
    config: PropTypes.object,      // 页面配置
@@ -44,7 +46,8 @@
    imgSrc: '',           // 图片路径
    lineMarks: null,      // 行标记
    colMap: null,         // 列信息(全部)
    activeIndex: null     // 标记当前选中行
    activeIndex: null,    // 标记当前选中行
    rowspan: null         // 行合并字段信息
  }
  UNSAFE_componentWillMount () {
@@ -55,6 +58,7 @@
    let colMap = new Map() // 用于获取字段信息
    let radio = 5          // 虚化比例
    let _format = false    // 是否虚化处理
    let rowspan = null
    if (window.GLOB.dataFormat && menuType !== 'HS' && memberLevel) {
      _format = true
@@ -110,7 +114,34 @@
        }
      }
      let cell = {
      let cell = null
      if (item.type === 'colspan' && item.unfold === 'true') {
        cell = {title: item.label, children: []}
        item.subColumn.forEach(col => {
          if (col.rowspan === 'true') {
            rowspan = col
          }
          cell.children.push({
            align: col.Align,
            title: col.label,
            dataIndex: col.field || col.uuid,
            key: col.uuid,
            width: col.Width || 120,
            render: (text, record) => {
              return this.getContent(col, record)
            }
          })
        })
      } else {
        if (item.rowspan === 'true') {
          rowspan = item
        }
        cell = {
        align: item.Align,
        dataIndex: item.field || item.uuid,
        title: item.label,
@@ -118,6 +149,7 @@
        width: item.Width || 120,
        render: (text, record) => {
          return this.getContent(item, record)
          }
        }
      }
@@ -136,7 +168,8 @@
      columns: _columns,
      pageSize: pageSize ? pageSize : 10,
      lineMarks: lineMarks,
      colMap: colMap
      colMap: colMap,
      rowspan: rowspan
    })
  }
@@ -330,6 +363,21 @@
      }
      if (item.linkThdMenu) {
        if (item.rowspan === 'true') {
          return {
            children: (
              <div className={className}>
                <div className="baseboard link-menu" onDoubleClick={() => this.triggerLink(item, record)}></div>
                <div className="content link-menu" style={{ minWidth: (item.Width || 120) + 'px' }} onDoubleClick={() => this.triggerLink(item, record)}>
                  {content}
                </div>
              </div>
            ),
            props: {
              rowSpan: record.$$rowspan,
            }
          }
        }
        return (
          <div className={className}>
            <div className="baseboard link-menu" onDoubleClick={() => this.triggerLink(item, record)}></div>
@@ -339,6 +387,21 @@
          </div>
        )
      } else {
        if (item.rowspan === 'true') {
          return {
            children: (
              <div className={className}>
                <div className="baseboard"></div>
                <div className="content" style={{ minWidth: (item.Width || 120) + 'px' }}>
                  {content}
                </div>
              </div>
            ),
            props: {
              rowSpan: record.$$rowspan,
            }
          }
        }
        return (
          <div className={className}>
            <div className="baseboard"></div>
@@ -872,8 +935,8 @@
  }
  render() {
    const { setting, pickup } = this.props
    const { selectedRowKeys, lineMarks, colMap, activeIndex } = this.state
    const { setting, pickup, statFValue } = this.props
    const { selectedRowKeys, lineMarks, colMap, activeIndex, rowspan } = this.state
    // 设置表格选择属性:单选、多选、不可选
    let rowSelection = null
@@ -907,6 +970,35 @@
      _data = _data.filter((item, index) => selectedRowKeys.includes(index))
    }
    if (rowspan) {
      let marks = {}
      let premark = {val: '', mark: ''}
      _data = _data.map(item => {
        if (item[rowspan.field]) {
          if (item[rowspan.field] !== premark.val) {
            premark = {val: item[rowspan.field], mark: Utils.getuuid()}
            marks[premark.mark] = 1
            item.$$mark = premark.mark
          } else {
            marks[premark.mark]++
            item.$$mark = premark.mark
          }
        } else {
          item.$$rowspan = 1
        }
        return item
      })
      _data = _data.map(item => {
        if (item.$$mark) {
          item.$$rowspan = marks[item.$$mark]
          marks[item.$$mark] = 0
        }
        return item
      })
    }
    let _pagination = false
    if (setting.laypage !== 'false') {
      _pagination = {
@@ -917,6 +1009,12 @@
        total: this.props.total,
        showTotal: (total, range) => `${range[0]}-${range[1]} ${this.props.dict['main.pagination.of']} ${total} ${this.props.dict['main.pagination.items']}`
      }
    }
    let _footer = ''
    if (statFValue && statFValue.length > 0) {
      _footer = statFValue.map(f => `${f.label}(合计):${f.value}`).join(';')
    }
    return (
@@ -1006,6 +1104,7 @@
          onChange={this.changeTable}
          pagination={_pagination}
        />
        {_footer ? <div className={'normal-table-footer ' + (_pagination ? 'pagination' : '')}>{_footer}</div> : null}
        <Modal
          className="image-scale-modal"
          visible={this.state.imgShow}