| | |
| | | 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' |
| | |
| | | static propTpyes = { |
| | | tableId: PropTypes.string, // 列表Id |
| | | resetTable: PropTypes.bool, // 表格重置 |
| | | statFValue: PropTypes.any, // 合计字段数据 |
| | | pageSize: PropTypes.any, // 每页数据 |
| | | dict: PropTypes.object, // 字典项 |
| | | config: PropTypes.object, // 页面配置 |
| | |
| | | imgSrc: '', // 图片路径 |
| | | lineMarks: null, // 行标记 |
| | | colMap: null, // 列信息(全部) |
| | | activeIndex: null // 标记当前选中行 |
| | | activeIndex: null, // 标记当前选中行 |
| | | rowspan: null // 行合并字段信息 |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | let colMap = new Map() // 用于获取字段信息 |
| | | let radio = 5 // 虚化比例 |
| | | let _format = false // 是否虚化处理 |
| | | let rowspan = null |
| | | |
| | | if (window.GLOB.dataFormat && menuType !== 'HS' && memberLevel) { |
| | | _format = true |
| | |
| | | } |
| | | } |
| | | |
| | | 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, |
| | |
| | | width: item.Width || 120, |
| | | render: (text, record) => { |
| | | return this.getContent(item, record) |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | columns: _columns, |
| | | pageSize: pageSize ? pageSize : 10, |
| | | lineMarks: lineMarks, |
| | | colMap: colMap |
| | | colMap: colMap, |
| | | rowspan: rowspan |
| | | }) |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | 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> |
| | |
| | | </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> |
| | |
| | | } |
| | | |
| | | 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 |
| | |
| | | _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 = { |
| | |
| | | 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 ( |
| | |
| | | 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} |