Ver código fonte

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

Conflicts:
	web/building_saas/main/js/models/calc_program.js
zhangweicheng 7 anos atrás
pai
commit
7c01aedb3f

+ 11 - 3
modules/reports/rpt_component/jpc_flow_tab.js

@@ -51,7 +51,8 @@ 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 ( ((vi + insertedGrpAmt * grp_lines) + i + 1) >= (maxRecPerPage - preAmt)) {
+                if ( (vIdx.length + i ) >= maxRecPerPage) {
                     for (let j = i; j < grp_lines; j++) {
                         grpPageInfo[JV.PROP_PRE_ADD_GRP_REC_INFO].push(j);
                     }
@@ -105,7 +106,12 @@ JpcFlowTabSrv.prototype.createNew = function(){
                     if (private_inner_add_grp_rec(vi)) break;
                     if (couldBreak) break;
                 } else {
-                    if (private_normal_add_rec(vi)) break;
+                    //备注: 在有group的情况下,如果grpPageInfo[JV.PROP_SEG_GRP_IDX] 范围大于 grpSequenceInfo.length,则表示已经到最后了,不要再加空白数据了
+                    if (grpPageInfo[JV.PROP_SEG_GRP_IDX] < grpSequenceInfo.length) {
+                        if (private_normal_add_rec(vi)) break;
+                    } else {
+                        break;
+                    }
                 }
             } else {
                 if (private_normal_add_rec(vi)) break;
@@ -428,7 +434,9 @@ JpcFlowTabSrv.prototype.createNew = function(){
                         private_chk_handle_rec_amt(dv, false);
                     }
                     //再处理下半部分
-                    private_addPageValue(me.dispValueIdxLst, followTabEx.segments[segIdx], null, counterRowRecEx, maxRowRec - mixSplitPoint, me.page_seg_map, segIdx, pageIdx, null, true, null, 0);
+                    let restRecAmt = maxRowRec - me.dispValueIdxLst[me.dispValueIdxLst.length - 1].length; //备注:在一些极端条件下,mixSplitPoint这个分割点不合适处理下半部分数据,以实际生成的value-index数量为准
+                    // private_addPageValue(me.dispValueIdxLst, followTabEx.segments[segIdx], null, counterRowRecEx, maxRowRec - mixSplitPoint, me.page_seg_map, segIdx, pageIdx, null, true, null, 0);
+                    private_addPageValue(me.dispValueIdxLst, followTabEx.segments[segIdx], null, counterRowRecEx, restRecAmt, me.page_seg_map, segIdx, pageIdx, null, true, null, 0);
                     for (let dv of me.dispValueIdxLst[me.dispValueIdxLst.length - 1]) {
                         private_chk_handle_rec_amt(dv, true);
                     }

+ 2 - 2
public/web/common_util.js

@@ -22,8 +22,8 @@ function parseFloatPlus(value){
 // 将arr2合并到arr1,并去重复。
 function mergeArr(arr1, arr2){
     if (arr2.length > 0){
-        for (let cNode of arr2){
-            if (!arr1.includes(cNode)) arr1.push(cNode);
+        for (let e of arr2){
+            if (!arr1.includes(e)) arr1.push(e);
         };
     }
 };

+ 10 - 7
test/unit/reports/test_cover_01.js

@@ -25,11 +25,13 @@ cfgCacheUtil.setupDftCache();
 let fsUtil = require("../../../public/fsUtil");
 
 let demoPrjId = - 1;
-let demoRptId = 223, pagesize = "A4";
+// let demoRptId = 223, pagesize = "A4";
+let demoRptId = 261, pagesize = "A4";
 
-demoPrjId = 1220; //QA:
+// demoPrjId = 1220; //QA:
+demoPrjId = 2260;
 //*
-let userId_Leng = "59cdf14a0034a1000ba52b97"; //小冷User Id 换成_id了
+let userId_Leng = "5acac1e885bf55000bd055ba"; //小冷User Id 换成_id了
 let userId_Dft = userId_Leng;
 /*/
  let userId_Dft = "595328da1934dc327cad08eb";
@@ -47,7 +49,7 @@ fs.readFile(__dirname.slice(0, __dirname.length - 18) + '/public/web/date_util.j
 });
 
 //*
-test('测试 - 打开模板: 封-1 ', function (t) {
+test('测试 - 打开模板: 封-3 ', function (t) {
     rptTplFacade.getRptTemplate(demoRptId).then(function(rptTpl) {
         let rptDataUtil = new rptDataExtractor();
         rptDataUtil.initialize(rptTpl._doc);
@@ -57,8 +59,9 @@ test('测试 - 打开模板: 封-1 ', function (t) {
         rptTplDataFacade.prepareProjectData(userId_Dft, demoPrjId, filter, function (err, msg, rawDataObj) {
             if (!err) {
                 try {
-                    // fsUtil.writeObjToFile(rawDataObj, "D:/GitHome/ConstructionCost/tmp/rptTplRawDataObject.jsp");
+                    // fsUtil.writeObjToFile(rawDataObj, "D:/GitHome/ConstructionCost/tmp/rptTplRawDataObject_建筑封-3表.jsp");
                     let tplData = rptDataUtil.assembleData(rawDataObj);
+                    // fsUtil.writeObjToFile(tplData, "D:/GitHome/ConstructionCost/tmp/rptTplAssembledData_建筑封-3表.jsp");
                     //build the report
                     let printCom = JpcEx.createNew();
                     rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_PAGE_SIZE] = pagesize;
@@ -69,7 +72,7 @@ test('测试 - 打开模板: 封-1 ', function (t) {
                     let maxPages = printCom.totalPages;
                     let pageRst = printCom.outputAsSimpleJSONPageArray(rptTpl, tplData, 1, maxPages, defProperties);
                     if (pageRst) {
-                        // fsUtil.writeObjToFile(pageRst, "D:/GitHome/ConstructionCost/tmp/testBuiltPageResult.jsp");
+                        fsUtil.writeObjToFile(pageRst, "D:/GitHome/ConstructionCost/tmp/testBuiltPageResult_建筑封-3.jsp");
                     } else {
                         console.log("oh! no pages were created!");
                     }
@@ -96,7 +99,7 @@ test('close the connection', function (t) {
         mongoose.disconnect();
         t.pass('closing db connection');
         t.end();
-    }, 8000);
+    }, 1000);
     // mongoose.disconnect();
     // t.pass('closing db connection');
     // t.end();

+ 8 - 0
web/building_saas/complementary_ration_lib/html/anzhuang.html

@@ -13,6 +13,14 @@
     <link rel="stylesheet" href="/lib/font-awesome/font-awesome.min.css">
     <link rel="stylesheet" href="/lib/jquery-contextmenu/jquery.contextMenu.css">
     <!--endinject-->
+    <style type="text/css">
+        .nav-tabs .nav-item.show .nav-link, .nav-tabs .nav-link.active{
+            border: 2px solid #ff6501;
+            color: #495057;
+            background-color: #fff;
+            border-bottom: 1px solid #fff;
+        }
+    </style>
 </head>
 
 <body>

+ 8 - 0
web/building_saas/complementary_ration_lib/html/dinge.html

@@ -13,6 +13,14 @@
     <link rel="stylesheet" href="/lib/jquery-contextmenu/jquery.contextMenu.css" type="text/css">
     <link rel="stylesheet" href="/lib/spreadjs/sheets/css/gc.spread.sheets.sc.css" type="text/css">
     <!--endinject-->
+    <style type="text/css">
+        .nav-tabs .nav-item.show .nav-link, .nav-tabs .nav-link.active{
+            border: 2px solid #ff6501;
+            color: #495057;
+            background-color: #fff;
+            border-bottom: 1px solid #fff;
+        }
+    </style>
 </head>
 <body>
 <div class="header">

+ 8 - 0
web/building_saas/complementary_ration_lib/html/fuzhu.html

@@ -12,6 +12,14 @@
     <link rel="stylesheet" href="/lib/font-awesome/font-awesome.min.css">
     <link rel="stylesheet" href="/lib/spreadjs/sheets/css/gc.spread.sheets.sc.css" type="text/css">
     <!--endinject-->
+    <style type="text/css">
+        .nav-tabs .nav-item.show .nav-link, .nav-tabs .nav-link.active{
+            border: 2px solid #ff6501;
+            color: #495057;
+            background-color: #fff;
+            border-bottom: 1px solid #fff;
+        }
+    </style>
 </head>
 
 <body>

+ 6 - 0
web/building_saas/complementary_ration_lib/html/gongliao.html

@@ -16,6 +16,12 @@
     <!--endinject-->
     <style type="text/css">
         .ztree li span.button.add{margin-right:2px;background-position:-144px 0;vertical-align:top;*vertical-align:middle}
+        .nav-tabs .nav-item.show .nav-link, .nav-tabs .nav-link.active{
+            border: 2px solid #ff6501;
+            color: #495057;
+            background-color: #fff;
+            border-bottom: 1px solid #fff;
+        }
     </style>
 </head>
 

+ 16 - 11
web/building_saas/complementary_ration_lib/js/coe.js

@@ -20,17 +20,22 @@ var pageObj = {
             $(this).attr('href', "/complementaryRation/installation" + "?repository=" + getQueryString("repository"))
         });
         var libID = getQueryString("repository");
-        var libName = storageUtil.getSessionCache("RationGrp","repositoryID_" + libID);
-        if (libName) {
-            let $rationName = $(`<div id='rationname' class='navbar-text'>${libName}</div>`);
-            $('.header-logo').after($rationName);
-        };
-        this.gljLibID = storageUtil.getSessionCache("gljLib", "repositoryID_" + libID);
-        this.libID = libID;
-        coeOprObj.buildSheet($('#mainSpread')[0]);
-        gljAdjOprObj.buildSheet($('#contentSpread')[0]);
-        coeOprObj.getCoeList();
-        gljAdjOprObj.getGljItemsOcc();
+        let me = this;
+        CommonAjax.post('/complementaryRation/api/getRationLibs', {ids: [libID]}, function (rstData) {
+            if(rstData.length > 0){
+                let libName = rstData[0].dispName;
+                if (libName) {
+                    let $rationName = $(`<div id='rationname' class='navbar-text'>${libName}</div>`);
+                    $('.header-logo').after($rationName);
+                };
+                me.gljLibID = rstData[0].gljLib;
+                me.libID = libID;
+                coeOprObj.buildSheet($('#mainSpread')[0]);
+                gljAdjOprObj.buildSheet($('#contentSpread')[0]);
+                coeOprObj.getCoeList();
+                gljAdjOprObj.getGljItemsOcc();
+            }
+        });
 
     },
     showData: function(sheet, setting, data) {

+ 19 - 15
web/building_saas/complementary_ration_lib/js/installation.js

@@ -56,22 +56,26 @@ let feeItemObj = {
             this.setOptions(this.workBook, this.setting.options);
             this.bindEvents(this.sheet);
             this.rationRepId = parseInt(getQueryString("repository"));
-            let libName = storageUtil.getSessionCache("RationGrp","repositoryID_" + this.rationRepId);
-            if (libName) {
-                let $rationName = $(`<div id='rationname' class='navbar-text'>${libName}</div>`);
-                $('.header-logo').after($rationName);
-            }
-            //init sectionSpread
-            se.buildSheet();
-            //init feeRuleSpread
-            fr.buildSheet();
-            //init installation
-            this.getInstallation(this.rationRepId, function (rstData) {
-                me.cache = rstData;
-                sheetCommonObj.showData(me.sheet, me.setting, me.cache);
-                me.initSelection(me.cache[0]);
+            CommonAjax.post('/complementaryRation/api/getRationLibs', {ids: [this.rationRepId]}, function (rstData) {
+                if(rstData.length > 0){
+                    let libName = rstData[0].dispName;
+                    if (libName) {
+                        let $rationName = $(`<div id='rationname' class='navbar-text'>${libName}</div>`);
+                        $('.header-logo').after($rationName);
+                    }
+                    //init sectionSpread
+                    se.buildSheet();
+                    //init feeRuleSpread
+                    fr.buildSheet();
+                    //init installation
+                    me.getInstallation(me.rationRepId, function (rstData) {
+                        me.cache = rstData;
+                        sheetCommonObj.showData(me.sheet, me.setting, me.cache);
+                        me.initSelection(me.cache[0]);
+                    });
+                    //init batchSectionSpread
+                }
             });
-            //init batchSectionSpread
         }
     },
     bindEvents: function (sheet) {

+ 0 - 2
web/building_saas/complementary_ration_lib/js/main.js

@@ -7,9 +7,7 @@ let compleRationMain = {
         let scFunc = function (rstData) {
             $("#comple_ration_table").empty();
             for(let i = 0; i < rstData.length; i++){
-                storageUtil.setSessionCache("RationGrp","repositoryID_" + rstData[i].ID, rstData[i].dispName);
                 if(rstData[i].gljLib !== undefined && rstData[i].gljLib && rstData[i].gljLib != -1){
-                    storageUtil.setSessionCache("gljLib","repositoryID_" + rstData[i].ID, rstData[i].gljLib);
                     let id = rstData[i].ID;
                     let libName = rstData[i].dispName;
                     $("#comple_ration_table").append(

+ 22 - 20
web/building_saas/complementary_ration_lib/js/repository_glj.js

@@ -18,27 +18,29 @@ var pageOprObj = {
     rationLibName : null,
     rationLibId: null,
     initPage : function(container) {
-        var me = this, rationLibId = getQueryString("repository"),//获取定额库参数
-            rationLibName = storageUtil.getSessionCache("RationGrp","repositoryID_" + rationLibId);
+        var me = this, rationLibId = getQueryString("repository");//获取定额库参数
         me.rationLibId = rationLibId;
-        if (rationLibName) {
-            me.rationLibName = rationLibName;
-            let $rationName = $(`<div id='rationname' class='navbar-text'>${me.rationLibName}</div>`);
-            $('.header-logo').after($rationName);
-            repositoryGljObj.buildSheet(container);
-            //repositoryGljObj.getRationGljIds(rationLibId);
-            repositoryGljObj.getGljDistType(function () {
-                repositoryGljObj.currentRepositoryId = parseInt(rationLibId);
-                //引用的工料机库
-                let gljLibID = storageUtil.getSessionCache("gljLib", "repositoryID_" + rationLibId);
-                if(gljLibID && typeof gljLibID !== 'undefined'){
-                    repositoryGljObj.getGljTree(gljLibID, function () {
-                        repositoryGljObj.getGljItems(gljLibID);
-                    });
-                }
-                sheetCommonObj.shieldAllCells(repositoryGljObj.workBook.getSheet(0), repositoryGljObj.setting);
-            });
-        }
+        //getRationLibName
+        CommonAjax.post('/complementaryRation/api/getRationLibs', {ids: [rationLibId]}, function (rstData) {
+            if(rstData.length > 0){
+                me.rationLibName = rstData[0].dispName;
+                let $rationName = $(`<div id='rationname' class='navbar-text'>${me.rationLibName}</div>`);
+                $('.header-logo').after($rationName);
+                repositoryGljObj.buildSheet(container);
+                repositoryGljObj.getGljDistType(function () {
+                    repositoryGljObj.currentRepositoryId = parseInt(rationLibId);
+                    //引用的工料机库
+                    let gljLibID = rstData[0].gljLib;
+                    if(gljLibID && typeof gljLibID !== 'undefined'){
+                        repositoryGljObj.getGljTree(gljLibID, function () {
+                            repositoryGljObj.getGljItems(gljLibID);
+                        });
+                    }
+                    sheetCommonObj.shieldAllCells(repositoryGljObj.workBook.getSheet(0), repositoryGljObj.setting);
+                });
+            }
+        });
+
     }
 }
 repositoryGljObj = {

+ 1 - 0
web/building_saas/js/global.js

@@ -13,6 +13,7 @@ function autoFlashHeight(){
     //$(".main-data-side-d").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightD-302);
     $(".main-data-side-d").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightD-$('#stdSectionRations').height()-5);
     $('.main-content').width($(window).width()-$('.main-nav').width()-$('.main-side').width()-5);
+    $('#glj_tree_div .modal-content').width($(window).width() < 1020 + 20 ? $(window).width() - 20 : 1020);
     //$("#main .main-data-top").height($(window).height()-headerHeight-toolsbarHeight-bottomContentHeight-1);
     $("#billsSpread").height($(window).height()-headerHeight-toolsbarHeight-mainBottomContentHeight-1);
     $("#project_glj_sheet").height($(window).height()-headerHeight-toolsbarHeight-gljBottomContentHeight-25);

+ 1 - 1
web/building_saas/main/html/main.html

@@ -634,7 +634,7 @@
     <!--工料机选择窗口-->
     <div class="modal fade" id="glj_tree_div" data-backdrop="static">
         <div class="modal-dialog modal-lg" role="document" id="modalCon">
-            <div class="modal-content" style="width: 1020px;">
+            <div class="modal-content" style="width: 1020px; left:50%; transform: translate(-50%,0%);">
                 <div class="modal-header">
                     <h5 class="modal-title">请选择工料机</h5>
                     <button type="button" class="close" data-dismiss="modal" aria-label="Close">

+ 117 - 38
web/building_saas/main/js/models/calc_program.js

@@ -563,6 +563,32 @@ let calcTools = {
         if (quantity)
             return parseFloat(quantity).toDecimal(decimalObj.glj.quantity)
         else return 0;
+    },
+    
+    getRationsByProjectGLJ(PGLJID){
+        let rationIDs = [];
+        let RGs = projectObj.project.ration_glj.datas;
+        for (let rg of RGs){
+            if (rg.projectGLJID == PGLJID){
+                rationIDs.push(rg.rationID);
+            }
+        };
+
+        let rationNodes = [];
+        let nodes = projectObj.project.mainTree.nodes;
+        for (let rID of rationIDs){
+            rationNodes.push(nodes['id_' + rID]);
+        };
+        return rationNodes;
+    },
+    getNodesByProgramID(programID){
+        let discreteNodes = [];
+        let nodes = projectObj.project.mainTree.items;
+        for (let node of nodes){
+            if (node.data.programID == programID)
+                discreteNodes.push(node);
+        };
+        return discreteNodes;
     }
 };
 
@@ -751,39 +777,62 @@ let analyzer = {
         return false;
     },
     isLegal: function (dispExpr, itemID, template) {  // 检测包括:无效字符、基数是否中括号、基数是否定义、行引用、循环计算
+
+        function testValue(expr){
+            try {
+                expr = expr.replace(/\[[\u4E00-\u9FA5]+\]/gi, '0');
+                expr = expr.replace(/@\d+/gi, '0');
+                if (expr.includes('00'))
+                    return false;
+
+                eval(expr);
+                return true;
+            }
+            catch (err) {
+                return false;
+            }
+        };
+
         let me = analyzer;
         let expr = me.standard(dispExpr);
         let invalidChars = /[^0-9\u4e00-\u9fa5\+\-\*\/\(\)\.\[\]FL%]/g;
         if (invalidChars.test(expr)){
-            hintBox.infoBox('系数提示','表达式中含有无效的字符!',1);
+            hintBox.infoBox('错误提示',`表达式中含有${hintBox.font('无效字符')}!`,1);
             return false;
         };
 
+        let i = expr.search(/\df/ig);   // 4F3
+        let j = expr.search(/\d\[/ig);  // 4[定额基价人工费]
+        if (i > -1 || j > -1){
+            hintBox.infoBox('错误提示', `表达式中${hintBox.font('缺少运算符')}!`, 1);
+            return false;
+        }
+
         let pattCn = new RegExp(/[\u4E00-\u9FA5]+/gi);
         let arrCn = expr.match(pattCn);
         let pattBase = new RegExp(/\[[\u4E00-\u9FA5]+\]/gi);
         let arrBase = expr.match(pattBase);
         if (arrCn && !arrBase){
-            hintBox.infoBox('系统提示', '定额基数必须用中括号[]括起来!', 1);
+            hintBox.infoBox('错误提示', `定额基数必须用中括号${hintBox.font('[]')}括起来!`, 1);
             return false;
         };
         if (arrCn && arrBase && (arrCn.length != arrBase.length)){
             for (let cn of arrCn){
                 let tempBase = `[${cn}]`;
                   if (!arrBase.includes(tempBase)){
-                      hintBox.infoBox('系统提示', `定额基数“${cn}”必须用中括号[]括起来!`, 1);
+                      hintBox.infoBox('错误提示', `定额基数“${hintBox.font(cn)}”必须用中括号${hintBox.font('[]')}括起来!`, 1);
                       return false;
                   }
             };
             // 这里要加一个保险。因为上面的 for 循环在“主材费 + [主材费]” 情况下有Bug
-            hintBox.infoBox('系统提示', '定额基数必须用中括号[]括起来!', 1);
+            hintBox.infoBox('错误提示', `定额基数必须用中括号${hintBox.font('[]')}括起来!`, 1);
             return false;
         };
         if (arrBase){
             for (let base of arrBase){
                 let baseName = base.slice(1, -1);
                 if (!rationCalcBases[baseName]){
-                    hintBox.infoBox('系统提示', '定额基数 [' + baseName + '] 末定义!', 1);
+                    hintBox.infoBox('错误提示', `定额基数${hintBox.font('[' +baseName + ']')}末定义!`, 1);
                     return false;
                 }
             };
@@ -794,16 +843,20 @@ let analyzer = {
             let num = F.slice(1);
             if (num > template.calcItems.length){
                 let s = hintBox.font('F'+num);
-                hintBox.infoBox('系统提示', `表达式中 “${s}” 行号引用错误!`, 1);
+                hintBox.infoBox('错误提示', `表达式中 “${hintBox.font(s)}” 行号引用错误!`, 1);
                 return false;
             };
         };
 
         let expression = me.getExpression(expr, template);
         if (me.isCycleCalc(expression, itemID, template)){
-            hintBox.infoBox('系统提示', '表达式中有循环计算!', 1);
+            hintBox.infoBox('错误提示', `表达式中有${hintBox.font('循环计算')}!`, 1);
             return false;
-        }
+        };
+        if (!testValue(expression)){
+            hintBox.infoBox('错误提示', `表达式中有${hintBox.font('语法错误')}!`, 1);
+            return false;
+        };
 
         return true;  // 表达式合法
     },
@@ -1480,6 +1533,7 @@ class CalcProgram {
                     let calcItem = template.calcItems[idx];
                     $CE.tempCalcItem = calcItem;
                     let feeRate = parseFloatPlus(calcItem.feeRate) ? parseFloatPlus(calcItem.feeRate).toDecimal(decimalObj.feeRate) : 100;  // 100%
+                    // console.log(`[${calcItem.ID}]: ${calcItem.compiledExpr}`);   // for test.
                     calcItem.unitFee = (eval(calcItem.compiledExpr) * feeRate * 0.01).toDecimal(decimalObj.decimal('unitPrice', treeNode));   // 如果eval()对清单树有影响,就换成小麦的Expression对象再试
 
                     let q = calcTools.uiNodeQty(treeNode) ? calcTools.uiNodeQty(treeNode) : 0;
@@ -1545,7 +1599,7 @@ class CalcProgram {
         return changedNodes;
     };
 
-    // 计算全部公式项。 (参数意义:将通过本方法后发生改变的节点存入changedNodesArr中)
+    // 计算全部公式项。 (参数意义:将通过本方法后发生改变的节点存入changedArr中)
     calcFormulaNodes(changedArr){
         let me = this;
         let formulaNodes = cbTools.getFormulaNodes(true);
@@ -1585,40 +1639,66 @@ class CalcProgram {
         };
     };
 
-    // 计算多条零散的定额,并计算他们所属的清单、父级清单,然后打包存储。如:批量替换工料机后受影响的定额。
-    calcRationsAndSave(rationNodes, callback){
-        let me = this, leafBills = [], allChangedNodes = [];
-        for (let node of rationNodes) {
-            me.innerCalc(node, allChangedNodes);
-            let leafBill = node.parent;
-            // 多条定额同属一条叶子清单时,避免叶子清单重复计算
-            if (leafBill && leafBills.indexOf(leafBill) < 0) leafBills.push(leafBill);
+    // 计算并保存指定的一个树节点。修改一个树节点,实际上要计算和保存的是一批树结点:层层父结点、被其它结点(的公式)引用的公式结点。
+    // 这个方法实际上封装了calculate()和saveNodes()两个方法,主要目的是为了外部调用方便,少写一点累赘代码。
+    calcAndSave(treeNode, callback){
+        let changedNodes = this.calculate(treeNode);
+        this.saveNodes(changedNodes, callback);
+    };
+
+    // 计算零散的、混杂的树节点:清单、定额混合等(如:用到某一计算程序的定额和清单)。
+    // 计算多条零散的定额,并计算他们所属的清单、父清单、引用清单。如:批量替换工料机后受影响的定额。
+    // 计算多条零散的清单,并计算他们的父清单、引用清单。如:花选删除树结点(如花选清单、定额等,不区分树结点类型)。
+    calcNodesAndSave(nodes, callback){
+        let me = this, rationNodes = [], billNodes = [], leafBills = [], allChangedNodes = [];
+        for (let node of nodes) {
+            if (node.sourceType == ModuleNames.ration)
+                rationNodes.push(node)
+            else
+                billNodes.push(node);
         };
 
-        for (let node of leafBills){
-            let curChangeds = me.calculate(node);
-            mergeArr(allChangedNodes, curChangeds);
+        // 多条定额同属一条叶子清单时,避免叶子清单重复计算
+        for (let ration of rationNodes) {
+            me.innerCalc(ration, allChangedNodes);
+            let leafBill = ration.parent;
+            if (leafBill && leafBills.indexOf(leafBill) < 0)
+                leafBills.push(leafBill);
         };
-        let endShowTime = +new Date();
-        me.saveNodes(allChangedNodes, callback);
-    };
 
-    // 计算多条零散的清单,并计算他们的父清单、引用清单,然后打包存储。如:多选删除树结点(如多选清单、定额等,不区分树结点类型)。
-    calcBillsAndSave(billNodes,callback){
-        let me = this, allChangedNodes = [];
-        for (let node of billNodes) {
-            let curChangeds = me.calculate(node, true, false);
-            mergeArr(allChangedNodes, curChangeds);
         };
+
         me.calcFormulaNodes(allChangedNodes);
-        me.saveNodes(allChangedNodes,callback);
+        me.saveNodes(allChangedNodes, callback);
     };
-
-    // 计算并保存指定的一个树节点。修改一个树节点,实际上要计算和保存的是一批树结点:层层父结点、被其它结点(的公式)引用的公式结点。
-    // 这个方法实际上封装了calculate()和saveNodes()两个方法,主要目的是为了外部调用方便,少写一点累赘代码。
-    calcAndSave(treeNode, callback){
-        let changedNodes = this.calculate(treeNode);
-        this.saveNodes(changedNodes, callback);
+    calcRationsAndSave(rationNodes, callback){
+        // let me = this, leafBills = [], allChangedNodes = [];
+        // for (let node of rationNodes) {
+        //     me.innerCalc(node, allChangedNodes);
+        //     let leafBill = node.parent;
+        //     // 多条定额同属一条叶子清单时,避免叶子清单重复计算
+        //     if (leafBill && leafBills.indexOf(leafBill) < 0) leafBills.push(leafBill);
+        // };
+        //
+        // for (let node of leafBills){
+        //     let curChangeds = me.calculate(node);
+        //     mergeArr(allChangedNodes, curChangeds);
+        // };
+        // let endShowTime = +new Date();
+        // me.saveNodes(allChangedNodes, callback);
+
+        this.calcNodesAndSave(rationNodes, callback);
+    };
+    calcBillsAndSave(billNodes,callback){
+        // let me = this, allChangedNodes = [];
+        // for (let node of billNodes) {
+        //     let curChangeds = me.calculate(node, true, false);
+        //     mergeArr(allChangedNodes, curChangeds);
+        // };
+        // me.calcFormulaNodes(allChangedNodes);
+        // me.saveNodes(allChangedNodes,callback);
+
+        this.calcNodesAndSave(billNodes, callback);
     };
 
     calcAllNodesAndSave(calcType = calcAllType.catAll, callback){
@@ -1626,8 +1706,7 @@ class CalcProgram {
         this.saveNodes(changedNodes, callback);
     };
 
-    // 排除指定项的综合合价计算(用于带循环计算的情况)。
-    // 这里的汇总只到清单级别即可(清单单价取费时,汇总到清单和汇总到定额两个值不一样)
+    // 排除指定项的综合合价计算(用于带循环计算的情况。这里的汇总只到清单级别即可:清单单价取费时,汇总到清单和汇总到定额两个值不一样)
     getTotalFee(baseNodes, excludeNodes){
         let rst = 0;
         function calcNodes(nodes) {

+ 1 - 0
web/building_saas/main/js/models/ration_glj.js

@@ -44,6 +44,7 @@ var ration_glj = {
             if (ration.type == rationType.gljRation){
                 let glj = JSON.parse(JSON.stringify(ration));
                 glj.type = glj.subType;
+                glj.quantity = 1;
                 return [glj];
             }
             else{

+ 2 - 1
web/building_saas/main/js/views/calc_base_view.js

@@ -300,7 +300,8 @@ let calcBaseView = {
                         calcProgramManage.saveCalcItem(data, function (rst) {
                             if (rst){
                                 cp.compileTemplate(template);
-                                cp.calcAllNodesAndSave();
+                                let relationNodes = calcTools.getNodesByProgramID(template.ID);
+                                cp.calcNodesAndSave(relationNodes);
                                 calcProgramManage.refreshDetailSheet();
                                 $('#qd-jsjs').modal('hide');
                                 $.bootstrapLoading.end();

+ 9 - 5
web/building_saas/main/js/views/calc_program_manage.js

@@ -109,13 +109,13 @@ let calcProgramManage = {
             return;
         }
 
+        let template = me.getSelectionInfo().template;
         if (dataCode == 'displayFieldName') {
             if (curCalcItem.displayFieldName == args.newValue) {
                 $.bootstrapLoading.end();
                 return;
             }
 
-            let template = me.getSelectionInfo().template;
             if (analyzer.fieldNameIsUsed(template, args.newValue)){
                 let sheet = me.detailSpread.getActiveSheet();
                 sheet.suspendEvent();
@@ -137,17 +137,19 @@ let calcProgramManage = {
         curCalcItem[dataCode] = args.newValue;
         let data = {
             'projectID': projectObj.project.ID(),
-            'templatesID': editInfo.template.ID,
+            'templatesID': template.ID,
             'calcItem': curCalcItem
         };
         me.saveCalcItem(data, function (rst) {
             if (rst){
-                projectObj.project.calcProgram.calcAllNodesAndSave();
+                let relationNodes = calcTools.getNodesByProgramID(template.ID);
+                projectObj.project.calcProgram.calcNodesAndSave(relationNodes);
             }
         });
         $.bootstrapLoading.end();
     },
     onDetailEnterCell: function (sender, args) {
+        // for test.
         // let t = calcProgramManage.getSelectionInfo().template;
         // let c = calcProgramManage.getSelectionInfo().calcItem;
         // let lc = analyzer.calcItemLabourCoe(c);
@@ -317,7 +319,8 @@ let calcProgramManage = {
                                 projectObj.project.calcProgram.compileTemplate(template);
                                 calcProgramManage.refreshDetailSheet();
                                 calcProgramManage.detailSpread.getActiveSheet().setSelection(idx + 1, 0, 1, 1);
-                                projectObj.project.calcProgram.calcAllNodesAndSave();
+                                let relationNodes = calcTools.getNodesByProgramID(template.ID);
+                                projectObj.project.calcProgram.calcNodesAndSave(relationNodes);
                             }
                         });
                         $.bootstrapLoading.end();
@@ -357,7 +360,8 @@ let calcProgramManage = {
                             if (rst){
                                 projectObj.project.calcProgram.compileTemplate(template);
                                 calcProgramManage.refreshDetailSheet();
-                                projectObj.project.calcProgram.calcAllNodesAndSave();
+                                let relationNodes = calcTools.getNodesByProgramID(template.ID);
+                                projectObj.project.calcProgram.calcNodesAndSave(relationNodes);
                             }
                         });
                         $.bootstrapLoading.end();

+ 3 - 0
web/building_saas/main/js/views/glj_view_contextMenu.js

@@ -347,6 +347,9 @@ function getGLJData(actionType) {
         $.bootstrapLoading.end();
         console.log(+new Date());
         $("#glj_tree_div").modal({show:true});
+        setTimeout(function(){
+            gljOprObj.gljLibSpresd.refresh();
+        }, 200);
     })
 }
 

+ 8 - 1
web/building_saas/main/js/views/project_glj_view.js

@@ -400,6 +400,13 @@ projectGljObject={
             }
             info.sheet.resumeEvent();
             info.sheet.resumePaint();
+
+            if (dataCode === 'supply' || dataCode === 'supply_quantity'){
+                let rations = calcTools.getRationsByProjectGLJ(recode.id);
+                projectObj.project.calcProgram.calcRationsAndSave(rations, function () {
+                    projectObj.mainController.refreshTreeNode(projectObj.project.mainTree.roots);
+                });
+            }
         };
         if(dataCode=='basePrice'||dataCode=='marketPrice'){
             value= scMathUtil.roundForObj(value,getDecimal('glj.unitPrice'));//修改市场价和修改定额价时需要重新记算很多受影响的树节点,现在改成与定字额工料机那里调相同的方法。
@@ -425,7 +432,7 @@ projectGljObject={
             extend = Object.keys(extend).length > 0 ?  JSON.stringify(extend) : '';
             let updateData = {id: recode.id, field: dataCode, value: value, extend: extend};
             projectGLJ.pGljUpdate(updateData,callback);
-        }
+        };
     },
     getSupplyQuantity : function(supplyType, quantity) {
         // 自行采购和甲定乙供则把甲供数量设置为0,其余情况则设置为当前总消耗量

+ 11 - 7
web/building_saas/main/js/views/project_view.js

@@ -21,6 +21,7 @@ var projectObj = {
     },
     treeSelectedChanged: function (node) {
         let project = projectObj.project;
+        let mainSheet = projectObj.mainController.sheet;
         //设置选中行底色和恢复前选中行底色
         let refreshNodes = [node];
         if(!project.mainTree.preSelected){
@@ -478,16 +479,21 @@ var projectObj = {
     mainSpreadLeaveCell: function (sender, info) {
         let colSetting = projectObj.mainController.setting.cols[info.col];
         projectObj.lastCol = colSetting;
+        projectObj.lastCell = {row: info.row, col: info.col};
     },
     //repaint 动态下拉框
     mainSpreadEnterCell: function (sender, info) {
         let colSetting = projectObj.mainController.setting.cols[info.col];
         if(colSetting.data.field === 'unit' || (projectObj.lastCol&&projectObj.lastCol.data.field === 'unit')||colSetting.data.field ==='subType'
             || (projectObj.lastCol&&projectObj.lastCol.data.field === 'subType') || colSetting.data.field === 'programID' ||(projectObj.lastCol&&projectObj.lastCol.data.field === 'programID')){
-            /*let hideRowFilter =new GC.Spread.Sheets.Filter.HideRowFilter(info.sheet.getRange(-1, info.col, -1, 1));
-            info.sheet.rowFilter(hideRowFilter);
-            info.sheet.resumePaint();*/
-            info.sheet.repaint();
+            let rects = [];
+            rects.push(info.sheet.getCellRect(info.row, info.col));
+            if(projectObj.lastCell){
+                rects.push(info.sheet.getCellRect(projectObj.lastCell.row, projectObj.lastCell.col));
+            }
+            for(let rect of rects){
+                info.sheet.repaint(rect);
+            }
         }
     },
     mainSpreadEditStarting: function (sender, info) {
@@ -672,7 +678,6 @@ var projectObj = {
                 console.log(`时间——${endTime - startTime}`);
                 that.project.projectMarkChecking();//是否需要重新进行造价计算
                 installationFeeObj.engineeringTypeChecking();//检查是否安装工程
-                //初始需要触发一次点击表格事件,sheet.getAutoFitWidth值(获取单元格文本长度)才正确
                 autoFlashHeight();
                 projectObj.refreshMainSpread();
                 $.bootstrapLoading.end();
@@ -1246,13 +1251,12 @@ var projectObj = {
         TREE_SHEET_HELPER.massOperationSheet(sheet, function () {
             for(let node of nodes){
                 if(node && node.serialNo()!= -1){
-                    //console.log(me.getNodeColorStyle(sheet, node).backColor);
                     sheet.getRange(node.serialNo(), -1, 1, -1).backColor(me.getNodeColorStyle(sheet, node).backColor);
                     //sheet.setStyle(node.serialNo(), -1, me.getNodeColorStyle(sheet, node));
                 }
             }
         });
-     
+
     },
     loadLockBillsButton:function () {
         if(projectInfoObj.projectInfo.property.lockBills == true){