Ver código fonte

Merge branch 'master' of http://192.168.1.41:3000/SmartCost/ConstructionCost

vian 5 anos atrás
pai
commit
0549b0ad11

+ 9 - 7
modules/reports/rpt_component/helper/jpc_helper_common_output.js

@@ -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());
                 }

+ 2 - 0
modules/reports/rpt_component/jpc_rte.js

@@ -2,9 +2,11 @@
  * Created by Tony on 2016/12/28.
  */
 let strUtil = require('../../../public/stringUtil');
+const scMathUtil = require('../../../public/scMathUtil').getUtil();
 let JV = require('./jpc_value_define');
 let JE = {
     $STR_UTIL: strUtil,
+    $SC_MATH_UTIL: scMathUtil,
     F: function(fID, $CURRENT_RPT) {
         let rst = null;
         if ($CURRENT_RPT && ($CURRENT_RPT.fields[JV.NODE_DETAIL_FIELDS][JV.PROP_ID + "_" + fID])) {