浏览代码

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

zhongzewei 7 年之前
父节点
当前提交
fca637241a

+ 25 - 0
modules/reports/controllers/rpt_tpl_controller.js

@@ -345,6 +345,31 @@ let mExport = {
                 callback(req, res, false, 'The report template was updated successfully!', true);
             }
         });
+    },
+    copyRptTpl: function (req, res) {
+        let params = JSON.parse(req.body.params),
+            orgRptTplId = params.orgRptTplId,
+            newID = params.newRptTplId;
+        let filter = {"ID": orgRptTplId};
+        RptTplModel.findOne(filter, '-_id').exec().then(function(baseTplRst) {
+            if (baseTplRst) {
+                let _doc = baseTplRst["_doc"];
+                _doc["ID"] = newID;
+                if (_doc["GROUP_KEY"].indexOf("(Copy)") < 0) {
+                    _doc["GROUP_KEY"] = _doc["GROUP_KEY"] + "(Copy)";
+                }
+                let rptTpl = new RptTplModel(_doc);
+                rptTpl.save(function (err, actTplRst) {
+                    if (err) {
+                        callback(req,res, "报表模板创建错误", "", null);
+                    } else {
+                        callback(req,res, false, "", newID);
+                    }
+                });
+            } else {
+                callback(req, res, 'Create report template failed!', null);
+            }
+        });
     }
 };
 

+ 1 - 0
modules/reports/routes/rpt_tpl_router.js

@@ -27,6 +27,7 @@ module.exports = function (app) {
     rptTplRouter.post('/createDftRptTpl', reportTplController.createDftRptTpl);
     rptTplRouter.post('/getRefRptTpl', reportTplController.getRefRptTpl);
     rptTplRouter.post('/updateRptTpl', reportTplController.updateRptTpl);
+    rptTplRouter.post('/copyRptTpl', reportTplController.copyRptTpl);
     rptTplRouter.post('/getCompilationList', reportTplController.getCompilationList);
     rptTplRouter.post('/getCustomizeCfg', reportTplController.getCustomerCfg);
     rptTplRouter.post('/saveCustomerCfg', reportTplController.saveCustomerCfg);

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

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

+ 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,其余情况则设置为当前总消耗量

+ 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);//重名检查