拖拽影响过滤焦点触发的回调功能

This commit is contained in:
wanghaoo 2018-11-21 22:23:40 +08:00
parent 42b9ec7f2c
commit b22fcfd8b7
3 changed files with 53 additions and 29 deletions

View File

@ -278,9 +278,7 @@ var Table = function (_Component) {
//如果用户传了scroll.x按用户传的为主
var setWidthParam = this.props.scroll.x;
var computeObj = this.columnManager.getColumnWidth(this.contentWidth);
var lastShowIndex = computeObj.lastShowIndex;
this.computeWidth = computeObj.computeWidth;
if (typeof setWidthParam == 'number') {
var numSetWidthParam = parseInt(setWidthParam);
this.contentWidth = numSetWidthParam;
@ -290,11 +288,15 @@ var Table = function (_Component) {
this.contentDomWidth = this.contentTable.getBoundingClientRect().width; //表格容器宽度
this.contentWidth = this.contentDomWidth; //默认与容器宽度一样
this.domWidthDiff = this.contentDomWidth - this.computeWidth;
if (typeof setWidthParam == 'string' && setWidthParam.indexOf('%')) {
this.contentWidth = this.contentWidth * parseInt(setWidthParam) / 100;
this.domWidthDiff = this.contentDomWidth - this.contentWidth;
}
}
var computeObj = this.columnManager.getColumnWidth(this.contentWidth);
var lastShowIndex = computeObj.lastShowIndex;
this.computeWidth = computeObj.computeWidth;
this.domWidthDiff = this.contentDomWidth - this.computeWidth;
if (typeof setWidthParam == 'string' && setWidthParam.indexOf('%')) {
this.contentWidth = this.contentWidth * parseInt(setWidthParam) / 100;
this.domWidthDiff = this.contentDomWidth - this.contentWidth;
}
if (this.computeWidth < this.contentWidth) {
@ -683,7 +685,7 @@ var Table = function (_Component) {
} else if (width) {
width = parseInt(width);
}
if (lastShowIndex == i) {
if (lastShowIndex == i && width) {
width = width + contentWidthDiff;
}

View File

@ -412,7 +412,7 @@ var TableHeader = function (_Component) {
TableHeader.prototype.render = function render() {
var _this2 = this;
var _this3 = this;
var _state = this.state,
dragAbleOrBord = _state.dragAbleOrBord,
@ -453,8 +453,8 @@ var TableHeader = function (_Component) {
if (!fixed && da.fixed) {
fixedStyle = clsPrefix + "-row-fixed-columns-in-body";
}
if (typeof da.width == "string" && da.width.indexOf("%") > -1 && _this2.props.contentWidth) {
da.width = parseInt(_this2.props.contentWidth * parseInt(da.width) / 100);
if (typeof da.width == "string" && da.width.indexOf("%") > -1 && _this3.props.contentWidth) {
da.width = parseInt(_this3.props.contentWidth * parseInt(da.width) / 100);
} else if (da.width) {
da.width = parseInt(da.width);
}
@ -463,7 +463,7 @@ var TableHeader = function (_Component) {
canDotDrag = "th-can-not-drag";
}
if (filterable && index == rows.length - 1) {
da.children = _this2.filterRenderType(da["filtertype"], da.dataindex, i);
da.children = _this3.filterRenderType(da["filtertype"], da.dataindex, i);
delete da.filterdropdownfocus;
}
@ -476,26 +476,37 @@ var TableHeader = function (_Component) {
if (draggable && dragAbleOrBordStart != "borderStart") {
thAbleObj = _extends({}, da, {
onDragStart: function onDragStart(e) {
_this2.onDragStart(e, da);
_this3.onDragStart(e, da);
},
onDragOver: function onDragOver(e) {
_this2.onDragOver(e, da);
_this3.onDragOver(e, da);
},
onDrop: function onDrop(e) {
_this2.onDrop(e, da);
_this3.onDrop(e, da);
},
onDragEnter: function onDragEnter(e) {
_this2.onDragEnter(e, da);
_this3.onDragEnter(e, da);
},
onMouseMove: function onMouseMove(e) {
_this2.ableOnMouseMove(e, da);
_this3.ableOnMouseMove(e, da);
},
onMouseDown: function onMouseDown(e) {
var _state2 = _this2.state,
//避免表头其他元素对其影响
var filterDom = _this2.props.contentTable.querySelector('.filterable');
//是否是过滤行元素,是的话不触发
var isFilterDom = filterDom ? filterDom.contains(e.target) : false;
if (e.target.classList.contains('uf') || isFilterDom) {
return;
}
if (e.target.classList.contains('uf')) {
return;
}
var _state2 = _this3.state,
dragAbleOrBord = _state2.dragAbleOrBord,
dragAbleOrBordStart = _state2.dragAbleOrBordStart;
_this2.setState({
_this3.setState({
dragAbleOrBordStart: dragAbleOrBord === "able" ? "ableStart" : ""
});
},
@ -511,12 +522,12 @@ var TableHeader = function (_Component) {
// thObj.className= thObj.className+`${clsPrefix}-thead-th ${canDotDrag}`,
};thBorObj.onMouseMove = function (e) {
if (draggable) {
_this2.ableOnMouseMove(e, da);
_this3.ableOnMouseMove(e, da);
}
_this2.onThMouseMove(e, da);
_this3.onThMouseMove(e, da);
};
thBorObj.onMouseUp = function (e) {
_this2.onThMouseUp(e, da);
_this3.onThMouseUp(e, da);
};
thClassName += clsPrefix + "-thead-th " + canDotDrag;
@ -529,19 +540,19 @@ var TableHeader = function (_Component) {
if (!da.fixed) {
thLineObj = {
onMouseMove: function onMouseMove(e) {
e.stopPropagation();_this2.onMouseMove(e, da);
e.stopPropagation();_this3.onMouseMove(e, da);
},
onMouseOut: function onMouseOut(e) {
_this2.onMouseOut(e, da);
_this3.onMouseOut(e, da);
},
onMouseDown: function onMouseDown(e) {
e.stopPropagation();_this2.onMouseDown(e, da);
e.stopPropagation();_this3.onMouseDown(e, da);
},
onMouseUp: function onMouseUp(e) {
_this2.onMouseUp(e, da);
_this3.onMouseUp(e, da);
},
onMouseOver: function onMouseOver(e) {
_this2.onMouseOver(e, da);
_this3.onMouseOver(e, da);
},
className: clsPrefix + "-thead-th-drag-gap "
};
@ -551,7 +562,7 @@ var TableHeader = function (_Component) {
_extends({ key: Math.random() }, thAbleObj, thBorObj, { className: thClassName }),
da.children,
da.fixed ? "" : _react2["default"].createElement("div", _extends({ ref: function ref(el) {
return _this2.gap = el;
return _this3.gap = el;
} }, thLineObj))
);
} else {

View File

@ -453,6 +453,17 @@ class TableHeader extends Component {
onDragEnter:(e)=>{this.onDragEnter(e, da)},
onMouseMove:(e)=>{this.ableOnMouseMove(e, da)},
onMouseDown:(e)=>{
//避免表头其他元素对其影响
const filterDom = _this2.props.contentTable.querySelector('.filterable');
//是否是过滤行元素,是的话不触发
const isFilterDom =filterDom ?filterDom.contains(e.target):false;
if(e.target.classList.contains('uf') ||isFilterDom){
return;
}
if(e.target.classList.contains('uf')){
return;
}
let {dragAbleOrBord,dragAbleOrBordStart} = this.state;
this.setState({
dragAbleOrBordStart:dragAbleOrBord==="able"?"ableStart":""