zhongzewei 7 лет назад
Родитель
Сommit
4abf2a2c21

+ 57 - 7
web/building_saas/main/js/controllers/project_controller.js

@@ -24,23 +24,59 @@ ProjectController = {
     addBills: function (project, sheetController, std) {
         if (!project || !sheetController) { return null; }
         let target = project.getParentTarget(project.mainTree.selected, 'sourceType', project.Bills.getSourceType());
-        let newSource = null, newNode = null, parentID, nextSiblingID;
+        let newSource = null, newNode = null, parentID, nextSiblingID, nodeParentID, nodeNextSiblingID;
         if (target) {
-            console.log(target.depth());
+            if(target.depth() === 0){
+                parentID = target.source.getID();
+                nextSiblingID = project.Bills.tree.setting.rootId;
+                nodeParentID = target.getID();
+                nodeNextSiblingID = project.mainTree.rootID();
+            }
+            else{
+                parentID = target.source.getParentID();
+                nextSiblingID = target.source.getNextSiblingID();
+                nodeParentID = target.getParentID();
+                nodeNextSiblingID = target.getNextSiblingID();
+            }
             parentID = target.depth() === 0 ? target.source.getID() : target.source.getParentID();
             nextSiblingID = target.depth() === 0 ? project.Bills.tree.setting.rootId : target.source.getNextSiblingID();
 
             if (std) {
+                let fixedNode = getRootFixedNode(target);
+                if(!isFlag(fixedNode.data) || (fixedNode.data.flagsIndex.fixed.flag !== fixedFlag.SUB_ENGINERRING && fixedNode.data.flagsIndex.fixed.flag !== fixedFlag.MEASURE)){
+                    return;
+                }
+                //焦点行属于分部分项
+                if(fixedNode.data.flagsIndex.fixed.flag === fixedFlag.SUB_ENGINERRING){
+                    std.type = billType.FX;
+                    //焦点行是分部分项
+                    let subType = getSubType(target);
+                    if(target.sourceType === project.Bills.getSourceType() && target.data.type === billType.DXFY && subType === billType.FB){
+                        return;
+                    }
+                    //焦点行是分部
+                    else if(target.sourceType === project.Bills.getSourceType() && target.data.type === billType.FB){
+                        if(!subType || subType === billType.FX){
+                            parentID = target.source.getID();
+                            nextSiblingID = project.Bills.tree.setting.rootId;
+                            nodeParentID = target.getID();
+                            nodeNextSiblingID = project.mainTree.rootID();
+                        }
+                        else{
+                            return;
+                        }
+                    }
+                }
+                else {
+                    std.type = billType.BILL;
+                }
+
                 let newCode = project.Bills.newFormatCode(std.code);
                 newSource = project.Bills.insertStdBills(parentID, nextSiblingID, std, newCode);
             } else {
                 newSource = project.Bills.insertBills(parentID, nextSiblingID);
             }
-            if (target.depth() === 0) {
-                newNode = project.mainTree.insert(target.getID(), project.mainTree.rootID())
-            } else {
-                newNode = project.mainTree.insert(target.getParentID(), target.getNextSiblingID());
-            }
+            newNode = project.mainTree.insert(nodeParentID, nodeNextSiblingID);
         } else {
             alert('不可添加清单');
         }
@@ -52,6 +88,17 @@ ProjectController = {
 
             this.syncDisplayNewNode(sheetController, newNode);
         }
+        function getSubType(node){
+            for(let sub of node.children){
+                if(sub.sourceType === project.Bills.getSourceType() && sub.data.type === billType.FB){
+                    return billType.FB;
+                }
+                else if(sub.sourceType === project.Bills.getSourceType() && sub.data.type === billType.FX){
+                    return billType.FX;
+                }
+            }
+            return null;
+        }
     },
     addRootBill:function (project, sheetController) {//添加大项费用
         if (!project || !sheetController) { return null; }
@@ -109,6 +156,9 @@ ProjectController = {
             } else if (selected.data.calcBase&&selected.data.calcBase!="") {
                 alert('当前有基数计算不能插入定额/量价/工料机。');
             } else {
+                if(selected.data.type === billType.FB){
+                    return;
+                }
                 if (std) {
                     newSource = project.Ration.insertStdRation(selected.source.getID(), null, std);
                     project.ration_glj.addRationGLJ(newSource,std);

+ 20 - 1
web/building_saas/main/js/models/bills.js

@@ -203,7 +203,7 @@ var Bills = {
                     data.data.jobContentText = stdBillsData.jobContentText;
                     data.data.itemCharacterText = stdBillsData.itemCharacterText;
                     data.data.programID = stdBillsData.engineering;
-                    data.data.type = billType.BILL;//插入清单类型
+                    data.data.type = stdBillsData.type;//插入清单类型
                     //zhong
                     newData = data.data;
                 }
@@ -426,3 +426,22 @@ function isDef(v) {
 function isFlag(v) {
     return this.isDef(v.flagsIndex) && this.isDef(v.flagsIndex.fixed);
 }
+
+function getRootFixedNode(node) {
+    let parent = node.parent;
+    if(isFlag(node.data) && (node.data.flagsIndex.fixed.flag === fixedFlag.SUB_ENGINERRING
+        || node.data.flagsIndex.fixed.flag === fixedFlag.MEASURE
+        || node.data.flagsIndex.fixed.flag === fixedFlag.OTHER
+        || node.data.flagsIndex.fixed.flag === fixedFlag.CHARGE
+        || node.data.flagsIndex.fixed.flag === fixedFlag.TAX)){
+        return node;
+    }
+    else {
+        if(!parent){
+            return node;
+        }
+        else {
+            return getRootFixedNode(parent);
+        }
+    }
+}

+ 0 - 2
web/building_saas/main/js/models/calc_base.js

@@ -895,9 +895,7 @@ let calcBase = {
             //输入式转换表达式
             let compileExp = $CBP.toCompileExpr(exp);
             //计算
-            console.log(compileExp);
             let calcExp = $CBP.percentToNum(compileExp);
-            console.log(calcExp);
             let calcBaseValue = eval(calcExp);
             if(!cbTools.isNum(calcBaseValue)){
                 throw '表达式不正确';

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

@@ -132,7 +132,6 @@ let calcBaseView = {
         let me = calcBaseView;
         //输入框显示原本的
         if(me.isDef(node.data.calcBase)){
-            console.log('enter');
             me.inputExpr.val(cbParser.toFExpr(node.data.calcBase));
         }
         me.buildSheet();