| | |
| | | import { Table, message, Affix, Button, Typography, Modal, Icon } from 'antd' |
| | | |
| | | import { modifyTabview } from '@/store/action' |
| | | import './index.scss' |
| | | import '@/assets/css/table.scss' |
| | | import './index.scss' |
| | | |
| | | const { Paragraph } = Typography |
| | | |
| | |
| | | imgShow: false, // 图片放大模态框 |
| | | imgSrc: '', // 图片路径 |
| | | lineMarks: null, // 行标记 |
| | | colMap: null // 列信息(全部) |
| | | colMap: null, // 列信息(全部) |
| | | activeIndex: null // 标记当前选中行 |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | let icon = '' |
| | | |
| | | marks.some(mark => { |
| | | let originType = colMap.get(mark.field).type |
| | | let originField = colMap.get(mark.field) |
| | | |
| | | if (!originField) return false |
| | | |
| | | let originType = originField.type || 'text' |
| | | |
| | | let originVal = record.hasOwnProperty(mark.field) ? record[mark.field] : '' |
| | | let contrastVal = '' |
| | |
| | | if (originVal === '' || contrastVal === '') return false |
| | | |
| | | if (mark.match === '=' && originVal === contrastVal) { |
| | | className = mark.color[1] |
| | | } else if (mark.match === '!=' && originVal !== contrastVal) { |
| | | className = mark.color[1] |
| | | } else if (mark.match === 'like' && originVal.indexOf(contrastVal) > -1) { |
| | | className = mark.color[1] |
| | |
| | | if (item.field && record.hasOwnProperty(item.field)) { |
| | | content = `${record[item.field]}` |
| | | } |
| | | |
| | | content = content ? (item.prefix || '') + content + (item.postfix || '') : '' |
| | | |
| | | if (content !== '') { |
| | | if (item.format === 'YYYY-MM-DD' && /^[1-9]\d{3}(-|\/)(0[1-9]|1[0-2])(-|\/)(0[1-9]|[1-2][0-9]|3[0-1])/.test(content)) { |
| | | content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)}` |
| | | } else if (item.format === 'YYYY-MM-DD HH:mm:ss' && /^[1-9]\d{3}(-|\/)(0[1-9]|1[0-2])(-|\/)(0[1-9]|[1-2][0-9]|3[0-1]).([0-1][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]/.test(content)) { |
| | | content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)} ${content.substr(11, 2)}:${content.substr(14, 2)}:${content.substr(17, 2)}` |
| | | } |
| | | |
| | | content = (item.prefix || '') + content + (item.postfix || '') |
| | | } |
| | | |
| | | if (item.marks) { |
| | | let result = this.getMark(record, item.marks) |
| | | |
| | |
| | | |
| | | return ( |
| | | <div> |
| | | <div className="baseboard"></div> |
| | | <div className="content" style={{ minWidth: (item.Width || 120) + 'px' }}> |
| | | {content ? <Paragraph copyable ellipsis={{ rows: 3, expandable: true }}>{content}</Paragraph> : null } |
| | | </div> |
| | | </div> |
| | | ) |
| | | } else if (item.type === 'link') { |
| | | let content = '' |
| | | let _href = record[item.field] || '' |
| | | |
| | | if (item.nameField && record.hasOwnProperty(item.nameField)) { |
| | | content = record[item.nameField] |
| | | } |
| | | |
| | | if (!content && _href) { |
| | | content = _href |
| | | } else if (!_href) { |
| | | content = '' |
| | | } |
| | | |
| | | if (item.joint === 'true' && _href) { |
| | | let _quary = `id=${record[this.props.setting.primaryKey]}&userid=${sessionStorage.getItem('UserID')}&appkey=${window.GLOB.appkey}&LoginUID=${sessionStorage.getItem('LoginUID')}` |
| | | let _param = '' |
| | | |
| | | try { |
| | | _param = window.btoa(_quary) |
| | | } catch { |
| | | _param = window.btoa(window.encodeURIComponent(_quary)) |
| | | } |
| | | |
| | | _href += '?' + _param |
| | | } |
| | | |
| | | if (item.blur) { |
| | | content = md5(content) |
| | | } |
| | | |
| | | return ( |
| | | <div> |
| | | <div className="content" style={{ minWidth: (item.Width || 120) + 'px' }}> |
| | | {content ? <a href={_href} target="_blank" rel="noopener noreferrer">{content}</a> : null } |
| | | </div> |
| | | </div> |
| | | ) |
| | |
| | | let contents = [] |
| | | let images = [] |
| | | |
| | | item.subColumn.forEach(col => { |
| | | item.subColumn.forEach((col, index) => { |
| | | if (!col.field || !record.hasOwnProperty(col.field)) return |
| | | if (index) { |
| | | col.Align = 'right' |
| | | } |
| | | |
| | | if (col.type === 'number') { |
| | | let content = '' |
| | |
| | | } |
| | | |
| | | if (content !== '') { |
| | | if (item.format === 'percent') { |
| | | if (col.format === 'percent') { |
| | | content = content * 100 |
| | | } |
| | | |
| | |
| | | content = md5(content) |
| | | } |
| | | |
| | | contents.push(content) |
| | | contents.push({content, align: col.Align}) |
| | | } else if (col.type === 'picture') { |
| | | let photos = [] |
| | | try { |
| | |
| | | } |
| | | |
| | | photos.forEach(photo => { |
| | | images.push({url: photo, scale: col.scale === 'true', maxHeight: col.maxHeight || 128}) |
| | | images.push({url: photo, align: col.Align, scale: col.scale === 'true', maxHeight: col.maxHeight || 128}) |
| | | }) |
| | | } else if (col.type === 'text') { |
| | | let content = record[col.field] |
| | | |
| | | if (content !== '') { |
| | | if (col.format === 'YYYY-MM-DD' && /^[1-9]\d{3}(-|\/)(0[1-9]|1[0-2])(-|\/)(0[1-9]|[1-2][0-9]|3[0-1])/.test(content)) { |
| | | content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)}` |
| | | } else if (col.format === 'YYYY-MM-DD HH:mm:ss' && /^[1-9]\d{3}(-|\/)(0[1-9]|1[0-2])(-|\/)(0[1-9]|[1-2][0-9]|3[0-1]).([0-1][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]/.test(content)) { |
| | | content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)} ${content.substr(11, 2)}:${content.substr(14, 2)}:${content.substr(17, 2)}` |
| | | } |
| | | |
| | | content = (col.prefix || '') + record[col.field] + (col.postfix || '') |
| | | } |
| | | |
| | |
| | | content = md5(content) |
| | | } |
| | | |
| | | contents.push(content) |
| | | contents.push({content, align: col.Align}) |
| | | } else if (col.type === 'link') { |
| | | let content = col.nameField ? record[col.nameField] : '' |
| | | let _href = record[col.field] || '' |
| | | |
| | | if (!content && _href) { |
| | | content = _href |
| | | } else if (!_href) { |
| | | content = '' |
| | | } |
| | | |
| | | if (col.joint === 'true' && _href) { |
| | | let _quary = `id=${record[this.props.setting.primaryKey]}&userid=${sessionStorage.getItem('UserID')}&appkey=${window.GLOB.appkey}&LoginUID=${sessionStorage.getItem('LoginUID')}` |
| | | let _param = '' |
| | | |
| | | try { |
| | | _param = window.btoa(_quary) |
| | | } catch { |
| | | _param = window.btoa(window.encodeURIComponent(_quary)) |
| | | } |
| | | |
| | | _href += '?' + _param |
| | | } |
| | | |
| | | if (item.blur) { |
| | | content = md5(content) |
| | | } |
| | | |
| | | content = _href ? <a href={_href} target="_blank" rel="noopener noreferrer">{content}</a> : null |
| | | |
| | | contents.push({content, align: col.Align}) |
| | | } else { |
| | | let content = record[col.field] |
| | | |
| | |
| | | content = md5(content) |
| | | } |
| | | |
| | | contents.push(content) |
| | | contents.push({content, align: col.Align}) |
| | | } |
| | | }) |
| | | |
| | |
| | | |
| | | getCospanContent = (type, contents, images) => { |
| | | if (type === 'vertical') { |
| | | return contents.map((content, index) => { |
| | | return (<p key={index}>{content}</p>) |
| | | return contents.map((cont, index) => { |
| | | return (<p key={index} style={{textAlign: cont.align}}>{cont.content}</p>) |
| | | }) |
| | | } else if (type === 'horizontal') { |
| | | return contents.map((content, index) => { |
| | |
| | | return ( |
| | | <div className="content-fence"> |
| | | <div className="content-fence-left"> |
| | | {contents.map((content, index) => { |
| | | {contents.map((cont, index) => { |
| | | if (index % 2 === 0) { |
| | | return (<p key={index}>{content}</p>) |
| | | return (<p key={index} style={{textAlign: cont.align}}>{cont.content}</p>) |
| | | } else { |
| | | return '' |
| | | } |
| | | })} |
| | | </div> |
| | | <div className="content-fence-right"> |
| | | {contents.map((content, index) => { |
| | | {contents.map((cont, index) => { |
| | | if (index % 2 === 1) { |
| | | return (<p key={index}>{content}</p>) |
| | | return (<p key={index} style={{textAlign: cont.align}}>{cont.content}</p>) |
| | | } else { |
| | | return '' |
| | | } |
| | |
| | | } else if (type === 'topPicBottomText') { |
| | | return ( |
| | | <div className="content-fence"> |
| | | <div className="content-fence-top"> |
| | | <div className="content-fence-top" style={images[0] ? {textAlign: images[0].align} : null}> |
| | | {images.map((_img, index) => { |
| | | if (!_img.url) return '' |
| | | if (_img.scale) { |
| | |
| | | })} |
| | | </div> |
| | | <div className="content-fence-bottom"> |
| | | {contents.map((content, index) => { |
| | | return (<p key={index}>{content}</p>) |
| | | {contents.map((cont, index) => { |
| | | return (<p key={index} style={{textAlign: cont.align}}>{cont.content}</p>) |
| | | })} |
| | | </div> |
| | | </div> |
| | |
| | | } else if (type === 'leftPicRightText') { |
| | | return ( |
| | | <div className="content-fence"> |
| | | <div className="content-fence-left"> |
| | | <div className="content-fence-left" style={images[0] ? {textAlign: images[0].align} : null}> |
| | | {images.map((_img, index) => { |
| | | if (!_img.url) return '' |
| | | if (_img.scale) { |
| | |
| | | })} |
| | | </div> |
| | | <div className="content-fence-right"> |
| | | {contents.map((content, index) => { |
| | | return (<p key={index}>{content}</p>) |
| | | {contents.map((cont, index) => { |
| | | return (<p key={index} style={{textAlign: cont.align}}>{cont.content}</p>) |
| | | })} |
| | | </div> |
| | | </div> |
| | |
| | | * |
| | | */ |
| | | onSelectChange = selectedRowKeys => { |
| | | const { setting } = this.props |
| | | |
| | | let index = '' |
| | | let _activeIndex = null |
| | | if (selectedRowKeys.length > 0) { |
| | | index = selectedRowKeys[selectedRowKeys.length - 1] |
| | | } |
| | | |
| | | if (setting.tableType === 'checkbox') { |
| | | _activeIndex = index === '' ? null : index |
| | | } |
| | | |
| | | this.changedata(index) |
| | | |
| | | this.setState({ selectedRowKeys }) |
| | | this.setState({ selectedRowKeys, activeIndex: _activeIndex }) |
| | | |
| | | let selects = [] |
| | | selectedRowKeys.forEach(item => { |
| | | selects.push(this.props.data[item]) |
| | | }) |
| | | let selects = this.props.data.filter((item, _index) => selectedRowKeys.includes(_index)) |
| | | |
| | | // selectedRowKeys.forEach(item => { |
| | | // selects.push(this.props.data[item]) |
| | | // }) |
| | | |
| | | this.props.chgSelectData(selects) |
| | | } |
| | |
| | | this.changedata(index) |
| | | this.setState({ selectedRowKeys: newkeys }) |
| | | } else { |
| | | let _re = newkeys.includes(index) |
| | | if (_re) { |
| | | let _index = '' |
| | | if (newkeys.includes(index)) { |
| | | newkeys = newkeys.filter(item => item !== index) |
| | | this.changedata('') |
| | | if (newkeys.length > 0) { |
| | | _index = newkeys[newkeys.length - 1] |
| | | } |
| | | this.changedata(_index) |
| | | } else { |
| | | _index = index |
| | | newkeys.push(index) |
| | | this.changedata(index) |
| | | } |
| | | |
| | | this.setState({ selectedRowKeys: newkeys }) |
| | | this.setState({ selectedRowKeys: newkeys, activeIndex: _index !== '' ? _index : null }) |
| | | } |
| | | |
| | | let selects = [] |
| | | newkeys.forEach(item => { |
| | | selects.push(this.props.data[item]) |
| | | }) |
| | | let selects = this.props.data.filter((item, _index) => newkeys.includes(_index)) |
| | | // newkeys.forEach(item => { |
| | | // selects.push(this.props.data[item]) |
| | | // }) |
| | | |
| | | this.props.chgSelectData(selects) |
| | | } |
| | |
| | | this.setState({ |
| | | pageIndex: pagination.current, |
| | | pageSize: pagination.pageSize, |
| | | selectedRowKeys: [] |
| | | selectedRowKeys: [], |
| | | activeIndex: null |
| | | }) |
| | | this.props.refreshdata(pagination, filters, sorter) |
| | | } |
| | |
| | | resetTable = () => { |
| | | this.setState({ |
| | | pageIndex: 1, |
| | | selectedRowKeys: [] |
| | | selectedRowKeys: [], |
| | | activeIndex: null |
| | | }) |
| | | } |
| | | |
| | | render() { |
| | | const { setting, pickup } = this.props |
| | | const { selectedRowKeys, lineMarks, colMap } = this.state |
| | | const { selectedRowKeys, lineMarks, colMap, activeIndex } = this.state |
| | | |
| | | // 设置表格选择属性:单选、多选、不可选 |
| | | let rowSelection = null |
| | |
| | | columns={this.state.columns} |
| | | dataSource={_data} |
| | | rowClassName={(record) => { |
| | | if (lineMarks.length === 0) return '' |
| | | |
| | | let className = '' |
| | | if (setting.tableType === 'checkbox' && record.key === activeIndex) { |
| | | className = 'mk-row-active ' |
| | | } |
| | | |
| | | if (lineMarks.length === 0) return className |
| | | |
| | | lineMarks.some(mark => { |
| | | let originType = colMap.get(mark.field).type |
| | |
| | | |
| | | if (mark.match === '=' && originVal === contrastVal) { |
| | | className = 'background ' + mark.color[1] |
| | | } else if (mark.match === '!=' && originVal !== contrastVal) { |
| | | className = 'background ' + mark.color[1] |
| | | } else if (mark.match === 'like' && originVal.indexOf(contrastVal) > -1) { |
| | | className = 'background ' + mark.color[1] |
| | | } else if (mark.match === '>' && originVal > contrastVal) { |