Procházet zdrojové kódy

09-1表明细丢失表栏 + 工料机明细统计出错

TonyKang před 7 roky
rodič
revize
dbf3e0518b

+ 1 - 2
modules/reports/rpt_component/jpc_flow_tab.js

@@ -52,8 +52,7 @@ JpcFlowTabSrv.prototype.createNew = function(){
         let private_inner_add_grp_rec = function(vi) {
             let hasFullGrp = true, couldBreak = false;
             for (let i = 0; i < grp_lines; i++) {
-                // if ( ((vi + insertedGrpAmt * grp_lines) + i + 1) >= (maxRecPerPage - preAmt)) {
-                if ( (vIdx.length + i ) >= maxRecPerPage) {
+                if (vIdx.length >= maxRecPerPage) {
                     for (let j = i; j < grp_lines; j++) {
                         grpPageInfo[JV.PROP_PRE_ADD_GRP_REC_INFO].push(j);
                     }

+ 34 - 0
modules/reports/util/rpt_construct_data_util.js

@@ -299,6 +299,37 @@ function summaryData(sourceData, handleCfg, prjData){
             tempRstArr.push(item);
         }
     }
+    let private_cal_before_sum = function () {
+        for (let calcAheadObj of handleCfg[JV.PROP_SUM_CALC_AHEAD]) {
+            if (!curParentPrjData[calcAheadObj["seeking_parent"]]) curParentPrjData[calcAheadObj["seeking_parent"]] = getModuleDataByKey(prjData, calcAheadObj["seeking_parent"]);
+            for (let pDataItem of curParentPrjData[calcAheadObj["seeking_parent"]].data) {
+                let data = (pDataItem._doc)?pDataItem._doc:pDataItem;
+                for (let item of tempRstArr) {
+                    if (item[calcAheadObj["seeking_key"]] === data[calcAheadObj["parent_key"]]) {
+                        for (let sumKey of handleCfg[JV.PROP_SUM_SUM_KEYS]) {
+                            switch (calcAheadObj[JV.PROP_SUM_CACL_TYPE]) {
+                                case "+":
+                                    item[sumKey] = parseFloat(item[sumKey]) + parseFloat(data[calcAheadObj["calc_property"]]);
+                                    break;
+                                case "-":
+                                    item[sumKey] = parseFloat(item[sumKey]) - parseFloat(data[calcAheadObj["calc_property"]]);
+                                    break;
+                                case "*":
+                                    item[sumKey] = item[sumKey] * parseFloat(data[calcAheadObj["calc_property"]]).toFixed(4);
+                                    break;
+                                case "/":
+                                    item[sumKey] = item[sumKey] / parseFloat(data[calcAheadObj["calc_property"]]).toFixed(4);
+                                    break;
+                                default:
+                                    break;
+                            }
+                        }
+                        break;
+                    }
+                }
+            }
+        }
+    };
     let private_get_grp_key = function (item) {
         let keys = [];
         for (let cfg of handleCfg[JV.PROP_SUM_GROUP_KEYS]) {
@@ -318,6 +349,9 @@ function summaryData(sourceData, handleCfg, prjData){
         return ( "grp_key_" + keys.join('_'));
     };
     let sumObj = {};
+    if (handleCfg[JV.PROP_SUM_CALC_AHEAD] && handleCfg[JV.PROP_SUM_CALC_AHEAD].length > 0) {
+        private_cal_before_sum();
+    }
     for (let dtl of tempRstArr) {
         let grpKey = private_get_grp_key(dtl);
         if (sumObj[grpKey] === null || sumObj[grpKey] === undefined) {

+ 2 - 0
public/web/rpt_value_define.js

@@ -80,6 +80,8 @@ const JV = {
     PROP_SORT_KEYS: "排序键值集",
     PROP_SUM_GROUP_KEYS: "分组键值集",
     PROP_SUM_SUM_KEYS: "统计键值集",
+    PROP_SUM_CALC_AHEAD: "统计前计算",
+    PROP_SUM_CACL_TYPE: "计算类型",
     PROP_FIELD_EXP_MAP: "mapExpression",
 
     NODE_FONT_COLLECTION: "font_collection",