merge
This commit is contained in:
commit
0cddb2738f
24
CHANGELOG.md
24
CHANGELOG.md
|
@ -1,3 +1,13 @@
|
|||
<a name="2.1.3"></a>
|
||||
## [2.1.3](https://github.com/tinper-bee/bee-table/compare/v2.1.2...v2.1.3) (2019-06-12)
|
||||
|
||||
|
||||
|
||||
<a name="2.1.2"></a>
|
||||
## [2.1.2](https://github.com/tinper-bee/bee-table/compare/v2.1.1...v2.1.2) (2019-06-06)
|
||||
|
||||
|
||||
|
||||
<a name="2.1.1"></a>
|
||||
## [2.1.1](https://github.com/tinper-bee/bee-table/compare/v2.1.0...v2.1.1) (2019-06-05)
|
||||
|
||||
|
@ -9,7 +19,7 @@
|
|||
|
||||
|
||||
<a name="2.1.0"></a>
|
||||
# [2.1.0](https://github.com/tinper-bee/bee-table/compare/v2.0.24...v2.1.0) (2019-06-01)
|
||||
# [2.1.0](https://github.com/tinper-bee/bee-table/compare/v2.0.25...v2.1.0) (2019-06-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
@ -18,13 +28,13 @@
|
|||
|
||||
|
||||
|
||||
<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>
|
||||
## [2.0.24](https://github.com/tinper-bee/bee-table/compare/v2.0.23...v2.0.24) (2019-05-22)
|
||||
|
||||
|
||||
|
||||
<a name="2.0.23"></a>
|
||||
## [2.0.23](https://github.com/tinper-bee/bee-table/compare/v2.0.22...v2.0.23) (2019-05-22)
|
||||
## [2.0.24](https://github.com/tinper-bee/bee-table/compare/v2.0.22...v2.0.24) (2019-05-22)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -153,6 +153,13 @@
|
|||
.u-loading.u-loading-line.u-loading-line-warning > div {
|
||||
background-color: #ff9800; }
|
||||
|
||||
.u-loading.u-loading-custom > div {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
-webkit-transform: translate(-50%, -50%);
|
||||
transform: translate(-50%, -50%); }
|
||||
|
||||
@keyframes line-scale {
|
||||
0% {
|
||||
-webkit-transform: scaley(1);
|
||||
|
|
|
@ -96,11 +96,13 @@ var TableHeader = function (_Component) {
|
|||
_this.drag.minWidth = currentObj.style.minWidth != "" ? parseInt(currentObj.style.minWidth) : defaultWidth;
|
||||
_this.drag.tableWidth = parseInt(_this.table.table.style.width ? _this.table.table.style.width : _this.table.table.scrollWidth);
|
||||
} else if (type != 'online' && _this.props.draggable) {
|
||||
if (!_this.props.draggable || targetEvent.nodeName.toUpperCase() != "TH") return;
|
||||
targetEvent.setAttribute('draggable', true); //添加交换列效果
|
||||
// if (!this.props.draggable || targetEvent.nodeName.toUpperCase() != "TH") return;
|
||||
if (!_this.props.draggable) return;
|
||||
var th = _this.getTargetToTh(targetEvent);
|
||||
th.setAttribute('draggable', true); //添加交换列效果
|
||||
_this.drag.option = 'dragAble';
|
||||
_this.currentDome = event.target;
|
||||
var _currentIndex = parseInt(currentElement.getAttribute("data-line-index"));
|
||||
_this.currentDome = th;
|
||||
var _currentIndex = parseInt(th.getAttribute("data-line-index"));
|
||||
_this.drag.currIndex = _currentIndex;
|
||||
} else {
|
||||
// console.log("onTrMouseDown dragborder or draggable is all false !");
|
||||
|
@ -108,6 +110,15 @@ var TableHeader = function (_Component) {
|
|||
}
|
||||
};
|
||||
|
||||
_this.getTargetToTh = function (targetEvent) {
|
||||
var th = targetEvent;
|
||||
if (targetEvent.nodeName.toUpperCase() != "TH") {
|
||||
th = _this.getThDome(targetEvent);
|
||||
}
|
||||
console.log(" getTargetToTh: ", th);
|
||||
return th;
|
||||
};
|
||||
|
||||
_this.onTrMouseMove = function (e) {
|
||||
if (!_this.props.dragborder && !_this.props.draggable) return;
|
||||
var _this$props2 = _this.props,
|
||||
|
@ -221,8 +232,9 @@ var TableHeader = function (_Component) {
|
|||
return;
|
||||
}
|
||||
var event = _utils.Event.getEvent(e),
|
||||
target = _utils.Event.getTarget(event);
|
||||
|
||||
// target = Event.getTarget(event);
|
||||
target = _this.getTargetToTh(_utils.Event.getTarget(event));
|
||||
var currentIndex = parseInt(target.getAttribute("data-line-index"));
|
||||
var currentKey = target.getAttribute('data-line-key');
|
||||
|
||||
|
@ -571,6 +583,11 @@ var TableHeader = function (_Component) {
|
|||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 判断当前的target 是否是 th,如果不是,直接递归查找。
|
||||
* @memberof TableHeader
|
||||
*/
|
||||
|
||||
/**
|
||||
* 调整列宽的move事件
|
||||
* @memberof TableHeader
|
||||
|
@ -667,6 +684,26 @@ var TableHeader = function (_Component) {
|
|||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据当前鼠标点击的节点,进行递归遍历,最终找到th
|
||||
* @param {*} element
|
||||
* @returns <th />对象
|
||||
* @memberof TableHeader
|
||||
*/
|
||||
|
||||
|
||||
TableHeader.prototype.getThDome = function getThDome(element) {
|
||||
var _tagName = element.tagName.toLowerCase();
|
||||
if (element.getAttribute('data-filter-type') === 'filterContext') return null;
|
||||
if (_tagName === 'i') return null;
|
||||
if (_tagName != 'th') {
|
||||
return this.getThDome(element.parentElement);
|
||||
} else {
|
||||
return element;
|
||||
}
|
||||
};
|
||||
|
||||
//---拖拽列交换----end-----
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,8 +42,15 @@ function singleSelect(Table, Radio) {
|
|||
var _this = _possibleConstructorReturn(this, _Component.call(this, props));
|
||||
|
||||
_this.onRadioChange = function (value, record, index) {
|
||||
_this.setState({ selectedRowIndex: index });
|
||||
_this.props.getSelectedDataFunc(record, index);
|
||||
var selectedRowIndex = _this.state.selectedRowIndex;
|
||||
|
||||
if (selectedRowIndex === index) {
|
||||
_this.setState({ selectedRowIndex: '' });
|
||||
_this.props.getSelectedDataFunc();
|
||||
} else {
|
||||
_this.setState({ selectedRowIndex: index });
|
||||
_this.props.getSelectedDataFunc(record, index);
|
||||
}
|
||||
};
|
||||
|
||||
_this.getDefaultColumns = function (columns) {
|
||||
|
|
|
@ -106,9 +106,9 @@ function sum(Table) {
|
|||
return _this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前的表格类型。
|
||||
*
|
||||
/**
|
||||
* 获取当前的表格类型。
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
value: true
|
||||
});
|
||||
|
||||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||
|
@ -9,71 +9,71 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
|
|||
exports.sortBy = sortBy;
|
||||
exports.compare = compare;
|
||||
exports.ObjectAssign = ObjectAssign;
|
||||
/*
|
||||
* 快速排序,按某个属性,或按“获取排序依据的函数”,来排序.
|
||||
* @method soryBy
|
||||
* @static
|
||||
* @param {array} arr 待处理数组
|
||||
* @param {string|function} prop 排序依据属性,获取
|
||||
* @param {boolean} desc 降序
|
||||
* @return {array} 返回排序后的新数组
|
||||
/*
|
||||
* 快速排序,按某个属性,或按“获取排序依据的函数”,来排序.
|
||||
* @method soryBy
|
||||
* @static
|
||||
* @param {array} arr 待处理数组
|
||||
* @param {string|function} prop 排序依据属性,获取
|
||||
* @param {boolean} desc 降序
|
||||
* @return {array} 返回排序后的新数组
|
||||
*/
|
||||
|
||||
function sortBy(arr, prop, desc) {
|
||||
var props = [],
|
||||
ret = [],
|
||||
i = 0,
|
||||
len = arr.length;
|
||||
if (typeof prop == 'string') {
|
||||
for (; i < len; i++) {
|
||||
var oI = arr[i];
|
||||
(props[i] = new String(oI && oI[prop] || ''))._obj = oI;
|
||||
}
|
||||
} else if (typeof prop == 'function') {
|
||||
for (; i < len; i++) {
|
||||
var _oI = arr[i];
|
||||
(props[i] = new String(_oI && prop(_oI) || ''))._obj = _oI;
|
||||
}
|
||||
} else {
|
||||
throw '参数类型错误';
|
||||
var props = [],
|
||||
ret = [],
|
||||
i = 0,
|
||||
len = arr.length;
|
||||
if (typeof prop == 'string') {
|
||||
for (; i < len; i++) {
|
||||
var oI = arr[i];
|
||||
(props[i] = new String(oI && oI[prop] || ''))._obj = oI;
|
||||
}
|
||||
props.sort();
|
||||
for (i = 0; i < len; i++) {
|
||||
ret[i] = props[i]._obj;
|
||||
} else if (typeof prop == 'function') {
|
||||
for (; i < len; i++) {
|
||||
var _oI = arr[i];
|
||||
(props[i] = new String(_oI && prop(_oI) || ''))._obj = _oI;
|
||||
}
|
||||
if (desc) ret.reverse();
|
||||
return ret;
|
||||
} else {
|
||||
throw '参数类型错误';
|
||||
}
|
||||
props.sort();
|
||||
for (i = 0; i < len; i++) {
|
||||
ret[i] = props[i]._obj;
|
||||
}
|
||||
if (desc) ret.reverse();
|
||||
return ret;
|
||||
};
|
||||
|
||||
/**
|
||||
* 数组对象排序
|
||||
* console.log(arr.sort(compare('age')))
|
||||
* @param {} property
|
||||
/**
|
||||
* 数组对象排序
|
||||
* console.log(arr.sort(compare('age')))
|
||||
* @param {} property
|
||||
*/
|
||||
function compare(property) {
|
||||
return function (a, b) {
|
||||
var value1 = a[property];
|
||||
var value2 = b[property];
|
||||
return value1 - value2;
|
||||
};
|
||||
return function (a, b) {
|
||||
var value1 = a[property];
|
||||
var value2 = b[property];
|
||||
return value1 - value2;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 简单数组数据对象拷贝
|
||||
* @param {*} obj 要拷贝的对象
|
||||
/**
|
||||
* 简单数组数据对象拷贝
|
||||
* @param {*} obj 要拷贝的对象
|
||||
*/
|
||||
function ObjectAssign(obj) {
|
||||
var b = obj instanceof Array;
|
||||
var tagObj = b ? [] : {};
|
||||
if (b) {
|
||||
//数组
|
||||
obj.forEach(function (da) {
|
||||
var _da = {};
|
||||
_extends(_da, da);
|
||||
tagObj.push(_da);
|
||||
});
|
||||
} else {
|
||||
_extends(tagObj, obj);
|
||||
}
|
||||
return tagObj;
|
||||
var b = obj instanceof Array;
|
||||
var tagObj = b ? [] : {};
|
||||
if (b) {
|
||||
//数组
|
||||
obj.forEach(function (da) {
|
||||
var _da = {};
|
||||
_extends(_da, da);
|
||||
tagObj.push(_da);
|
||||
});
|
||||
} else {
|
||||
_extends(tagObj, obj);
|
||||
}
|
||||
return tagObj;
|
||||
}
|
|
@ -19,11 +19,11 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
|
|||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
|
||||
|
||||
/**
|
||||
* 渲染checkbox
|
||||
* @param Checkbox
|
||||
* @param Icon
|
||||
* @returns {CheckboxRender}
|
||||
/**
|
||||
* 渲染checkbox
|
||||
* @param Checkbox
|
||||
* @param Icon
|
||||
* @returns {CheckboxRender}
|
||||
*/
|
||||
function renderCheckbox(Checkbox, Icon) {
|
||||
return function (_Component) {
|
||||
|
|
|
@ -28,12 +28,12 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
|
|||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
|
||||
|
||||
/**
|
||||
* 渲染输入框
|
||||
* @param Form
|
||||
* @param Input
|
||||
* @param Icon
|
||||
* @returns {InputRender}
|
||||
/**
|
||||
* 渲染输入框
|
||||
* @param Form
|
||||
* @param Input
|
||||
* @param Icon
|
||||
* @returns {InputRender}
|
||||
*/
|
||||
function renderInput(Form, Input, Icon) {
|
||||
var _class, _temp2;
|
||||
|
|
|
@ -26,11 +26,11 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
|
|||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
|
||||
|
||||
/**
|
||||
* 渲染下拉框
|
||||
* @param Select
|
||||
* @param Icon
|
||||
* @returns {SelectRender}
|
||||
/**
|
||||
* 渲染下拉框
|
||||
* @param Select
|
||||
* @param Icon
|
||||
* @returns {SelectRender}
|
||||
*/
|
||||
function renderSelect(Select, Icon) {
|
||||
var _class, _temp2;
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "bee-table",
|
||||
"version": "2.1.1",
|
||||
"version": "2.1.3",
|
||||
"description": "Table ui component for react",
|
||||
"keywords": [
|
||||
"react",
|
||||
|
@ -56,7 +56,7 @@
|
|||
"bee-loading": "1.1.2",
|
||||
"bee-locale": "0.0.14",
|
||||
"bee-menus": "^2.0.6",
|
||||
"bee-radio": "2.0.10",
|
||||
"bee-radio": "^2.0.11",
|
||||
"bee-select": "^2.0.11",
|
||||
"classnames": "^2.2.5",
|
||||
"component-classes": "^1.2.6",
|
||||
|
|
|
@ -203,11 +203,13 @@ class TableHeader extends Component {
|
|||
this.drag.minWidth = currentObj.style.minWidth != ""?parseInt(currentObj.style.minWidth):defaultWidth;
|
||||
this.drag.tableWidth = parseInt(this.table.table.style.width ?this.table.table.style.width:this.table.table.scrollWidth);
|
||||
}else if(type != 'online' && this.props.draggable){
|
||||
if (!this.props.draggable || targetEvent.nodeName.toUpperCase() != "TH") return;
|
||||
targetEvent.setAttribute('draggable',true);//添加交换列效果
|
||||
// if (!this.props.draggable || targetEvent.nodeName.toUpperCase() != "TH") return;
|
||||
if (!this.props.draggable) return;
|
||||
let th = this.getTargetToTh(targetEvent);
|
||||
th.setAttribute('draggable',true);//添加交换列效果
|
||||
this.drag.option = 'dragAble';
|
||||
this.currentDome = event.target;
|
||||
let currentIndex = parseInt(currentElement.getAttribute("data-line-index"));
|
||||
this.currentDome = th;
|
||||
let currentIndex = parseInt(th.getAttribute("data-line-index"));
|
||||
this.drag.currIndex = currentIndex;
|
||||
}else{
|
||||
// console.log("onTrMouseDown dragborder or draggable is all false !");
|
||||
|
@ -215,6 +217,18 @@ class TableHeader extends Component {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 判断当前的target 是否是 th,如果不是,直接递归查找。
|
||||
* @memberof TableHeader
|
||||
*/
|
||||
getTargetToTh = (targetEvent) => {
|
||||
let th = targetEvent;
|
||||
if(targetEvent.nodeName.toUpperCase() != "TH"){
|
||||
th = this.getThDome(targetEvent);
|
||||
}
|
||||
console.log(" getTargetToTh: ", th);
|
||||
return th;
|
||||
}
|
||||
/**
|
||||
* 调整列宽的move事件
|
||||
* @memberof TableHeader
|
||||
|
@ -385,8 +399,8 @@ class TableHeader extends Component {
|
|||
if (!this.props.draggable) return;
|
||||
if(this.drag && this.drag.option != 'dragAble'){return;}
|
||||
let event = Event.getEvent(e) ,
|
||||
target = Event.getTarget(event);
|
||||
|
||||
// target = Event.getTarget(event);
|
||||
target = this.getTargetToTh(Event.getTarget(event));
|
||||
let currentIndex = parseInt(target.getAttribute("data-line-index"));
|
||||
let currentKey = target.getAttribute('data-line-key');
|
||||
|
||||
|
@ -485,6 +499,25 @@ class TableHeader extends Component {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据当前鼠标点击的节点,进行递归遍历,最终找到th
|
||||
* @param {*} element
|
||||
* @returns <th />对象
|
||||
* @memberof TableHeader
|
||||
*/
|
||||
getThDome(element){
|
||||
let _tagName = element.tagName.toLowerCase();
|
||||
if(element.getAttribute('data-filter-type') === 'filterContext')return null;
|
||||
if(_tagName === 'i')return null;
|
||||
if(_tagName != 'th'){
|
||||
return this.getThDome(element.parentElement);
|
||||
}else{
|
||||
return element;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//---拖拽列交换----end-----
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,8 +45,14 @@ export default function singleSelect(Table, Radio) {
|
|||
}
|
||||
|
||||
onRadioChange = (value, record, index) => {
|
||||
this.setState({selectedRowIndex: index});
|
||||
this.props.getSelectedDataFunc(record,index);
|
||||
let { selectedRowIndex } = this.state;
|
||||
if(selectedRowIndex === index){
|
||||
this.setState({selectedRowIndex: ''});
|
||||
this.props.getSelectedDataFunc();
|
||||
}else{
|
||||
this.setState({selectedRowIndex: index});
|
||||
this.props.getSelectedDataFunc(record,index);
|
||||
}
|
||||
}
|
||||
|
||||
getDefaultColumns=(columns)=>{
|
||||
|
|
Loading…
Reference in New Issue