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