Browse Source

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

TonyKang 7 years ago
parent
commit
cb9c4bc0e9

+ 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);
         };
     }
 };

+ 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">

+ 108 - 31
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,6 +777,22 @@ 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;
@@ -803,7 +845,11 @@ let analyzer = {
         if (me.isCycleCalc(expression, itemID, template)){
             hintBox.infoBox('系统提示', '表达式中有循环计算!', 1);
             return false;
-        }
+        };
+        if (!testValue(expression)){
+            hintBox.infoBox('系统提示', '表达式语法错误!', 1);
+            return false;
+        };
 
         return true;  // 表达式合法
     },
@@ -1480,6 +1526,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 +1592,7 @@ class CalcProgram {
         return changedNodes;
     };
 
-    // 计算全部公式项。 (参数意义:将通过本方法后发生改变的节点存入changedNodesArr中)
+    // 计算全部公式项。 (参数意义:将通过本方法后发生改变的节点存入changedArr中)
     calcFormulaNodes(changedArr){
         let me = this;
         let formulaNodes = cbTools.getFormulaNodes(true);
@@ -1585,40 +1632,71 @@ 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);
+        mergeArr(billNodes, leafBills);
+
+        for (let bill of billNodes){
+            let changeBills = me.calculate(bill, true, false);
+            mergeArr(allChangedNodes, changeBills);
         };
+
         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 +1704,7 @@ class CalcProgram {
         this.saveNodes(changedNodes, callback);
     };
 
-    // 排除指定项的综合合价计算(用于带循环计算的情况)。
-    // 这里的汇总只到清单级别即可(清单单价取费时,汇总到清单和汇总到定额两个值不一样)
+    // 排除指定项的综合合价计算(用于带循环计算的情况。这里的汇总只到清单级别即可:清单单价取费时,汇总到清单和汇总到定额两个值不一样)
     getTotalFee(baseNodes, excludeNodes){
         let rst = 0;
         function calcNodes(nodes) {

+ 53 - 31
web/building_saas/main/js/models/quantity_detail.js

@@ -40,18 +40,25 @@ var quantity_detail = {
                 this.refreshSheetData();
             }
         };
-        quantity_detail.prototype.refreshAfterSave=function(data){
+        quantity_detail.prototype.refreshAfterSave=function(data,batchCallback){
             var me = this;
+            let newData = null;
             if(data.hasOwnProperty('resort')){
                 this.resortData(data.doc,1);
                 _.forEach(data.update_task,function (item) {
                     me.refreshEachItme(item.query,item.doc);
                 })
-                this.datas.push(data.doc);
+                newData = data.doc;
             }else {
-                this.datas.push(data);
+                newData = data;
             }
-            this.refreshSheetData();
+            this.datas.push(newData);
+            if(batchCallback){
+                gljOprObj.detailData.push(newData);
+            }else {
+                this.refreshSheetData();
+            }
+
         };
         quantity_detail.prototype.resortData=function(data,req){
 
@@ -62,7 +69,7 @@ var quantity_detail = {
                 }
             }
         };
-        quantity_detail.prototype.refreshAfterUpdate=function(data){
+        quantity_detail.prototype.refreshAfterUpdate=function(data,batchCallback){
             var me = this;
             var filter_object;
             if(data.hasOwnProperty('refreshList')){
@@ -75,7 +82,11 @@ var quantity_detail = {
             var showList = _.filter(this.datas,filter_object);
             gljOprObj.detailData=showList;
             gljOprObj.detailData=_.sortBy(gljOprObj.detailData,'seq');
-            this.refreshSheetData();
+            console.log(batchCallback);
+            if(batchCallback == undefined){
+                this.refreshSheetData();
+            }
+
         };
         quantity_detail.prototype.refreshEachItme = function(query,doc){
             var detail_list = this.datas;
@@ -107,7 +118,7 @@ var quantity_detail = {
         quantity_detail.prototype.refreshSheetData=function () {
             gljOprObj.showQuantityDetailData();
         };
-        quantity_detail.prototype.saveQuantityDetail=function (args,dataCode,selected) {
+        quantity_detail.prototype.saveQuantityDetail=function (args,dataCode,selected,batchCallback) {
             var me = this;
             var doc={};
             var selected = selected?selected:projectObj.project.mainTree.selected;
@@ -127,9 +138,13 @@ var quantity_detail = {
                 }
                 doc.refreshQuantity=true;
                 if(!selected.data.hasOwnProperty('isFromDetail')||selected.data.isFromDetail==0){
-                    var c = confirm("确定要使用工程量明细替换原工程量吗?");
-                    if(!c){
-                        doc.refreshQuantity=false;
+                    if(!args.replace){//为了批量粘贴时不重复提示,普通编辑时不受影响
+                        var c = confirm("确定要使用工程量明细替换原工程量吗?");
+                        if(c){
+                            args.replace = true;
+                        }else {
+                            doc.refreshQuantity=false;
+                        }
                     }
                 }
 
@@ -142,17 +157,19 @@ var quantity_detail = {
                 url = "/quantity_detail/save";
             }
             var callback = function (data) {
+                $.bootstrapLoading.end();
                 if(doc.refreshQuantity==false){//清空数据
                     me.cleanQuantityDetail();
                 }else {
-                    data.newRecord?me.refreshAfterSave(data.newRecord):me.refreshAfterSave(data);
-                    if(data.node){
+                    data.newRecord?me.refreshAfterSave(data.newRecord,batchCallback):me.refreshAfterSave(data,batchCallback);
+                    if(batchCallback){
+                        batchCallback(args)
+                    }else if(data.node){
                       me.refreshRationOrBillNodes(data.node);
                     }
                     //gljOprObj.detailSheet.setActiveCell(0,0);
                     //gljOprObj.detailSheet.clearSelection();
                 }
-                $.bootstrapLoading.end();
             }
             CommonAjax.post(url,doc,callback,function () {
                 $.bootstrapLoading.end();
@@ -166,7 +183,7 @@ var quantity_detail = {
                     console.log(newNode.data.quantity);
                     this.updateBillQuantity(newNode.data.quantity,newNode,newNode.data.quantityEXP);
                 }else {//更新定额所使用的值要用还没转换前的
-                    this.updateRationQuantity(node.data.r_quantity,newNode,newNode.data.quantityEXP);//to do 加上工程量表达式和含量更新
+                    this.updateRationQuantity(node.data.r_quantity,newNode,newNode.data.quantityEXP);
                 }
             }
         };
@@ -257,7 +274,7 @@ var quantity_detail = {
             let regExp = new RegExp(FindText, "g");
             return str.replace(regExp, RepText);
         };
-        quantity_detail.prototype.updateQuantityDetail=function (args,dataCode,recode,selected) {
+        quantity_detail.prototype.updateQuantityDetail=function (args,dataCode,recode,selected,batchCallback) {
             var doc ={};
             var query={
                 ID:recode.ID,
@@ -273,20 +290,23 @@ var quantity_detail = {
                 }
                 query.refreshQuantity=true;
                 if(!selected.data.hasOwnProperty('isFromDetail')||selected.data.isFromDetail==0){
-                    var c = confirm("确定要使用工程量明细替换原工程量吗?");
-                    if(!c){
-                        //query.refreshQuantity=false;
-                        this.cleanQuantityDetail(selected,true);
-                        return;
+                    if(!args.replace){//为了批量粘贴时不重复提示,普通编辑时不受影响
+                        var c = confirm("确定要使用工程量明细替换原工程量吗?");
+                        if(c){
+                            args.replace = true;
+                        }else {
+                            this.cleanQuantityDetail(selected,true);
+                            return;
+                        }
                     }
                 }
                 query.index = args.row;
-                this.updateQuantityRegex(query,doc,args)
+                this.updateQuantityRegex(query,doc,args,batchCallback)
             }else {
-                this.normalUpdate(query,doc);
+                this.normalUpdate(query,doc,args,batchCallback);
             }
         };
-        quantity_detail.prototype.updateQuantityRegex=function(query,doc,args){
+        quantity_detail.prototype.updateQuantityRegex=function(query,doc,args,batchCallback){
             var needupdate = false;
             if(args.editingText==null){
                 needupdate =true;
@@ -297,7 +317,7 @@ var quantity_detail = {
                 }
             }
             if(needupdate){
-                this.commonUpdate("/quantity_detail/updateRegex",{query:query,doc:doc});
+                this.commonUpdate("/quantity_detail/updateRegex",{query:query,doc:doc},args,batchCallback);
             }else {
                 var sheet = subSpread.getActiveSheet();
                 sheet.getCell(args.row,args.col).value(gljOprObj.detailData[args.row].regex);
@@ -327,23 +347,25 @@ var quantity_detail = {
             };
             this.normalUpdate(query,doc);
         };
-        quantity_detail.prototype.commonUpdate = function (url,postData) {
+        quantity_detail.prototype.commonUpdate = function (url,postData,args,batchCallback) {
             var me = this;
             $.bootstrapLoading.start();
             var callback = function (data) {
-                me.refreshAfterUpdate(data);
-                if(data.node){
-                  me.refreshRationOrBillNodes(data.node);
-                }
                 $.bootstrapLoading.end();
+                me.refreshAfterUpdate(data,batchCallback);
+                if(batchCallback){
+                    batchCallback(args)
+                }else if(data.node){
+                    me.refreshRationOrBillNodes(data.node);
+                }
             }
             CommonAjax.post(url,postData,callback,function () {
                 $.bootstrapLoading.end();
             });
         };
-        quantity_detail.prototype.normalUpdate=function(query,doc){
+        quantity_detail.prototype.normalUpdate=function(query,doc,args,batchCallback){
             var url = "/quantity_detail/update";
-            this.commonUpdate(url,{query:query,doc:doc});
+            this.commonUpdate(url,{query:query,doc:doc},args,batchCallback);
         };
         quantity_detail.prototype.regexChecking=function(text){
             var regex=/^[0-9Cc\+\-\*\^/\(\)\.]*$/g;

+ 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();

+ 16 - 3
web/building_saas/main/js/views/glj_view.js

@@ -398,7 +398,6 @@ var gljOprObj = {
         }
     },
     onEditDetailSheet: function (args,callback) {
-        console.log(args);
         var me = gljOprObj;
         if (args.row > me.detailData.length) {
             return;
@@ -728,7 +727,6 @@ var gljOprObj = {
     },
     onRangeChanged: function (sender, args) {
         var me = gljOprObj;
-        console.log(args);
         if(args.sheetName == 'quantity_detail'){
             me.batchUpdateQuantityDetail(args);
         }else {
@@ -763,8 +761,23 @@ var gljOprObj = {
             };
             updateArray.push(tem);
         }
-        console.log(updateArray);
+        if(updateArray.length>0){
+            updateArray.length == 1?me.onEditDetailSheet(updateArray[0]):me.onEditDetailSheet(updateArray[0],updateCallback);
+        }
+
+        function updateCallback(i_args) {
+            let index = i_args.index;
+            if(index < updateArray.length-1){
+                let nextIndex = index+1;
+                updateArray[nextIndex].replace = i_args.replace;
+                if(nextIndex == updateArray.length-1){//是最后一个,则不用调callback了
+                    me.onEditDetailSheet(updateArray[nextIndex]);
+                }else {
+                    me.onEditDetailSheet(updateArray[nextIndex],updateCallback);
+                }
 
+            }
+        }
 
     },
 

+ 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){

+ 7 - 3
web/building_saas/pm/js/pm_newMain.js

@@ -214,7 +214,10 @@ const projTreeObj = {
         if(args.sheet.name()=="copyToSheet"){ //如果是复制到表,不用做后面的操作
             return;
         }
-        if(selected.preSibling()!=null&&selected.preSibling() == targetNode){
+        if(selected.preSibling()!=null&&selected.preSibling() == targetNode&&selected.data.projType == targetNode.data.projType){//如果目标节点与选中节点的前一节点一样,并且选中节点与目标节点项目类型也一样的话,不用移动
+            return;
+        }
+        if(selected == targetNode){
             return;
         }
 
@@ -247,7 +250,6 @@ const projTreeObj = {
                 }
                 if(selected.pid() != rootProjectID){//跨了建设项目,更新子项目,同时要检查是否移动或复制子项的单价文件和费率文件。
                     //检查费率文件和单价文件
-                    //todo
                     for(let c of selected.children){
                         projectMap[c.id()] = {query:{'ID':c.id()},update:{'property.rootProjectID':rootProjectID}};
                         moveOrCopy(c,rootProjectID,feeRateMap,unitPriceMap,true);
@@ -300,7 +302,9 @@ const projTreeObj = {
                 projectMap[sel.preSibling().id()] = {query:{'ID':sel.preSibling().id()},update:{'NextSiblingID':sel.data.NextSiblingID}};
             }
             if(sel.parent.id() == tem_parent.id()){//移动前移动后的父项相同,只改变next
-                projectMap[selected.id()] = {query:{'ID':selected.id()},update:{'NextSiblingID':nextID}};
+                if(selected.id() != nextID){//父项相同的情况下, 下一节点ID如果等于选中的ID即项目没有移动,不用做处理
+                    projectMap[selected.id()] = {query:{'ID':selected.id()},update:{'NextSiblingID':nextID}};
+                }
             }else {//
                 let temData = {query:{'ID':selected.id()},update:{'ParentID':tem_parent.id(),'NextSiblingID':nextID}};
                 let reName = projTreeObj.projectNameChecking(tem_parent,selected);//重名检查