From 2404d8a1bed5509432652f11aba6a1efa04aa160 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 18 九月 2020 19:24:26 +0800 Subject: [PATCH] 2020-09-18 --- src/tabviews/zshare/normalTable/index.jsx | 125 +++++++++++++++++++++++++++++++++++++---- 1 files changed, 112 insertions(+), 13 deletions(-) diff --git a/src/tabviews/zshare/normalTable/index.jsx b/src/tabviews/zshare/normalTable/index.jsx index d5b303d..e207ef6 100644 --- a/src/tabviews/zshare/normalTable/index.jsx +++ b/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,17 +114,45 @@ } } - let cell = { - align: item.Align, - dataIndex: item.field || item.uuid, - title: item.label, - sorter: item.field && item.IsSort === 'true', - width: item.Width || 120, - render: (text, record) => { - return this.getContent(item, record) + 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, + sorter: item.field && item.IsSort === 'true', + width: item.Width || 120, + render: (text, record) => { + return this.getContent(item, record) + } } } - + if (item.fixed === true || item.fixed === 'true') { if (index < columns.length / 2) { cell.fixed = 'left' @@ -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} -- Gitblit v1.8.0