feat: 提供column.sumThousandth属性,用于设置合计行是否开启千分位功能
This commit is contained in:
parent
90f2de3bbb
commit
0a8f8c362b
1599
CHANGELOG.md
1599
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
|
@ -177,6 +177,8 @@
|
||||||
position: relative;
|
position: relative;
|
||||||
line-height: 1.33;
|
line-height: 1.33;
|
||||||
overflow: hidden; }
|
overflow: hidden; }
|
||||||
|
.u-table.copy .u-table-thead th {
|
||||||
|
user-select: unset; }
|
||||||
.u-table-body {
|
.u-table-body {
|
||||||
position: relative; }
|
position: relative; }
|
||||||
.u-table-body .u-table-row-expand-columns-in-body .expand-icon-con {
|
.u-table-body .u-table-row-expand-columns-in-body .expand-icon-con {
|
||||||
|
@ -458,8 +460,8 @@
|
||||||
-moz-user-select: -moz-none;
|
-moz-user-select: -moz-none;
|
||||||
-khtml-user-select: none;
|
-khtml-user-select: none;
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
/*
|
/*
|
||||||
Introduced in IE 10.
|
Introduced in IE 10.
|
||||||
*/
|
*/
|
||||||
-ms-user-select: none;
|
-ms-user-select: none;
|
||||||
user-select: none; }
|
user-select: none; }
|
||||||
|
|
|
@ -639,7 +639,8 @@ var Table = function (_Component) {
|
||||||
onDropBorder = _props2.onDropBorder,
|
onDropBorder = _props2.onDropBorder,
|
||||||
onDraggingBorder = _props2.onDraggingBorder,
|
onDraggingBorder = _props2.onDraggingBorder,
|
||||||
bodyDisplayInRow = _props2.bodyDisplayInRow,
|
bodyDisplayInRow = _props2.bodyDisplayInRow,
|
||||||
headerEventNoStop = _props2.headerEventNoStop;
|
headerEventNoStop = _props2.headerEventNoStop,
|
||||||
|
onCopy = _props2.onCopy;
|
||||||
|
|
||||||
this.columnsChildrenList = []; //复杂表头拖拽,重新render表头前,将其置空
|
this.columnsChildrenList = []; //复杂表头拖拽,重新render表头前,将其置空
|
||||||
var rows = this.getHeaderRows(columns);
|
var rows = this.getHeaderRows(columns);
|
||||||
|
@ -688,7 +689,8 @@ var Table = function (_Component) {
|
||||||
leftFixedWidth: leftFixedWidth,
|
leftFixedWidth: leftFixedWidth,
|
||||||
rightFixedWidth: rightFixedWidth,
|
rightFixedWidth: rightFixedWidth,
|
||||||
bodyDisplayInRow: bodyDisplayInRow,
|
bodyDisplayInRow: bodyDisplayInRow,
|
||||||
eventNoStop: headerEventNoStop
|
eventNoStop: headerEventNoStop,
|
||||||
|
onCopy: onCopy
|
||||||
})) : null;
|
})) : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1640,6 +1642,9 @@ var Table = function (_Component) {
|
||||||
if (props.bordered) {
|
if (props.bordered) {
|
||||||
className += ' ' + clsPrefix + '-bordered';
|
className += ' ' + clsPrefix + '-bordered';
|
||||||
}
|
}
|
||||||
|
if (props.onCopy) {
|
||||||
|
className += ' copy';
|
||||||
|
}
|
||||||
className += ' ' + clsPrefix + '-scroll-position-' + this.state.scrollPosition;
|
className += ' ' + clsPrefix + '-scroll-position-' + this.state.scrollPosition;
|
||||||
//如果传入height说明是固定高度
|
//如果传入height说明是固定高度
|
||||||
//内容过多折行显示时,height 属性会失效,为了避免产生错行
|
//内容过多折行显示时,height 属性会失效,为了避免产生错行
|
||||||
|
|
|
@ -515,7 +515,9 @@ var TableHeader = function (_Component) {
|
||||||
return _react2["default"].createElement(
|
return _react2["default"].createElement(
|
||||||
"th",
|
"th",
|
||||||
_extends({}, da, keyTemp, { className: thClassName, "data-th-fixed": da.fixed, "data-line-key": da.key,
|
_extends({}, da, keyTemp, { className: thClassName, "data-th-fixed": da.fixed, "data-line-key": da.key,
|
||||||
"data-line-index": columIndex, "data-th-width": da.width, "data-type": "draggable" }),
|
"data-line-index": columIndex, "data-th-width": da.width, "data-type": "draggable", onCopy: function onCopy(event) {
|
||||||
|
_this7.onCopy(da, columIndex, event);
|
||||||
|
} }),
|
||||||
da.children,
|
da.children,
|
||||||
|
|
||||||
// && columIndex != _rowLeng
|
// && columIndex != _rowLeng
|
||||||
|
@ -536,7 +538,7 @@ var TableHeader = function (_Component) {
|
||||||
da.onClick ? thDefaultObj.onClick = function (e) {
|
da.onClick ? thDefaultObj.onClick = function (e) {
|
||||||
da.onClick(da, e);
|
da.onClick(da, e);
|
||||||
} : "";
|
} : "";
|
||||||
return _react2["default"].createElement("th", _extends({}, thDefaultObj, keyTemp, { "data-th-fixed": da.fixed, style: { maxWidth: da.width } }));
|
return _react2["default"].createElement("th", _extends({}, thDefaultObj, keyTemp, { "data-th-fixed": da.fixed, style: { maxWidth: da.width }, onCopy: _this7.onCopy }));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -1051,6 +1053,12 @@ var _initialiseProps = function _initialiseProps() {
|
||||||
return _react2["default"].createElement("div", null);
|
return _react2["default"].createElement("div", null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.onCopy = function (data, index, event) {
|
||||||
|
if (_this8.props.onCopy) {
|
||||||
|
_this8.props.onCopy(_extends(data, { col: index }), event);
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
TableHeader.propTypes = propTypes;
|
TableHeader.propTypes = propTypes;
|
||||||
|
|
|
@ -96,14 +96,16 @@ function bigData(Table) {
|
||||||
_this.treeType = isTreeType;
|
_this.treeType = isTreeType;
|
||||||
//fix: 滚动加载场景中,数据动态改变下占位计算错误的问题(26 Jun)
|
//fix: 滚动加载场景中,数据动态改变下占位计算错误的问题(26 Jun)
|
||||||
if (newData.toString() !== props.data.toString()) {
|
if (newData.toString() !== props.data.toString()) {
|
||||||
|
|
||||||
_this.cachedRowHeight = []; //缓存每行的高度
|
_this.cachedRowHeight = []; //缓存每行的高度
|
||||||
_this.cachedRowParentIndex = [];
|
_this.cachedRowParentIndex = [];
|
||||||
_this.computeCachedRowParentIndex(newData);
|
_this.computeCachedRowParentIndex(newData);
|
||||||
// fix:切换数据源,startIndex、endIndex错误
|
// fix:切换数据源,startIndex、endIndex错误
|
||||||
_this.currentIndex = 0;
|
if (_this.scrollTop <= 0) {
|
||||||
_this.startIndex = _this.currentIndex; //数据开始位置
|
// 增加scrollTop 判断,ncc场景下滚动条不在最上层, 会出现空白,因为重置了currentIndex没有重置滚动条
|
||||||
_this.endIndex = _this.currentIndex + _this.loadCount;
|
_this.currentIndex = 0;
|
||||||
|
_this.startIndex = _this.currentIndex; //数据开始位置
|
||||||
|
_this.endIndex = _this.currentIndex + _this.loadCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_this.treeData = [];
|
_this.treeData = [];
|
||||||
_this.flatTreeData = [];
|
_this.flatTreeData = [];
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
|
|
||||||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
||||||
|
@ -35,115 +35,115 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
|
||||||
|
|
||||||
function dragColumn(Table) {
|
function dragColumn(Table) {
|
||||||
|
|
||||||
return function (_Component) {
|
return function (_Component) {
|
||||||
_inherits(DragColumn, _Component);
|
_inherits(DragColumn, _Component);
|
||||||
|
|
||||||
function DragColumn(props) {
|
function DragColumn(props) {
|
||||||
_classCallCheck(this, DragColumn);
|
_classCallCheck(this, DragColumn);
|
||||||
|
|
||||||
var _this = _possibleConstructorReturn(this, _Component.call(this, props));
|
var _this = _possibleConstructorReturn(this, _Component.call(this, props));
|
||||||
|
|
||||||
_this.setColumOrderByIndex = function (_column) {
|
_this.setColumOrderByIndex = function (_column) {
|
||||||
_column.forEach(function (da, i) {
|
_column.forEach(function (da, i) {
|
||||||
da.dragIndex = i;
|
da.dragIndex = i;
|
||||||
da.drgHover = false;
|
da.drgHover = false;
|
||||||
});
|
});
|
||||||
return _column;
|
return _column;
|
||||||
};
|
};
|
||||||
|
|
||||||
_this.onDragEnd = function (event, data) {
|
_this.onDragEnd = function (event, data) {
|
||||||
var dragSource = data.dragSource,
|
var dragSource = data.dragSource,
|
||||||
dragTarg = data.dragTarg;
|
dragTarg = data.dragTarg;
|
||||||
var columns = _this.state.columns;
|
var columns = _this.state.columns;
|
||||||
|
|
||||||
var sourceIndex = -1,
|
var sourceIndex = -1,
|
||||||
targetIndex = -1;
|
targetIndex = -1;
|
||||||
|
|
||||||
sourceIndex = columns.findIndex(function (da, i) {
|
sourceIndex = columns.findIndex(function (da, i) {
|
||||||
return da.key == dragSource.key;
|
return da.key == dragSource.key;
|
||||||
});
|
});
|
||||||
targetIndex = columns.findIndex(function (da, i) {
|
targetIndex = columns.findIndex(function (da, i) {
|
||||||
return da.key == dragTarg.key;
|
return da.key == dragTarg.key;
|
||||||
});
|
});
|
||||||
// 向前移动
|
// 向前移动
|
||||||
if (targetIndex < sourceIndex) {
|
if (targetIndex < sourceIndex) {
|
||||||
targetIndex = targetIndex + 1;
|
targetIndex = targetIndex + 1;
|
||||||
|
}
|
||||||
|
columns.splice(targetIndex, 0, columns.splice(sourceIndex, 1)[0]);
|
||||||
|
var _newColumns = [];
|
||||||
|
columns.forEach(function (da, i) {
|
||||||
|
var newDate = _extends(da, {});
|
||||||
|
newDate.title = da.title;
|
||||||
|
_newColumns.push(newDate);
|
||||||
|
});
|
||||||
|
_this.setState({
|
||||||
|
columns: _newColumns //cloneDeep(columns)
|
||||||
|
});
|
||||||
|
if (_this.props.onDragEnd) {
|
||||||
|
_this.props.onDragEnd(event, data, columns);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
_this.getTarget = function (evt) {
|
||||||
|
return evt.target || evt.srcElement;
|
||||||
|
};
|
||||||
|
|
||||||
|
_this.state = {
|
||||||
|
columns: _this.setColumOrderByIndex(props.columns)
|
||||||
|
};
|
||||||
|
return _this;
|
||||||
}
|
}
|
||||||
columns.splice(targetIndex, 0, columns.splice(sourceIndex, 1)[0]);
|
|
||||||
var _newColumns = [];
|
DragColumn.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
||||||
columns.forEach(function (da, i) {
|
if (nextProps.columns != this.props.columns) {
|
||||||
var newDate = _extends(da, {});
|
this.setState({
|
||||||
newDate.title = da.title;
|
columns: this.setColumOrderByIndex(nextProps.columns)
|
||||||
_newColumns.push(newDate);
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
DragColumn.prototype.recursion = function (_recursion) {
|
||||||
|
function recursion(_x) {
|
||||||
|
return _recursion.apply(this, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
recursion.toString = function () {
|
||||||
|
return _recursion.toString();
|
||||||
|
};
|
||||||
|
|
||||||
|
return recursion;
|
||||||
|
}(function (obj) {
|
||||||
|
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||||
|
|
||||||
|
for (key in obj) {
|
||||||
|
if (_typeof(obj[key]) == 'object' && Object.keys(obj[key].length > 0)) {
|
||||||
|
data[key] = recursion(obj[key]);
|
||||||
|
} else {
|
||||||
|
data[key] = obj[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return data;
|
||||||
});
|
});
|
||||||
_this.setState({
|
|
||||||
columns: _newColumns //cloneDeep(columns)
|
|
||||||
});
|
|
||||||
if (_this.props.onDragEnd) {
|
|
||||||
_this.props.onDragEnd(event, data, columns);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
_this.getTarget = function (evt) {
|
DragColumn.prototype.render = function render() {
|
||||||
return evt.target || evt.srcElement;
|
var _props = this.props,
|
||||||
};
|
data = _props.data,
|
||||||
|
dragborder = _props.dragborder,
|
||||||
|
draggable = _props.draggable,
|
||||||
|
className = _props.className,
|
||||||
|
others = _objectWithoutProperties(_props, ['data', 'dragborder', 'draggable', 'className']);
|
||||||
|
|
||||||
_this.state = {
|
return _react2["default"].createElement(Table, _extends({}, others, {
|
||||||
columns: _this.setColumOrderByIndex(props.columns)
|
columns: this.state.columns,
|
||||||
};
|
data: data,
|
||||||
return _this;
|
className: className + ' u-table-drag-border',
|
||||||
}
|
onDragEnd: this.onDragEnd,
|
||||||
|
draggable: draggable,
|
||||||
|
dragborder: dragborder
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
DragColumn.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
return DragColumn;
|
||||||
if (nextProps.columns != this.props.columns) {
|
}(_react.Component);
|
||||||
this.setState({
|
|
||||||
columns: this.setColumOrderByIndex(nextProps.columns)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
DragColumn.prototype.recursion = function (_recursion) {
|
|
||||||
function recursion(_x) {
|
|
||||||
return _recursion.apply(this, arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
recursion.toString = function () {
|
|
||||||
return _recursion.toString();
|
|
||||||
};
|
|
||||||
|
|
||||||
return recursion;
|
|
||||||
}(function (obj) {
|
|
||||||
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
||||||
|
|
||||||
for (key in obj) {
|
|
||||||
if (_typeof(obj[key]) == 'object' && Object.keys(obj[key].length > 0)) {
|
|
||||||
data[key] = recursion(obj[key]);
|
|
||||||
} else {
|
|
||||||
data[key] = obj[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
});
|
|
||||||
|
|
||||||
DragColumn.prototype.render = function render() {
|
|
||||||
var _props = this.props,
|
|
||||||
data = _props.data,
|
|
||||||
dragborder = _props.dragborder,
|
|
||||||
draggable = _props.draggable,
|
|
||||||
className = _props.className,
|
|
||||||
others = _objectWithoutProperties(_props, ['data', 'dragborder', 'draggable', 'className']);
|
|
||||||
|
|
||||||
return _react2["default"].createElement(Table, _extends({}, others, {
|
|
||||||
columns: this.state.columns,
|
|
||||||
data: data,
|
|
||||||
className: className + ' u-table-drag-border',
|
|
||||||
onDragEnd: this.onDragEnd,
|
|
||||||
draggable: draggable,
|
|
||||||
dragborder: dragborder
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
|
|
||||||
return DragColumn;
|
|
||||||
}(_react.Component);
|
|
||||||
}
|
}
|
||||||
module.exports = exports['default'];
|
module.exports = exports['default'];
|
|
@ -94,6 +94,9 @@ function sum(Table) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var _sum = (0, _utils.DicimalFormater)(count, precision);
|
var _sum = (0, _utils.DicimalFormater)(count, precision);
|
||||||
|
if (column.sumThousandth) {
|
||||||
|
_sum = _this.toThousands(_sum);
|
||||||
|
}
|
||||||
sumdata[column.dataIndex] = _sum;
|
sumdata[column.dataIndex] = _sum;
|
||||||
if (column.sumRender && typeof column.sumRender == 'function') {
|
if (column.sumRender && typeof column.sumRender == 'function') {
|
||||||
sumdata[column.dataIndex] = column.sumRender(_sum);
|
sumdata[column.dataIndex] = column.sumRender(_sum);
|
||||||
|
@ -114,10 +117,26 @@ function sum(Table) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前的表格类型。
|
* 获取当前的表格类型。
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
SumTable.prototype.toThousands = function toThousands(num) {
|
||||||
|
var result = '',
|
||||||
|
counter = 0;
|
||||||
|
num = (num || 0).toString();
|
||||||
|
var numArr = num.split('.');
|
||||||
|
num = numArr[0];
|
||||||
|
for (var i = num.length - 1; i >= 0; i--) {
|
||||||
|
counter++;
|
||||||
|
result = num.charAt(i) + result;
|
||||||
|
if (!(counter % 3) && i != 0) {
|
||||||
|
result = ',' + result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return numArr.length === 1 ? result : result + '.' + numArr[1];
|
||||||
|
};
|
||||||
|
|
||||||
SumTable.prototype.render = function render() {
|
SumTable.prototype.render = function render() {
|
||||||
return _react2["default"].createElement(Table, _extends({}, this.props, {
|
return _react2["default"].createElement(Table, _extends({}, this.props, {
|
||||||
columns: this.props.columns,
|
columns: this.props.columns,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
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; };
|
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; };
|
||||||
|
@ -20,29 +20,29 @@ exports.ObjectAssign = ObjectAssign;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function sortBy(arr, prop, desc) {
|
function sortBy(arr, prop, desc) {
|
||||||
var props = [],
|
var props = [],
|
||||||
ret = [],
|
ret = [],
|
||||||
i = 0,
|
i = 0,
|
||||||
len = arr.length;
|
len = arr.length;
|
||||||
if (typeof prop == 'string') {
|
if (typeof prop == 'string') {
|
||||||
for (; i < len; i++) {
|
for (; i < len; i++) {
|
||||||
var oI = arr[i];
|
var oI = arr[i];
|
||||||
(props[i] = new String(oI && oI[prop] || ''))._obj = oI;
|
(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 '参数类型错误';
|
|
||||||
}
|
}
|
||||||
props.sort();
|
} else if (typeof prop == 'function') {
|
||||||
for (i = 0; i < len; i++) {
|
for (; i < len; i++) {
|
||||||
ret[i] = props[i]._obj;
|
var _oI = arr[i];
|
||||||
|
(props[i] = new String(_oI && prop(_oI) || ''))._obj = _oI;
|
||||||
}
|
}
|
||||||
if (desc) ret.reverse();
|
} else {
|
||||||
return ret;
|
throw '参数类型错误';
|
||||||
|
}
|
||||||
|
props.sort();
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
ret[i] = props[i]._obj;
|
||||||
|
}
|
||||||
|
if (desc) ret.reverse();
|
||||||
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,11 +51,11 @@ function sortBy(arr, prop, desc) {
|
||||||
* @param {} property
|
* @param {} property
|
||||||
*/
|
*/
|
||||||
function compare(property) {
|
function compare(property) {
|
||||||
return function (a, b) {
|
return function (a, b) {
|
||||||
var value1 = a[property];
|
var value1 = a[property];
|
||||||
var value2 = b[property];
|
var value2 = b[property];
|
||||||
return value1 - value2;
|
return value1 - value2;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,17 +63,17 @@ function compare(property) {
|
||||||
* @param {*} obj 要拷贝的对象
|
* @param {*} obj 要拷贝的对象
|
||||||
*/
|
*/
|
||||||
function ObjectAssign(obj) {
|
function ObjectAssign(obj) {
|
||||||
var b = obj instanceof Array;
|
var b = obj instanceof Array;
|
||||||
var tagObj = b ? [] : {};
|
var tagObj = b ? [] : {};
|
||||||
if (b) {
|
if (b) {
|
||||||
//数组
|
//数组
|
||||||
obj.forEach(function (da) {
|
obj.forEach(function (da) {
|
||||||
var _da = {};
|
var _da = {};
|
||||||
_extends(_da, da);
|
_extends(_da, da);
|
||||||
tagObj.push(_da);
|
tagObj.push(_da);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
_extends(tagObj, obj);
|
_extends(tagObj, obj);
|
||||||
}
|
}
|
||||||
return tagObj;
|
return tagObj;
|
||||||
}
|
}
|
|
@ -8,10 +8,10 @@
|
||||||
|
|
||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
import {Checkbox} from "tinper-bee";
|
import {Checkbox} from "tinper-bee";
|
||||||
import Table from "../../src";
|
import Table from "../../src";
|
||||||
import sum from "../../src/lib/sum.js";
|
import sum from "../../src/lib/sum.js";
|
||||||
import multiSelect from "../../src/lib/multiSelect.js";
|
import multiSelect from "../../src/lib/multiSelect.js";
|
||||||
|
|
||||||
let ComplexTable = multiSelect(sum(Table), Checkbox);
|
let ComplexTable = multiSelect(sum(Table), Checkbox);
|
||||||
//sum第二个参数可以设置精度,例如 sum(Table,4); 设计精度为4
|
//sum第二个参数可以设置精度,例如 sum(Table,4); 设计精度为4
|
||||||
let _sum = 0;
|
let _sum = 0;
|
||||||
|
@ -57,14 +57,16 @@ const columns = [
|
||||||
dataIndex: "total",
|
dataIndex: "total",
|
||||||
key: "total",
|
key: "total",
|
||||||
width: 100,
|
width: 100,
|
||||||
sumCol: true
|
sumCol: true,
|
||||||
|
sumThousandth: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "金额",
|
title: "金额",
|
||||||
dataIndex: "money",
|
dataIndex: "money",
|
||||||
key: "money",
|
key: "money",
|
||||||
width: 100,
|
width: 100,
|
||||||
sumCol: true
|
sumCol: true,
|
||||||
|
sumThousandth: true
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -80,7 +82,7 @@ function getData(){
|
||||||
contact: "Tom",
|
contact: "Tom",
|
||||||
warehouse: "普通仓",
|
warehouse: "普通仓",
|
||||||
total: i + Math.floor(Math.random()*10),
|
total: i + Math.floor(Math.random()*10),
|
||||||
money: 20 * Math.floor(Math.random()*10)
|
money: 2000 * Math.floor(Math.random()*10)
|
||||||
});
|
});
|
||||||
_sum += data[i].total;
|
_sum += data[i].total;
|
||||||
_sum += data[i].money;
|
_sum += data[i].money;
|
||||||
|
@ -89,7 +91,7 @@ function getData(){
|
||||||
}
|
}
|
||||||
|
|
||||||
class Demo35 extends Component {
|
class Demo35 extends Component {
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
|
@ -102,7 +104,7 @@ class Demo35 extends Component {
|
||||||
const {data} = this.state;
|
const {data} = this.state;
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<ComplexTable
|
<ComplexTable
|
||||||
columns={columns}
|
columns={columns}
|
||||||
data={data}
|
data={data}
|
||||||
bordered
|
bordered
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -452,8 +452,8 @@
|
||||||
color: rgb(33, 33, 33);
|
color: rgb(33, 33, 33);
|
||||||
background-clip: padding-box;
|
background-clip: padding-box;
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
/*
|
/*
|
||||||
Introduced in IE 10.
|
Introduced in IE 10.
|
||||||
*/
|
*/
|
||||||
-ms-user-select: none;
|
-ms-user-select: none;
|
||||||
user-select: none; }
|
user-select: none; }
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
194
package.json
194
package.json
|
@ -1,99 +1,99 @@
|
||||||
{
|
{
|
||||||
"name": "bee-table",
|
"name": "bee-table",
|
||||||
"version": "2.2.68",
|
"version": "2.2.68",
|
||||||
"description": "Table ui component for react",
|
"description": "Table ui component for react",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react",
|
"react",
|
||||||
"react-component",
|
"react-component",
|
||||||
"bee-table",
|
"bee-table",
|
||||||
"iuap-design"
|
"iuap-design"
|
||||||
],
|
],
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.0.0"
|
"node": ">=6.0.0"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"moduleFileExtensions": [
|
"moduleFileExtensions": [
|
||||||
"js",
|
"js",
|
||||||
"jsx"
|
"jsx"
|
||||||
],
|
],
|
||||||
"transform": {
|
"transform": {
|
||||||
"^.+\\.js$": "babel-jest"
|
"^.+\\.js$": "babel-jest"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/tinper-bee/bee-table.git",
|
"homepage": "https://github.com/tinper-bee/bee-table.git",
|
||||||
"author": "Yonyou FED",
|
"author": "Yonyou FED",
|
||||||
"repository": "http://github.com/tinper-bee/bee-table",
|
"repository": "http://github.com/tinper-bee/bee-table",
|
||||||
"bugs": "https://github.com/tinper-bee/bee-table.git/issues",
|
"bugs": "https://github.com/tinper-bee/bee-table.git/issues",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "./build/index.js",
|
"main": "./build/index.js",
|
||||||
"config": {
|
"config": {
|
||||||
"port": 3000,
|
"port": 3000,
|
||||||
"commitizen": {
|
"commitizen": {
|
||||||
"path": "./node_modules/cz-conventional-changelog"
|
"path": "./node_modules/cz-conventional-changelog"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "bee-tools run start",
|
"dev": "bee-tools run start",
|
||||||
"build": "bee-tools run build",
|
"build": "bee-tools run build",
|
||||||
"lint": "bee-tools run lint",
|
"lint": "bee-tools run lint",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"chrome": "bee-tools run chrome",
|
"chrome": "bee-tools run chrome",
|
||||||
"coveralls": "jest",
|
"coveralls": "jest",
|
||||||
"browsers": "bee-tools run browsers",
|
"browsers": "bee-tools run browsers",
|
||||||
"pub": "bee-tools run pub",
|
"pub": "bee-tools run pub",
|
||||||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
|
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
|
||||||
"version": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md",
|
"version": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md",
|
||||||
"postversion": "git push --follow-tags",
|
"postversion": "git push --follow-tags",
|
||||||
"prepublishOnly": "npm run build"
|
"prepublishOnly": "npm run build"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bee-button": "latest",
|
"bee-button": "latest",
|
||||||
"bee-checkbox": "latest",
|
"bee-checkbox": "latest",
|
||||||
"bee-datepicker": "^2.0.28",
|
"bee-datepicker": "^2.0.28",
|
||||||
"bee-dropdown": "^2.0.4",
|
"bee-dropdown": "^2.0.4",
|
||||||
"bee-form-control": "latest",
|
"bee-form-control": "latest",
|
||||||
"bee-icon": "latest",
|
"bee-icon": "latest",
|
||||||
"bee-input-number": "^2.0.7",
|
"bee-input-number": "^2.0.7",
|
||||||
"bee-loading": "1.1.2",
|
"bee-loading": "1.1.2",
|
||||||
"bee-locale": "0.0.14",
|
"bee-locale": "0.0.14",
|
||||||
"bee-menus": "^2.0.6",
|
"bee-menus": "^2.0.6",
|
||||||
"bee-radio": "^2.0.16",
|
"bee-radio": "^2.0.16",
|
||||||
"bee-select": "^2.0.11",
|
"bee-select": "^2.0.11",
|
||||||
"classnames": "^2.2.5",
|
"classnames": "^2.2.5",
|
||||||
"component-classes": "^1.2.6",
|
"component-classes": "^1.2.6",
|
||||||
"lodash.clonedeep": "^4.5.0",
|
"lodash.clonedeep": "^4.5.0",
|
||||||
"object-path": "^0.11.3",
|
"object-path": "^0.11.3",
|
||||||
"shallowequal": "^1.0.2",
|
"shallowequal": "^1.0.2",
|
||||||
"throttle-debounce": "^2.0.1",
|
"throttle-debounce": "^2.0.1",
|
||||||
"tinper-bee-core": "latest",
|
"tinper-bee-core": "latest",
|
||||||
"warning": "^3.0.0"
|
"warning": "^3.0.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "^15.3.0 || ^16.0",
|
"react": "^15.3.0 || ^16.0",
|
||||||
"react-dom": "^15.3.0 || ^16.0",
|
"react-dom": "^15.3.0 || ^16.0",
|
||||||
"prop-types": "^15.6.0"
|
"prop-types": "^15.6.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-jest": "^22.0.4",
|
"babel-jest": "^22.0.4",
|
||||||
"bee-clipboard": "^2.0.0",
|
"bee-clipboard": "^2.0.0",
|
||||||
"bee-drawer": "0.0.2",
|
"bee-drawer": "0.0.2",
|
||||||
"bee-layout": "latest",
|
"bee-layout": "latest",
|
||||||
"bee-pagination": "^2.0.5",
|
"bee-pagination": "^2.0.5",
|
||||||
"bee-panel": "latest",
|
"bee-panel": "latest",
|
||||||
"bee-popover": "^3.0.2",
|
"bee-popover": "^3.0.2",
|
||||||
"bee-switch": "^2.0.6",
|
"bee-switch": "^2.0.6",
|
||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
"console-polyfill": "~0.2.1",
|
"console-polyfill": "~0.2.1",
|
||||||
"cz-conventional-changelog": "^2.1.0",
|
"cz-conventional-changelog": "^2.1.0",
|
||||||
"enzyme": "^2.9.1",
|
"enzyme": "^2.9.1",
|
||||||
"es5-shim": "~4.1.10",
|
"es5-shim": "~4.1.10",
|
||||||
"jest": "^22.0.4",
|
"jest": "^22.0.4",
|
||||||
"react": "^16.6.3",
|
"react": "^16.6.3",
|
||||||
"react-addons-test-utils": "^15.5.0",
|
"react-addons-test-utils": "^15.5.0",
|
||||||
"react-dom": "^16.6.3",
|
"react-dom": "^16.6.3",
|
||||||
"ref-tree": "2.0.1-beta.1",
|
"ref-tree": "2.0.1-beta.1",
|
||||||
"reqwest": "^2.0.5",
|
"reqwest": "^2.0.5",
|
||||||
"tinper-bee": "latest",
|
"tinper-bee": "latest",
|
||||||
"husky": "^4.2.5"
|
"husky": "^4.2.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ export default function sum(Table,precision=2) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前的表格类型。
|
* 获取当前的表格类型。
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
getTableType=()=>{
|
getTableType=()=>{
|
||||||
const {columns} = this.props;
|
const {columns} = this.props;
|
||||||
|
@ -37,7 +37,18 @@ export default function sum(Table,precision=2) {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toThousands(num) {
|
||||||
|
let result = '', counter = 0;
|
||||||
|
num = (num || 0).toString();
|
||||||
|
const numArr = num.split('.')
|
||||||
|
num = numArr[0]
|
||||||
|
for (var i = num.length - 1; i >= 0; i--) {
|
||||||
|
counter++;
|
||||||
|
result = num.charAt(i) + result;
|
||||||
|
if (!(counter % 3) && i != 0) { result = ',' + result; }
|
||||||
|
}
|
||||||
|
return numArr.length === 1 ? result : result +'.' +numArr[1];
|
||||||
|
}
|
||||||
|
|
||||||
addSumData=()=>{
|
addSumData=()=>{
|
||||||
let {data=[],columns=[]} = this.props;
|
let {data=[],columns=[]} = this.props;
|
||||||
|
@ -56,26 +67,29 @@ export default function sum(Table,precision=2) {
|
||||||
if(column.sumCol){
|
if(column.sumCol){
|
||||||
let count = 0;
|
let count = 0;
|
||||||
data.forEach((da,i)=>{
|
data.forEach((da,i)=>{
|
||||||
|
|
||||||
let _num = parseFloat(da[column.key]);
|
let _num = parseFloat(da[column.key]);
|
||||||
//排查字段值为NAN情况
|
//排查字段值为NAN情况
|
||||||
if(_num == _num){
|
if(_num == _num){
|
||||||
count += _num;
|
count += _num;
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
let sum = DicimalFormater(count,precision);
|
let sum = DicimalFormater(count,precision);
|
||||||
|
if(column.sumThousandth) {
|
||||||
|
sum = this.toThousands(sum)
|
||||||
|
}
|
||||||
sumdata[column.dataIndex] = sum;
|
sumdata[column.dataIndex] = sum;
|
||||||
if(column.sumRender&&typeof column.sumRender =='function'){
|
if(column.sumRender&&typeof column.sumRender =='function'){
|
||||||
sumdata[column.dataIndex] = column.sumRender(sum)
|
sumdata[column.dataIndex] = column.sumRender(sum)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if(index == 0){
|
if(index == 0){
|
||||||
sumdata[column.dataIndex] = "合计 "+sumdata[column.dataIndex];
|
sumdata[column.dataIndex] = "合计 "+sumdata[column.dataIndex];
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
newData.push(sumdata);
|
newData.push(sumdata);
|
||||||
return newData;
|
return newData;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue