This commit is contained in:
izbz wh 2019-05-27 10:28:15 +08:00
commit 07009bae46
6 changed files with 46 additions and 19 deletions

View File

@ -1,3 +1,8 @@
<a name="2.0.25"></a>
## [2.0.25](https://github.com/tinper-bee/bee-table/compare/v2.0.24...v2.0.25) (2019-05-24)
<a name="2.0.24"></a> <a name="2.0.24"></a>
## [2.0.24](https://github.com/tinper-bee/bee-table/compare/v2.0.22...v2.0.24) (2019-05-22) ## [2.0.24](https://github.com/tinper-bee/bee-table/compare/v2.0.22...v2.0.24) (2019-05-22)

View File

@ -205,17 +205,18 @@ var Table = function (_Component) {
targetIndex = i; targetIndex = i;
} }
}); });
if (currentIndex < targetIndex) { data = _this.swapArray(data, currentIndex, targetIndex);
data.splice(targetIndex, 0, data.splice(currentIndex, 1).shift());
} else {
data.splice(targetIndex + 1, 0, data.splice(currentIndex, 1).shift());
}
_this.props.onDropRow && _this.props.onDropRow(data, record); _this.props.onDropRow && _this.props.onDropRow(data, record);
_this.setState({ _this.setState({
data: data data: data
}); });
}; };
_this.swapArray = function (arr, index1, index2) {
arr[index1] = arr.splice(index2, 1, arr[index1])[0];
return arr;
};
_this.renderDragHideTable = function () { _this.renderDragHideTable = function () {
var _this$props = _this.props, var _this$props = _this.props,
columns = _this$props.columns, columns = _this$props.columns,
@ -396,7 +397,7 @@ var Table = function (_Component) {
} }
// 是否传入 scroll中的y属性如果传入判断是否是整数如果是则进行比较 。bodyTable 的clientHeight进行判断 // 是否传入 scroll中的y属性如果传入判断是否是整数如果是则进行比较 。bodyTable 的clientHeight进行判断
// this.isShowScrollY(); this.isShowScrollY();
}; };
Table.prototype.componentWillUnmount = function componentWillUnmount() { Table.prototype.componentWillUnmount = function componentWillUnmount() {
@ -454,7 +455,7 @@ var Table = function (_Component) {
var bodyH = this.bodyTable.clientHeight; var bodyH = this.bodyTable.clientHeight;
var bodyContentH = this.bodyTable.querySelector('table').clientHeight; var bodyContentH = this.bodyTable.querySelector('table').clientHeight;
var rightBodyTable = this.refs.fixedColumnsBodyRight; var rightBodyTable = this.refs.fixedColumnsBodyRight;
var leftBodyTable = this.refs.fixedColumnsBodyLeft; // const leftBodyTable = this.refs.fixedColumnsBodyLeft;
var overflowy = bodyContentH <= bodyH ? 'auto' : 'scroll'; var overflowy = bodyContentH <= bodyH ? 'auto' : 'scroll';
this.bodyTable.style.overflowY = overflowy; this.bodyTable.style.overflowY = overflowy;
@ -737,6 +738,13 @@ var Table = function (_Component) {
* @param targetKey 拖拽结束时目标位置的key * @param targetKey 拖拽结束时目标位置的key
*/ */
/**
* 数组元素交换位置
* @param {array} arr 数组
* @param {number} index1 添加项目的位置
* @param {number} index2 删除项目的位置
*/
/** /**
* *

18
dist/demo.js vendored
View File

@ -16626,17 +16626,18 @@
targetIndex = i; targetIndex = i;
} }
}); });
if (currentIndex < targetIndex) { data = _this.swapArray(data, currentIndex, targetIndex);
data.splice(targetIndex, 0, data.splice(currentIndex, 1).shift());
} else {
data.splice(targetIndex + 1, 0, data.splice(currentIndex, 1).shift());
}
_this.props.onDropRow && _this.props.onDropRow(data, record); _this.props.onDropRow && _this.props.onDropRow(data, record);
_this.setState({ _this.setState({
data: data data: data
}); });
}; };
_this.swapArray = function (arr, index1, index2) {
arr[index1] = arr.splice(index2, 1, arr[index1])[0];
return arr;
};
_this.renderDragHideTable = function () { _this.renderDragHideTable = function () {
var _this$props = _this.props, var _this$props = _this.props,
columns = _this$props.columns, columns = _this$props.columns,
@ -17158,6 +17159,13 @@
* @param targetKey 拖拽结束时目标位置的key * @param targetKey 拖拽结束时目标位置的key
*/ */
/**
* 数组元素交换位置
* @param {array} arr 数组
* @param {number} index1 添加项目的位置
* @param {number} index2 删除项目的位置
*/
/** /**
* *

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"name": "bee-table", "name": "bee-table",
"version": "2.0.25-beta.0", "version": "2.0.26-beta.0",
"description": "Table ui component for react", "description": "Table ui component for react",
"keywords": [ "keywords": [
"react", "react",

View File

@ -581,16 +581,22 @@ class Table extends Component {
targetIndex = i; targetIndex = i;
} }
}); });
if(currentIndex < targetIndex){ data = this.swapArray(data,currentIndex,targetIndex);
data.splice(targetIndex, 0, data.splice(currentIndex, 1).shift());
}else{
data.splice((targetIndex+1), 0, data.splice(currentIndex, 1).shift());
}
this.props.onDropRow && this.props.onDropRow(data,record); this.props.onDropRow && this.props.onDropRow(data,record);
this.setState({ this.setState({
data, data,
}); });
} }
/**
* 数组元素交换位置
* @param {array} arr 数组
* @param {number} index1 添加项目的位置
* @param {number} index2 删除项目的位置
*/
swapArray = (arr, index1, index2) => {
arr[index1] = arr.splice(index2, 1, arr[index1])[0];
return arr;
}
/** /**
* *