浏览代码

Merge branch 'master' of http://smartcost.f3322.net:3000/SmartCost/YangHuCost

zhangweicheng 6 年之前
父节点
当前提交
3c3071a455

+ 1 - 0
modules/reports/rpt_component/jpc_ex.js

@@ -168,6 +168,7 @@ JpcExSrv.prototype.createNew = function(){
         let me = this, dftPagingOption = option||JV.PAGING_OPTION_NORMAL;
         //1. data object
         let dataHelper = JpcData.createNew();
+        me.executeFormulas(JV.RUN_TYPE_BEFORE_ANALYZING, rptTpl, dataObj, me); //在分析前运行,主要是增加灵活性,比如:重新编排数据的主从关系
         if (me.crossTab) {
             me.executeFormulas(JV.RUN_TYPE_BEFORE_PAGING, rptTpl, dataObj, me);
             dataHelper.analyzeData(rptTpl, dataObj);

+ 1 - 0
public/web/rpt_value_define.js

@@ -198,6 +198,7 @@ const JV = {
     PROP_INSERTED_GRP_REC: "insertedGrpRecAmt",
     PROP_GRP_LINES: "group_lines_amt",
 
+    RUN_TYPE_BEFORE_ANALYZING: "before_analyzing",
     RUN_TYPE_BEFORE_PAGING: "before_paging",
     RUN_TYPE_BEFORE_OUTPUT: "before_output",
 

+ 8 - 5
test/unit/reports/test_rpt_test_template.js

@@ -36,7 +36,9 @@ let demoPrjId = - 1;
 // let demoRptId = 20; //01
 // let demoRptId = 23; //04 综合费率表
 
-let demoRptId = 56; //24
+// let demoRptId = 56; //24
+let demoRptId = 36; //5.1
+
 
 let pagesize = "A4";
 //288: 11-2表(新)
@@ -50,8 +52,9 @@ let userId_Leng = "5c3ffa9aa0a92732f41216e0"; //小冷User Id (养护的)
 // demoPrjId = 2260; //QA:
 // demoPrjId = 410; //QA:
 // demoPrjId = 313; //PROD:
-demoPrjId = 455; //PROD:
+// demoPrjId = 455; //PROD:
 // demoPrjId = 618; //PROD:
+demoPrjId = 815; //PROD:
 // demoPrjId = 4107; //UAT:
 //*/
 let userId_Dft = userId_Leng;
@@ -86,9 +89,9 @@ test('测试 - 测试模板啦: ', function (t) {
         rptTplDataFacade.prepareProjectData(userId_Dft, demoPrjId, filter, function (err, msg, rawDataObj) {
             if (!err) {
                 try {
-                    fsUtil.writeObjToFile(rawDataObj, "D:/GitHome/YangHuCost/tmp/rptTplRawDataObject_测试模板.jsp");
+                    // fsUtil.writeObjToFile(rawDataObj, "D:/GitHome/YangHuCost/tmp/rptTplRawDataObject_测试模板.jsp");
                     let tplData = rptDataUtil.assembleData(rawDataObj);
-                    fsUtil.writeObjToFile(rawDataObj, "D:/GitHome/YangHuCost/tmp/rptTplRawDataAfterCacl_测试模板.jsp");
+                    // fsUtil.writeObjToFile(rawDataObj, "D:/GitHome/YangHuCost/tmp/rptTplRawDataAfterCacl_测试模板.jsp");
                     // fsUtil.writeObjToFile(tplData, "D:/GitHome/YangHuCost/tmp/rptTplAssembledData_测试模板.jsp");
                     //it's time to build the report!!!
                     let printCom = JpcEx.createNew();
@@ -101,7 +104,7 @@ test('测试 - 测试模板啦: ', function (t) {
                     let customizeCfg = {"fillZero": true};
                     let pageRst = printCom.outputAsSimpleJSONPageArray(rptTpl, tplData, 1, maxPages, defProperties, customizeCfg);
                     if (pageRst) {
-                        fsUtil.writeObjToFile(pageRst, "D:/GitHome/YangHuCost/tmp/testBuiltPageResult_测试模板.jsp");
+                        // fsUtil.writeObjToFile(pageRst, "D:/GitHome/YangHuCost/tmp/testBuiltPageResult_测试模板.jsp");
                         // rpt_xl_util.exportExcel(pageRst, pagesize, "local_test_rpt_excel", true, null, null, function(uuidName){
                         //     console.log("excel uuid: " + uuidName);
                         // });

+ 15 - 18
web/building_saas/main/js/models/calc_program.js

@@ -1657,16 +1657,17 @@ class CalcProgram {
                 if (treeNode.calcType == treeNodeCalcType.ctGatherBillsFees){
                     for (let node of nodes) {
                         if (node.data.feesIndex && node.data.feesIndex[ft.type]) {
-                            if (projectObj.project.property.valuationType === 'bill') { // 预算
-                                buf = (buf + parseFloatPlus(node.data.feesIndex[ft.type].unitFee)).toDecimal(decimalObj.process);
-                                btuf = (btuf + parseFloatPlus(node.data.feesIndex[ft.type].tenderUnitFee)).toDecimal(decimalObj.process);
-                            };
                             btf = (btf + parseFloatPlus(node.data.feesIndex[ft.type].totalFee)).toDecimal(decimalObj.process);
                             bttf = (bttf + parseFloatPlus(node.data.feesIndex[ft.type].tenderTotalFee)).toDecimal(decimalObj.process);
+
+                            if (calcTools.isBudgetProject()){
+                                buf = (btf / bq).toDecimal(decimalObj.process);
+                                btuf = (bttf / bq).toDecimal(decimalObj.process);
+                            }
                         };
                     };
                 }
-                else if (treeNode.calcType == treeNodeCalcType.ctGatherRationsFees){     // 这里的算法要配合冷姐姐的神图才能看懂^_^
+                else if (treeNode.calcType == treeNodeCalcType.ctGatherRationsFees){
                     let sum_rtf = 0, sum_rttf = 0;
                     for (let node of nodes) {
                         let ruf = 0, rtuf = 0, rtf = 0, rttf = 0;
@@ -1747,16 +1748,14 @@ class CalcProgram {
 
                 if (treeNode.data.calcFlag == treeNodeCalcFlag.customUnitPrice){    // 修改了清单单价:以单价为准,算金额
                     uf = parseFloatPlus(treeNode.data.feesIndex.common.unitFee);
-                    if (nQ == 0) nQ = 1;
                     tf = (uf * nQ).toDecimal(decimalObj.bills.totalPrice);
                 }
                 else if (treeNode.data.calcFlag == treeNodeCalcFlag.customTotalPrice){  // 修改了清单金额:以金额为准,算单价。修改了清单数量也一样
                     tf = parseFloatPlus(treeNode.data.feesIndex.common.totalFee);
-                    uf = nQ ? (tf / nQ) : tf;        // 如果工程量为0或空,综合合单直接填到综合单
+                    uf = nQ ? (tf / nQ) : tf;        // 如果工程量为0或空,综合单价直接等于综合合
                     uf = uf.toDecimal(decimalObj.bills.unitPrice);
-                    if (projectObj.project.property.valuationType != 'bill') {  // 招投标项目, 还要反算
-                        let nQ2 = nQ ? nQ : 1;
-                        tf = (uf * nQ2).toDecimal(decimalObj.bills.totalPrice);
+                    if (calcTools.isBillProject()) {  // 招投标项目, 还要反算
+                        tf = (uf * nQ).toDecimal(decimalObj.bills.totalPrice);
                     };
                 };
 
@@ -1765,14 +1764,12 @@ class CalcProgram {
                 calcTools.checkFeeField(treeNode, ftObj);
 
                 // 数量、金额时,同步定额建安费
-                // if (treeNode.data.calcFlag == treeNodeCalcFlag.customUnitPrice || treeNode.data.calcFlag == treeNodeCalcFlag.customTotalPrice){
-                    let ftObj2 = {
-                        fieldName: 'rationCommon',
-                        unitFee: uf,
-                        totalFee: tf
-                    };
-                    calcTools.checkFeeField(treeNode, ftObj2);
-                // };
+                let ftObj2 = {
+                    fieldName: 'rationCommon',
+                    unitFee: uf,
+                    totalFee: tf
+                };
+                calcTools.checkFeeField(treeNode, ftObj2);
             }
 
             treeNode.data.calcTemplate = {"calcItems": []};