From 1f6d49bf15e6b50eeee1edc32022eb006b401835 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 08 二月 2023 00:35:55 +0800 Subject: [PATCH] 2023-02-08 --- src/tabviews/zshare/normalTable/index.jsx | 127 +++++++++++++++++++----------------------- 1 files changed, 57 insertions(+), 70 deletions(-) diff --git a/src/tabviews/zshare/normalTable/index.jsx b/src/tabviews/zshare/normalTable/index.jsx index 259b6c7..e08b2cb 100644 --- a/src/tabviews/zshare/normalTable/index.jsx +++ b/src/tabviews/zshare/normalTable/index.jsx @@ -2,7 +2,7 @@ import PropTypes from 'prop-types' import md5 from 'md5' import { is, fromJS } from 'immutable' -import { Table, Affix, Typography } from 'antd' +import { Table, Typography, Col } from 'antd' import asyncComponent from '@/utils/asyncComponent' import MKEmitter from '@/utils/events.js' @@ -17,6 +17,14 @@ const PopupButton = asyncComponent(() => import('@/tabviews/zshare/actionList/popupbutton')) const TabButton = asyncComponent(() => import('@/tabviews/zshare/actionList/tabbutton')) const NewPageButton = asyncComponent(() => import('@/tabviews/zshare/actionList/newpagebutton')) +const Video = asyncComponent(() => import('@/components/video')) +const MkPicture = asyncComponent(() => import('@/components/mkPicture')) + +const PicRadio = { + '4:3': '75%', '3:2': '66.67%', '16:9': '56.25%', '2:1': '50%', '3:1': '33.33%', '4:1': '25%', + '5:1': '20%', '6:1': '16.67%', '7:1': '14.29%', '8:1': '12.5%', '9:1': '11.11%', + '10:1': '10%', '3:4': '133.33%', '2:3': '150%', '9:16': '177.78%' +} class BodyRow extends React.Component { shouldComponentUpdate (nextProps) { @@ -40,7 +48,6 @@ pickup: PropTypes.any, // 鏁版嵁鏀惰捣 columns: PropTypes.array, // 琛ㄦ牸鍒� fields: PropTypes.array, // 缁勪欢瀛楁闆� - ContainerId: PropTypes.any, // 鏍囩椤靛灞侷d BData: PropTypes.any, // 涓昏〃鏁版嵁 data: PropTypes.any, // 琛ㄦ牸鏁版嵁 total: PropTypes.any, // 鎬绘暟 @@ -353,11 +360,7 @@ let tabmenu = item.linkThdMenu tabmenu.param = __param - if (['linkage_navigation', 'linkage', 'menu_board'].includes(window.GLOB.navBar)) { - MKEmitter.emit('modifyTabs', tabmenu, 'replace') - } else { - MKEmitter.emit('modifyTabs', tabmenu, 'plus', true) - } + MKEmitter.emit('modifyTabs', tabmenu, true) } else if (item.linkurl) { let src = item.linkurl @@ -547,13 +550,13 @@ } if (content !== '') { - let decimal = item.decimal || 0 + content = Math.round(content * item.round) / item.round + if (item.format === 'percent') { content = content * 100 - decimal = decimal > 2 ? decimal - 2 : 0 } - - content = content.toFixed(decimal) + + content = content.toFixed(item.decimal) if (item.format === 'thdSeparator') { content = content.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') @@ -632,6 +635,7 @@ } } else if (item.type === 'picture') { let photos = '' + let style = {borderRadius: '2px'} if (item.field && record.hasOwnProperty(item.field)) { photos = record[item.field] + '' } @@ -641,19 +645,35 @@ photos = photos.split(',').filter(Boolean) } - let maxHeight = item.maxHeight || 128 + if (PicRadio[item.lenWidRadio]) { + style.paddingTop = PicRadio[item.lenWidRadio] + } else { + style.paddingTop = '100%' + } + + let scale = item.scale === 'true' + return ( <div className="picture-col"> - {photos && photos.map((url, i) => { - if (item.scale === 'true') { - return <img style={{maxHeight: maxHeight}} className="image-scale" onClick={(e) => { - e.stopPropagation() - MKEmitter.emit('mkImageScale', url, photos) - }} key={`${i}`} src={url} alt=""/> - } else { - return <img style={{maxHeight: maxHeight}} key={`${i}`} src={url} alt=""/> - } - })} + {photos.map((url, i) => (<Col key={i} span={item.span || 24}> + <MkPicture style={style} scale={scale} url={url} urls={photos}/> + </Col>))} + </div> + ) + } else if (item.type === 'video') { + let url = '' + if (item.field && record.hasOwnProperty(item.field)) { + url = record[item.field] + '' + } + + if (!url) { + return ( + <div className="video-wrap"></div> + ) + } + return ( + <div className="video-wrap"> + <Video card={item} value={url}/> </div> ) } else if (item.type === 'textarea') { @@ -733,7 +753,6 @@ BData={this.props.BData} setting={this.props.setting} columns={this.props.fields || this.props.columns} - ContainerId={this.props.ContainerId} /> ) } else if (btn.OpenType === 'popview') { @@ -755,9 +774,9 @@ btn={btn} disabled={record.$disabled} selectedData={[record]} + BID={record.$$BID} BData={this.props.BData} MenuID={this.props.MenuID} - setting={this.props.setting} /> ) } else if (btn.OpenType === 'innerpage' || btn.OpenType === 'outerpage') { @@ -768,7 +787,6 @@ disabled={record.$disabled} selectedData={[record]} BData={this.props.BData} - setting={this.props.setting} /> ) } @@ -797,13 +815,13 @@ } if (content !== '') { - let decimal = col.decimal || 0 + content = Math.round(content * col.round) / col.round + if (col.format === 'percent') { content = content * 100 - decimal = decimal > 2 ? decimal - 2 : 0 } - content = content.toFixed(decimal) + content = content.toFixed(col.decimal) if (col.format === 'thdSeparator') { content = content.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') @@ -846,7 +864,7 @@ } photos.forEach(photo => { - images.push({url: photo, align: col.Align, scale: col.scale === 'true', maxHeight: col.maxHeight || 128}) + images.push({url: photo, align: col.Align, scale: col.scale === 'true'}) }) } else if (col.type === 'text') { let content = record[col.field] @@ -985,12 +1003,12 @@ <div className="content-fence-top" style={images[0] ? {textAlign: images[0].align} : null}> {images.map((_img, index) => { if (_img.scale) { - return <img style={{maxHeight: _img.maxHeight}} className="image-scale" onClick={(e) => { + return <img className="image-scale" onClick={(e) => { e.stopPropagation() MKEmitter.emit('mkImageScale', _img.url, images.map(g => g.url)) }} key={`${index}`} src={_img.url} alt=""/> } else { - return (<img style={{maxHeight: _img.maxHeight}} key={`${index}`} src={_img.url} alt=""/>) + return (<img key={`${index}`} src={_img.url} alt=""/>) } })} </div> @@ -1007,11 +1025,11 @@ <div className="content-fence-left" style={images[0] ? {textAlign: images[0].align} : null}> {images.map((_img, index) => { if (_img.scale) { - return <img style={{maxHeight: _img.maxHeight}} className="image-scale" onClick={() => { + return <img className="image-scale" onClick={() => { MKEmitter.emit('mkImageScale', _img.url, images.map(g => g.url)) }} key={`${index}`} src={_img.url} alt=""/> } else { - return (<img style={{maxHeight: _img.maxHeight}} key={`${index}`} src={_img.url} alt=""/>) + return (<img key={`${index}`} src={_img.url} alt=""/>) } })} </div> @@ -1097,9 +1115,9 @@ } changedata = (index) => { - const { data, setting, tableId, ContainerId } = this.props + const { data, setting, tableId } = this.props - if (!tableId || !ContainerId) return + if (!tableId || !setting.ContainerId) return let _id = '' let _data = '' @@ -1109,7 +1127,7 @@ _data = data[index] || '' } - MKEmitter.emit('changeTableLine', ContainerId, tableId, _id, _data) + MKEmitter.emit('changeTableLine', setting.ContainerId, tableId, _id, _data) } resetTable = (id, repage) => { @@ -1196,7 +1214,7 @@ render() { const { setting, pickup, statFValue } = this.props - const { selectedRowKeys, lineMarks, activeIndex, pageOptions } = this.state + const { selectedRowKeys, lineMarks, activeIndex, pageOptions, columns } = this.state let components = { body: {} @@ -1213,21 +1231,6 @@ selectedRowKeys, type: (setting.tableType === 'radio') ? 'radio' : 'checkbox', onChange: this.onSelectChange - } - } - - // 琛ㄦ牸澶撮儴鍥哄畾浜庨《閮ㄦ椂锛屽垽鏂窛椤堕儴楂樺害 - let offset = null - if (this.props.tableId === 'mainTable' && setting.columnfixed) { - if (!setting.actionfixed) { - offset = 48 - } else { - let box = document.getElementById(this.props.MenuID + 'mainaction') - if (box) { - offset = 48 + box.offsetHeight - } else { - offset = 105 - } } } @@ -1273,30 +1276,14 @@ } return ( - <div className={'normal-data-table mingke-table ' + (height ? 'fixed-height' : '')}> - {offset && <Affix offsetTop={offset} className="fix-header"> - <Table - size={setting.size || 'middle'} - style={style} - bordered={setting.bordered !== 'false'} - rowSelection={rowSelection} - columns={this.state.columns.map(column => { - return { - align: column.align, - dataIndex: column.dataIndex, - title: column.title, - width: column.width - } - })} - /> - </Affix>} + <div className={'normal-data-table mingke-table ' + (height ? 'fixed-height' : '') + ` table-col-${columns.length}`}> <Table components={components} size={setting.size || 'middle'} style={style} bordered={setting.bordered !== 'false'} rowSelection={rowSelection} - columns={this.state.columns} + columns={columns} dataSource={_data} rowClassName={(record) => { let className = '' -- Gitblit v1.8.0