|
@@ -1,5 +1,6 @@
|
|
|
let JV = require('../jpc_value_define');
|
|
|
let JpcFieldHelper = require('./jpc_helper_field');
|
|
|
+const OFFSET_FLOAT = 0.0000000001;
|
|
|
|
|
|
let JpcCommonOutputHelper = {
|
|
|
createCommonOutputWithoutDecorate: function (node, value, forceCombine) {
|
|
@@ -43,13 +44,14 @@ let JpcCommonOutputHelper = {
|
|
|
}
|
|
|
return rst;
|
|
|
},
|
|
|
- formatCell: function (formatStr, rstCell) {
|
|
|
+ formatCell: function(formatStr, rstCell) {
|
|
|
if (formatStr) {
|
|
|
- if (!(isNaN(parseFloat(rstCell[JV.PROP_VALUE])))) {
|
|
|
- let dotIdx = formatStr.indexOf(".");
|
|
|
+ const rstCellFloatVal = parseFloat(rstCell[JV.PROP_VALUE]);
|
|
|
+ if (!(isNaN(rstCellFloatVal))) {
|
|
|
+ const dotIdx = formatStr.indexOf('.');
|
|
|
if (dotIdx >= 0) {
|
|
|
- let tmpStr = parseFloat(rstCell[JV.PROP_VALUE]).toFixed(formatStr.length - dotIdx - 1);
|
|
|
- let digStr = formatStr.substr(dotIdx + 1, formatStr.length - dotIdx);
|
|
|
+ let tmpStr = (rstCellFloatVal + OFFSET_FLOAT).toFixed(formatStr.length - dotIdx - 1);
|
|
|
+ const digStr = formatStr.substr(dotIdx + 1, formatStr.length - dotIdx);
|
|
|
for (let sIdx = digStr.length - 1; sIdx >= 0; sIdx--) {
|
|
|
if (digStr[sIdx] === '#') {
|
|
|
if (tmpStr.length > 0 && tmpStr[tmpStr.length - 1] === '0') {
|
|
@@ -64,9 +66,9 @@ let JpcCommonOutputHelper = {
|
|
|
if (tmpStr[tmpStr.length - 1] === '.') tmpStr = tmpStr.substr(0, tmpStr.length - 1);
|
|
|
rstCell[JV.PROP_VALUE] = tmpStr;
|
|
|
} else {
|
|
|
- rstCell[JV.PROP_VALUE] = parseFloat(rstCell[JV.PROP_VALUE]).toFixed(0);
|
|
|
+ rstCell[JV.PROP_VALUE] = (rstCellFloatVal + OFFSET_FLOAT).toFixed(0);
|
|
|
}
|
|
|
- let commaIdx = formatStr.indexOf(",");
|
|
|
+ const commaIdx = formatStr.indexOf(',');
|
|
|
if (commaIdx >= 0) {
|
|
|
rstCell[JV.PROP_VALUE] = comdify(rstCell[JV.PROP_VALUE].toString());
|
|
|
}
|