提交 8e46991f 编写于 作者: 蔡祥熠

Merge branch 'fix/Process.submit_handwrit' into 'wrdp'

Merge of fix/Process.submit_handwrit 处理数据表格总计小数点保留位数的问题 to wrdp

See merge request o2oa/o2oa!4340
......@@ -379,17 +379,46 @@ MWF.xApplication.process.Xform.DatatablePC = new Class(
this.totalColumns.each(function(column, index){
var json = column.moduleJson;
if(!json)return;
var pointLength = 0; //小数点后的最大数位
var tmpV;
if (column.type === "count"){
tmpV = data.data.length;
}else if(column.type === "number"){
var tmpV = new Decimal(0);
tmpV = new Decimal(0);
for (var i=0; i<data.data.length; i++){
var d = data.data[i];
if(d[json.id])tmpV = tmpV.plus(d[json.id].toFloat() || 0);
if(d[json.id]){
tmpV = tmpV.plus(d[json.id].toFloat() || 0);
var v = d[json.id].toString();
if( v.indexOf(".") > -1 ){
pointLength = Math.max(pointLength, v.split(".")[1].length);
}
}
}
}
if( isNaN( tmpV ) ){
totalData[json.id] = "";
column.td.set("text", "" );
}else{
if( pointLength > 0 && tmpV.toString() !== "0" ){
var s = tmpV.toString();
if( s.indexOf(".") > -1 ){
var length = s.split(".")[1].length;
if( length < pointLength ){
totalData[json.id] = s + "0".repeat(pointLength-length);
}else{
totalData[json.id] = s;
}
}else{
totalData[json.id] = s +"."+ "0".repeat(pointLength)
}
}else{
totalData[json.id] = tmpV.toString();
}
column.td.set("text", totalData[json.id] );
}
totalData[json.id] = tmpV.toString();
column.td.set("text", isNaN( tmpV ) ? "" : tmpV );
}.bind(this));
data.total = totalData;
return totalData;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册