From f6626b05f1275cc2f8ca77f773d4f6a6af1b0a89 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 21 十一月 2022 16:11:55 +0800 Subject: [PATCH] 2022-11-21 --- src/tabviews/custom/components/share/normalTable/index.jsx | 188 ++++++++++++++++++++++++++++++++-------------- 1 files changed, 129 insertions(+), 59 deletions(-) diff --git a/src/tabviews/custom/components/share/normalTable/index.jsx b/src/tabviews/custom/components/share/normalTable/index.jsx index 0e98c31..09611a8 100644 --- a/src/tabviews/custom/components/share/normalTable/index.jsx +++ b/src/tabviews/custom/components/share/normalTable/index.jsx @@ -15,8 +15,9 @@ import './index.scss' const { Paragraph } = Typography -const CardCellComponent = asyncComponent(() => import('@/tabviews/custom/components/card/cardcellList')) +const Video = asyncComponent(() => import('@/components/video')) const MkPicture = asyncComponent(() => import('@/components/mkPicture')) +const CardCellComponent = asyncComponent(() => import('@/tabviews/custom/components/card/cardcellList')) 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%', @@ -24,7 +25,7 @@ } class BodyRow extends React.Component { shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.props.data), fromJS(nextProps.data)) || !is(fromJS(this.props.className), fromJS(nextProps.className)) + return !is(fromJS(this.props.data), fromJS(nextProps.data)) || this.props.className !== nextProps.className } render() { @@ -259,6 +260,14 @@ ))} </div> ) + } else if (col.type === 'video') { + let url = record[col.field] || '' + + resProps.children = ( + <div className="video-wrap"> + {url ? <Video card={col} value={url}/> : null} + </div> + ) } else if (col.type === 'textarea') { let content = '' if (record[col.field] !== undefined) { @@ -395,12 +404,12 @@ columns: PropTypes.array, // 琛ㄦ牸鍒� lineMarks: PropTypes.array, // 琛屾爣璁� fields: PropTypes.array, // 缁勪欢瀛楁闆� - ContainerId: PropTypes.any, // 鏍囩椤靛灞侷d data: PropTypes.any, // 琛ㄦ牸鏁版嵁 total: PropTypes.any, // 鎬绘暟 loading: PropTypes.bool, // 琛ㄦ牸鍔犺浇涓� refreshdata: PropTypes.func, // 琛ㄦ牸涓帓搴忓垪銆侀〉鐮佺殑鍙樺寲鏃跺埛鏂� chgSelectData: PropTypes.func, // 鏁版嵁鍒囨崲 + autoMatic: PropTypes.any } state = { @@ -434,52 +443,69 @@ } } - let getColumns = (cols) => { - return cols.map(item => { - let cell = null - - if (item.type === 'colspan') { - cell = { title: item.label, align: item.Align } - cell.children = getColumns(item.subcols) - } else { - if (item.rowspan === 'true') { - rowspans.push(item.field) - } - if (item.type === 'index') { - item.field = '$Index' - item.type = 'text' - } else if (_format && !Math.floor(Math.random() * radio)) { - item.blur = true - } - - if (item.marks && item.marks.length === 0) { - item.marks = '' - } + let _columns = [] - if (item.field) { - orderfields[item.uuid] = item.field - } - - cell = { - align: item.Align, - dataIndex: item.uuid, - title: item.label, - sorter: item.field && item.IsSort === 'true', - width: item.Width || 120, - onCell: record => ({ - record, - col: item, - config: item.type === 'custom' || item.type === 'action' ? {setting, columns: fields} : null, - triggerLink: this.triggerLink - }) - } - } + if (setting.tableMode !== 'fast') { + let getColumns = (cols) => { + return cols.map(item => { + let cell = null + + if (item.type === 'colspan') { + cell = { title: item.label, align: item.Align } + cell.children = getColumns(item.subcols) + } else { + if (item.rowspan === 'true') { + rowspans.push(item.field) + } + if (item.type === 'index') { + item.field = '$Index' + item.type = 'text' + } else if (_format && !Math.floor(Math.random() * radio)) { + item.blur = true + } + + if (item.marks && item.marks.length === 0) { + item.marks = '' + } - return cell + if (item.field) { + orderfields[item.uuid] = item.field + } + + cell = { + align: item.Align, + dataIndex: item.uuid, + title: item.label, + sorter: item.field && item.IsSort === 'true', + width: item.Width || 120, + onCell: record => ({ + record, + col: item, + config: item.type === 'custom' || item.type === 'action' ? {setting, columns: fields} : null, + triggerLink: this.triggerLink + }) + } + } + + return cell + }) + } + _columns = getColumns(columns) + } else { + let fields = [] + columns.forEach(item => { + if (!item.field || fields.includes(item.field)) return + fields.push(item.field) + + _columns.push({ + align: item.Align, + dataIndex: item.field, + title: item.label, + sorter: item.IsSort === 'true', + width: item.Width || 120 + }) }) } - - let _columns = getColumns(columns) if (rowspans.length === 0) { rowspans = null @@ -493,13 +519,6 @@ } return uuid.join('') }) () - - // if (setting.borderColor) { // 杈规棰滆壊 - // let style = `#${tableId} table, #${tableId} tr, #${tableId} th, #${tableId} td {border-color: ${setting.borderColor}}` - // let ele = document.createElement('style') - // ele.innerHTML = style - // document.getElementsByTagName('head')[0].appendChild(ele) - // } let size = (setting.pageSize || 10) + '' let pageOptions = ['10', '25', '50', '100', '500', '1000'] @@ -530,9 +549,17 @@ } componentDidMount () { - MKEmitter.addListener('mkCheckTopLine', this.mkCheckTopLine) + const { autoMatic } = this.props + MKEmitter.addListener('mkCheckAll', this.mkCheckAll) MKEmitter.addListener('resetTable', this.resetTable) + + if (autoMatic === true) { + MKEmitter.addListener('autoQueryData', this.autoQueryData) + MKEmitter.addListener('autoSelectData', this.autoSelectData) + } + + MKEmitter.addListener('mkCheckTopLine', this.mkCheckTopLine) } /** @@ -542,9 +569,50 @@ this.setState = () => { return } - MKEmitter.removeListener('mkCheckTopLine', this.mkCheckTopLine) MKEmitter.removeListener('mkCheckAll', this.mkCheckAll) MKEmitter.removeListener('resetTable', this.resetTable) + MKEmitter.removeListener('autoQueryData', this.autoQueryData) + MKEmitter.removeListener('autoSelectData', this.autoSelectData) + MKEmitter.removeListener('mkCheckTopLine', this.mkCheckTopLine) + } + + autoSelectData = (id, index) => { + if (id !== this.props.MenuID) return + + const { pageSize, pageIndex } = this.state + + let i = index - (pageIndex - 1) * pageSize - 1 + + if (this.props.data[i]) { + this.changeRow(this.props.data[i], i) + MKEmitter.emit('autoTransSelectData', this.props.MenuID, this.props.data[i]) + } else { + MKEmitter.emit('autoMaticOver', this.props.MenuID) + } + } + + autoQueryData = (id, index) => { + if (id !== this.props.MenuID) return + + const { total } = this.props + const { pageSize } = this.state + + if (index !== 1 && (!total || index > total)) { + MKEmitter.emit('autoMaticOver', this.props.MenuID) + return + } + + console.clear() + + let pageIndex = Math.ceil(index / pageSize) + + this.setState({ + pageIndex: pageIndex, + selectedRowKeys: [], + activeIndex: null + }) + + this.props.refreshdata({pageIndex}) } mkCheckTopLine = (menuId, id) => { @@ -856,11 +924,14 @@ } } - const components = { + let components = { body: { - row: BodyRow, - cell: BodyCell + row: BodyRow } + } + + if (setting.tableMode !== 'fast') { + components.body.cell = BodyCell } // 鏁版嵁鏀惰捣鏃讹紝杩囨护宸查�夋暟鎹� @@ -899,7 +970,6 @@ } <Table components={components} - // style={setting.style} size={setting.size || 'middle'} bordered={setting.bordered !== 'false'} rowSelection={rowSelection} @@ -909,7 +979,7 @@ scroll={{ x: '100%', y: height }} onRow={(record, index) => { return { - lineMarks, + lineMarks: setting.tableMode !== 'fast' ? lineMarks : null, data: record, className: index === activeIndex ? ' mk-row-active ' : '', onClick: () => {this.changeRow(record, index)}, -- Gitblit v1.8.0