zhangweicheng 6 年之前
父节点
当前提交
80546f88b3

+ 11 - 2
modules/pm/facade/pm_facade.js

@@ -288,12 +288,21 @@ async function copyProjectSetting(originalID,newProjectID) {
 
 async function copyBills(newProjectID,billMap) {
      let uuidMaping = billMap.uuidMaping;//做ID映射
-    for(let doc of billMap.datas){
+     for(let doc of billMap.datas){
          doc.projectID = newProjectID;
          doc.ID = uuidMaping[doc.ID] ? uuidMaping[doc.ID] : -1;
          doc.ParentID = uuidMaping[doc.ParentID] ? uuidMaping[doc.ParentID] : -1;
          doc.NextSiblingID = uuidMaping[doc.NextSiblingID] ? uuidMaping[doc.NextSiblingID] : -1;
-    }
+         //对于有基数计算的节点,需要替换计算基数中引用的ID为新的ID
+         if(doc.calcBase && doc.calcBase != ""){
+             let idArr = scMathUtil.getFIDArr(doc.calcBase);
+             for(let re of idArr){
+                 let oID = re.substr(1);//去掉开头的@字符
+                 if(!uuidMaping[oID]) continue;
+                 doc.calcBase = doc.calcBase.replace(new RegExp(oID, "g"),uuidMaping[oID]);
+             }
+         }
+     }
     await insertMany(billMap.datas,billsModel);
     return billMap.datas;
 }

+ 6 - 0
public/web/scMathUtil.js

@@ -209,6 +209,12 @@ let scMathUtil = {
     },
     isDef:function (v) {
         return v !== undefined && v !== null;
+    },
+    //获取ID引用
+    getFIDArr: function (exp) {
+        let fidRex = /@[\d,a-z,A-Z,-]{36}/g;
+        let fidArr = exp.match(fidRex);
+        return this.isDef(fidArr) ? fidArr : [];
     }
 };
 

+ 1 - 3
web/building_saas/main/js/models/calc_base.js

@@ -1042,9 +1042,7 @@ let cbParser = {
     },
     //获取ID引用
     getFIDArr: function (exp) {
-        let fidRex = /@[\d,a-z,A-Z,-]{36}/g;
-        let fidArr = exp.match(fidRex);
-        return cbTools.isDef(fidArr) ? fidArr : [];
+        return scMathUtil.getFIDArr(exp);//统一前后端调用方法
     },
     //获取表达式中的中文式
     getCN: function(expr){

+ 28 - 22
web/building_saas/main/js/models/ration.js

@@ -118,6 +118,8 @@ var Ration = {
             };
             if(rType == rationType.ration){//空定额暂时不输入取费专业
                // newData['programID'] = projectInfoObj.projectInfo.property.engineering;
+            }else if(rType == rationType.volumePrice){//量价取费专业默认为费率为0
+                newData['programID'] = projectObj.project.calcProgram.compiledTemplateMaps["费率为0"];
             }else {
                 if(pEngineer) newData['programID'] = pEngineer;
             }
@@ -545,7 +547,7 @@ var Ration = {
         };
 
 
-        ration.prototype.addNewRation = function (itemQuery,rationType,callback=null,isEmpty=false,priceType) {//priceType 是量价类型
+        ration.prototype.addNewRation = function (itemQuery,rationType,callback=null,isEmpty=false,priceType,needCalcAndSave=true) {//priceType 是量价类型
             let me = this;
             let project = projectObj.project, sheetController = projectObj.mainController;
             let engineering = projectInfoObj.projectInfo.property.engineering;
@@ -595,34 +597,38 @@ var Ration = {
                 CommonAjax.post("/ration/addNewRation",{itemQuery:itemQuery,newData:newData,defaultLibID: rationLibObj.getDefaultStdRationLibID(),calQuantity:calQuantity,brUpdate:brUpdate,needInstall:needInstall},function (data) {
                     //更新缓存
                     me.datas.push(data.ration);
-
                     me.addSubListOfRation(data);
-
                     //插入树节点
                     newSource = data.ration;
-                    newNode = project.mainTree.insert(billItemID, nextID, newSource.ID);
-                    newNode.source = newSource;
-                    newNode.sourceType = project.Ration.getSourceType();
-                    newNode.data = newSource;
-                    project.projectGLJ.loadData(function () {
-                        ProjectController.syncDisplayNewNode(sheetController, newNode);
-                        project.ration_glj.addToMainTree(data.ration_gljs);
-                        projectObj.mainController.refreshTreeNode([newNode], false);
-                        project.calcProgram.calcAndSave(newNode,function () {
-                            if(project.Bills.isFBFX(newNode)) { //判断是否属于分部分项工程 ,是的话才需要做计取安装费计算
-                                installationFeeObj.calcInstallationFee();
-                            }
+                    if(needCalcAndSave == false){
+                        syncNodeOper(data);
+                        if(callback) callback(newNode);
+                    }else {
+                        project.projectGLJ.loadData(function () {
+                            syncNodeOper(data);
+                            project.calcProgram.calcAndSave(newNode,function () {
+                                if(project.Bills.isFBFX(newNode)) { //判断是否属于分部分项工程 ,是的话才需要做计取安装费计算
+                                    installationFeeObj.calcInstallationFee();
+                                }
+                            });
+                            //如果添加规则中,添加内容为定额子目,则更新相关清单
+                            if(callback) callback(newNode);
                         });
-                        //如果添加规则中,添加内容为定额子目,则更新相关清单
-                        if(callback){
-                            callback(newNode);
-                        }
-                        $.bootstrapLoading.end();
-                    });
-                })
+                    }
+                    $.bootstrapLoading.end();
+                });
                 return newNode;
             }
             else return null;
+            function syncNodeOper(data) {//插入后刷新节点操作
+                newNode = project.mainTree.insert(billItemID, nextID, newSource.ID);
+                newNode.source = newSource;
+                newNode.sourceType = project.Ration.getSourceType();
+                newNode.data = newSource;
+                ProjectController.syncDisplayNewNode(sheetController, newNode);
+                project.ration_glj.addToMainTree(data.ration_gljs);
+                projectObj.mainController.refreshTreeNode([newNode], false);
+            }
         };
         ration.prototype.addNewRationFast = function (rationType,callback) {
             let me = this;

+ 2 - 2
web/building_saas/main/js/views/project_view.js

@@ -1086,7 +1086,7 @@ var projectObj = {
                             newCol = codeCol;
                         }
                         sheet.setActiveCell(newRow, newCol);
-                    },true);
+                    },true,null,false);
                 }
             }
             //在定额/量价/人材机的编码单元格回车,焦点应跳动至本行的工程量单元格
@@ -1113,7 +1113,7 @@ var projectObj = {
                             newCol = codeCol;
                         }
                         sheet.setActiveCell(newRow, newCol);
-                    }, true);
+                    }, true,null,false);
                 }
                 //如果其后有定额空行,焦点跳动至定额空行的编码单元格
                 else if(nextSibling && !(isDef(nextSibling.data.code) && nextSibling.data.code.toString().trim() !== '')) {