Prechádzať zdrojové kódy

指标增加精度处理接口

TonyKang 5 rokov pred
rodič
commit
2d498ffbca

+ 21 - 0
app/reports/util/rpt_calculation_data_util.js

@@ -768,6 +768,7 @@ function setupFunc(obj, ownRawObj, baseDir) {
     obj.getSplitProperty = ext_getSplitProperty;
     obj.getPicProperty = ext_getPicProperty;
     // obj.getPropertyByForeignId = ext_getPropertyByForeignId;
+    obj.getPreferPrecisionProperty = ext_getPreferPrecisionProperty;
     obj.getArrayProperty = ext_getArrayValues;
     obj.getBlank = ext_getBlank;
 }
@@ -860,6 +861,26 @@ function getDeepProperty(propKey, orgObj, destArr) {
     }
 }
 
+function ext_getPreferPrecisionProperty(dataKey, preferKey, preferPropKey, dftPropKey) {
+    // 通过一个开关(preferKey)来控制精度,如为true,则选择preferPropKey,否则选择dftPropKey
+    const rst = [];
+    const parentObj = this;
+    const dtObj = parentObj.myOwnRawDataObj[dataKey];
+    if (preferKey && preferPropKey && dftPropKey && dtObj) {
+        const da = getActDataArr(dtObj);
+        if (da.length === 1) {
+            const pKey = [];
+            pri_push_property(preferKey, da[0], pKey);
+            if (pKey.length > 0 && pKey[0]) {
+                pri_push_property(preferPropKey, da[0], rst);
+            } else {
+                pri_push_property(dftPropKey, da[0], rst);
+            }
+        }
+    }
+    return rst;
+}
+
 function ext_getProperty(dataKey, propKey) {
     const rst = [];
     const parentObj = this;