From 8aebc779572409e82f4b3b3930139caf5d3a670e Mon Sep 17 00:00:00 2001 From: izbz wh <731215820@qq.com> Date: Fri, 11 Sep 2020 14:48:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=87=AA=E5=AE=9A=E4=B9=89=E6=9F=90?= =?UTF-8?q?=E5=88=97=E6=9D=A5=E6=8E=A7=E5=88=B6=E5=BD=93=E5=89=8D=E8=A1=8C?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=8F=AF=E4=BB=A5=E6=8B=96=E6=8B=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Table.js | 2 +- src/TableCell.js | 6 ++++++ src/TableRow.js | 21 +++++++++++++++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/Table.js b/src/Table.js index c464abe..b5f6865 100644 --- a/src/Table.js +++ b/src/Table.js @@ -802,7 +802,7 @@ class Table extends Component { indent={indent} indentSize={props.indentSize} needIndentSpaced={needIndentSpaced} - className={`${className} ${props.rowDraggAble && !props.useDragHandle?'row-dragg-able ':''}`} + className={`${className}`} record={record} expandIconAsCell={expandIconAsCell} onDestroy={this.onRowDestroy} diff --git a/src/TableCell.js b/src/TableCell.js index c2b7bcc..9a4f6d1 100644 --- a/src/TableCell.js +++ b/src/TableCell.js @@ -184,6 +184,11 @@ class TableCell extends Component{ onPaste(e,position) } + onCellMouseOver = (e)=> { + const {column} = this.props + this.props.stopRowDrag(column.notRowDrag) + } + render() { const { record, indentSize, clsPrefix, indent, index, expandIcon, column ,fixed,showSum, bodyDisplayInRow,lazyStartIndex,lazyEndIndex} = this.props; @@ -301,6 +306,7 @@ class TableCell extends Component{ onClick={this.handleClick} title={title} onPaste={this.onPaste} + onMouseOver={this.onCellMouseOver} style={{maxWidth:column.width, color:fontColor, backgroundColor:bgColor, ...column.style}}> {indentText} {expandIcon} diff --git a/src/TableRow.js b/src/TableRow.js index ffb3ec1..4b2cad4 100644 --- a/src/TableRow.js +++ b/src/TableRow.js @@ -140,7 +140,7 @@ class TableRow extends Component{ */ onDragStart = (e) => { let {onDragRowStart} = this.props; - if (!this.props.rowDraggAble) return; + if (!this.props.rowDraggAble || this.notRowDrag) return; let event = Event.getEvent(e) , target = Event.getTarget(event); if (target.tagName === 'TD') { @@ -430,6 +430,16 @@ class TableRow extends Component{ onHover(false, hoverKey,e,fixedIndex,record); } + stopRowDrag = (isStop) => { + const {rowDraggAble} = this.props; + const {notRowDrag} = this.state; + if(rowDraggAble && isStop!== notRowDrag) { + this.setState({ + notRowDrag: isStop + }) + } + } + set =(fn)=> { this.clear(); this._timeout = window.setTimeout(fn, 300); @@ -452,6 +462,7 @@ class TableRow extends Component{ expandable, onExpand, needIndentSpaced, indent, indentSize,isHiddenExpandIcon,fixed,bodyDisplayInRow ,expandedIcon,collapsedIcon, hoverKey,lazyStartIndex,lazyEndIndex, expandIconCellWidth } = this.props; + const {notRowDrag} = this.state; let showSum = false; let { className } = this.props; if (this.state.hovered) { @@ -515,6 +526,7 @@ class TableRow extends Component{ lazyStartIndex={lazyStartIndex} lazyEndIndex={lazyEndIndex} onPaste={onPaste} + stopRowDrag={this.stopRowDrag} col={i} /> ); @@ -526,9 +538,14 @@ class TableRow extends Component{ if(record && record._checked){ className += ' selected'; } + + if(rowDraggAble && !useDragHandle && !notRowDrag) { + className += ' row-dragg-able' + } + return (