Просмотр исходного кода

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

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

+ 8 - 14
web/building_saas/main/js/controllers/project_controller.js

@@ -59,20 +59,16 @@ ProjectController = {
             } else if (false) {
                 alert('当前清单已有公式计算,不能套用定额。');
             } else {
-                let firstChild = selected.firstChild();
-                if (firstChild && firstChild.sourceType === project.VolumePrice.getSourceType()) {
-                    alert('当前位置已有量价,不能套用定额。');
+                if (std) {
+                    newSource = project.Ration.insertStdRation(selected.source.getID(), null, std);
+                    project.ration_glj.addRationGLJ(newSource,std);
                 } else {
-                    if (std) {
-                        newSource = project.Ration.insertStdRation(selected.source.getID(), null, std);
-                        project.ration_glj.addRationGLJ(newSource,std);
-                    } else {
-                        newSource = project.Ration.insertRation(selected.source.getID());
-                    }
+                    newSource = project.Ration.insertRation(selected.source.getID());
                 }
+
                 newNode = project.mainTree.insert(selected.getID(), selected.tree.rootID());
             }
-        } else if (selected.sourceType === project.Ration.getSourceType()) {
+        } else if (selected.sourceType === project.Ration.getSourceType() || selected.sourceType === project.VolumePrice.getSourceType()) {
             if (std) {
                 newSource = project.Ration.insertStdRation(selected.source[project.masterField.ration], selected.source, std);
                 project.ration_glj.addRationGLJ(newSource,std);
@@ -80,9 +76,7 @@ ProjectController = {
                 newSource = project.Ration.insertRation(selected.source[project.masterField.ration], selected.source);
             }
             newNode = project.mainTree.insert(selected.getParentID(), selected.getNextSiblingID());
-        } else if (selected.sourceType === project.VolumePrice.getSourceType()) {
-            alert('当前位置已有量价,不能套用定额。');
-        }
+        };
         if (newNode) {
             newNode.source = newSource;
             newNode.sourceType = project.Ration.getSourceType();
@@ -117,7 +111,7 @@ ProjectController = {
         if (selected.sourceType === project.Bills.getSourceType() && selected.source.children.length === 0) {
             newSource = project.VolumePrice.insertVolumePrice(selected.source.getID());
             newNode = project.mainTree.insert(selected.getID(), selected.tree.rootID());
-        } else if (selected.sourceType === project.VolumePrice.getSourceType()) {
+        } else if (selected.sourceType === project.Ration.getSourceType() || selected.sourceType === project.VolumePrice.getSourceType()) {
             newSource = project.VolumePrice.insertVolumePrice(selected.source[project.masterField.volumePrice], selected.source);
             newNode = project.mainTree.insert(selected.getParentID(), selected.getNextSiblingID());
         }

+ 6 - 5
web/building_saas/main/js/models/calc_program.js

@@ -582,6 +582,7 @@ class CalcProgram {
 
         // 汇总定额或子清单的费用类别
         if (treeNode.calcType == treeNodeCalcType.ctGatherRations || treeNode.calcType == treeNodeCalcType.ctGatherBills){
+            treeNode.data.programID = null;
             initFees(treeNode);
 
             let objsArr = (treeNode.calcType == treeNodeCalcType.ctGatherRations) ? project.Ration.getRationsByNode(treeNode) : treeNode.children;
@@ -612,7 +613,7 @@ class CalcProgram {
             treeNode.data.calcTemplate = {"calcItems": rst};
         }
         else{
-            // 叶子清单的缺省计算程序需要提供总金额作为计算基数(不需要工料机),然后每条按比例(费率)计算,不需要工料机明细。
+            // 叶子清单的公式计算:使用缺省清单计算程序需要提供总金额作为计算基数(不需要工料机),然后每条按比例(费率)计算,不需要工料机明细。
             if (treeNode.calcType == treeNodeCalcType.ctCalcBaseValue){
                 delete treeNode.data.gljList;
 
@@ -626,16 +627,16 @@ class CalcProgram {
                 treeNode.data.marketTotalFee = (muf * q).toDecimal(me.digit);
                 treeNode.data.gljList = me.project.ration_glj.getGljArrByRation(treeNode.data.ID);
                 if (treeNode.data.programID == undefined){
-                    treeNode.data.programID = 1;
+                    treeNode.data.programID = projectInfoObj.projectInfo.property.engineering;
                 };
             }
             else if (treeNode.calcType == treeNodeCalcType.ctBillCalcProgram) {
                 let rations = project.Ration.getBillsSortRation(treeNode.source.getID());
                 treeNode.data.gljList = project.ration_glj.getGatherGljArrByRations(rations);
 
-                if (treeNode.data.programID == undefined){
-                    treeNode.data.programID = 1;
-                };
+                if (treeNode.data.programID == undefined || treeNode.data.programID == defaultBillTemplate.ID){
+                    treeNode.data.programID = projectInfoObj.projectInfo.property.engineering;
+                }
             };
 
             let template = me.compiledTemplates[treeNode.data.programID];

+ 1 - 1
web/building_saas/main/js/models/ration.js

@@ -154,7 +154,7 @@ var Ration = {
         ration.prototype.getInsertRationData = function (billsID, preRation) {
             var br = this.getBillsSortRation(billsID);
             var updateData = [];
-            if (preRation) {
+            if (preRation && br.indexOf(preRation) > -1) {  // CSL, 2017-11-28  如果preIndex是-1,表明preRation 是量价。
                 var preIndex = br.indexOf(preRation), i;
                 updateData.push({updateType: 'ut_create', updateData: this.getTempRationData(this.maxRationID() + 1, billsID, preIndex < br.length - 1 ? br[preIndex + 1].serialNo : br[preIndex].serialNo + 1)});
                 for (i = preIndex + 1; i < br.length; i++) {

+ 4 - 2
web/building_saas/main/js/models/volume_price.js

@@ -51,6 +51,8 @@ var VolumePrice = {
             getTempVolumePrice (newID, billsID, serialNo) {
                 var newData = {'ID': newID, 'serialNo': serialNo, projectID: tools.owner.ID()};
                 newData[project.masterField.volumePrice] = billsID;
+                newData.type = '材料';
+                newData.programID = projectInfoObj.projectInfo.property.engineering;
                 return newData;
             };
             getBillsSortVolumePrice (billsID) {
@@ -75,7 +77,7 @@ var VolumePrice = {
             getInsertVolumePriceData (billsID, pre) {
                 let bv = this.getBillsSortVolumePrice(billsID);
                 let updateData = [];
-                if (pre) {
+                if (pre && bv.indexOf(pre) > -1) {
                     let preIndex = bv.indexOf(pre), i;
                     updateData.push({updateType: 'ut_create', updateData: this.getTempVolumePrice(this.maxID() + 1, billsID, preIndex < bv.length - 1 ? bv[preIndex + 1].serialNo : bv[preIndex].serialNo + 1)});
                     for (i = preIndex + 1; i < bv.length; i++) {
@@ -90,7 +92,7 @@ var VolumePrice = {
                 tools.owner.pushNow('insertVolumePrice', [this.getSourceType(), this.getProject().projCounter()], [this.getInsertVolumePriceData(billsID, pre), this.getCounterData()]);
 
                 let bv = this.getBillsSortVolumePrice(billsID), newVP = null;
-                if (pre) {
+                if (pre && bv.indexOf(pre) > -1) {
                     let preIndex = bv.indexOf(pre);
                     newVP = this.getTempVolumePrice(this.getNewID(), billsID, preIndex < bv.length - 1 ? bv[preIndex + 1].serialNo : bv[preIndex].serialNo + 1);
                     this.datas.push(newVP);

+ 1 - 1
web/building_saas/main/js/views/calc_program_view.js

@@ -232,7 +232,7 @@ let calcProgramObj = {
             projectObj.project.calcProgram.calculate(treeNode);
             projectObj.project.calcProgram.saveNode(treeNode);
         };
-        me.datas = treeNode.data.calcTemplate.calcItems;
+        me.datas = treeNode.data.calcTemplate ? treeNode.data.calcTemplate.calcItems : [];
         sheetCommonObj.initSheet(me.sheet, me.setting, me.datas.length);
         sheetCommonObj.showData(me.sheet, me.setting, me.datas);
 

+ 19 - 4
web/building_saas/main/js/views/main_tree_col.js

@@ -31,6 +31,15 @@ let MainTreeCol = {
             return node.sourceType !== projectObj.project.VolumePrice.getSourceType();
         },
 
+        calcProgramName: function (node) {
+            if (
+                node.sourceType === projectObj.project.VolumePrice.getSourceType() ||
+                node.sourceType === projectObj.project.Ration.getSourceType() ||
+                (node.sourceType === projectObj.project.Bills.getSourceType() && node.source.children && node.source.children.length === 0 && projectObj.project.projSetting.billsCalcMode === billsPrice)
+            ) return false
+            else return true;
+        },
+
         bills: function (node) {
             return node.sourceType === projectObj.project.Bills.getSourceType();
         },
@@ -85,10 +94,16 @@ let MainTreeCol = {
             return feeRateObject.getFeeRateEditCellType();
         },
 
-        calcProgramName: function () {
-            var names = new GC.Spread.Sheets.CellTypes.ComboBox();
-            names.items(projectObj.project.calcProgram.compiledTemplateNames);
-            return names;
+        calcProgramName: function (node) {
+            if (
+                node.sourceType === projectObj.project.VolumePrice.getSourceType() ||
+                node.sourceType === projectObj.project.Ration.getSourceType() ||
+                (node.sourceType === projectObj.project.Bills.getSourceType() && node.source.children && node.source.children.length === 0 && projectObj.project.projSetting.billsCalcMode === billsPrice)
+            ) {
+                var names = new GC.Spread.Sheets.CellTypes.ComboBox();
+                names.items(projectObj.project.calcProgram.compiledTemplateNames);
+                return names;
+            }
         },
 
         type: function (node) {

+ 14 - 28
web/building_saas/main/js/views/project_view.js

@@ -414,20 +414,13 @@ var projectObj = {
                     disabled: function () {
                         var selected = project.mainTree.selected;
                         if (selected) {
-                            if (selected.sourceType === project.Ration.getSourceType()) {
-                                return false;
-                            } else if (selected.sourceType === project.Bills.getSourceType()) {
-                                if (selected.source.children.length === 0) {
-                                    return selected.children.length !== 0 ? selected.firstChild().sourceType !== project.Ration.getSourceType() : false;
-                                } else {
-                                    return true;
-                                }
-                            } else if (selected.sourceType === project.VolumePrice.getSourceType()) {
-                                return true;
-                            };
-                        } else {
-                            return true;
-                        }
+                            if (            // CSL, 2017-11-28
+                                selected.sourceType === project.Ration.getSourceType() ||
+                                selected.sourceType === project.VolumePrice.getSourceType() ||
+                                (selected.sourceType === project.Bills.getSourceType() && selected.source.children.length === 0)
+                               ) return false
+                            else return true
+                        } else return true
                     },
                     callback: function (key, opt) {
                         ProjectController.addRation(project, controller);
@@ -439,20 +432,13 @@ var projectObj = {
                     disabled: function () {
                         var selected = project.mainTree.selected;
                         if (selected) {
-                            if (selected.sourceType === project.Ration.getSourceType()) {
-                                return true;
-                            } else if (selected.sourceType === project.Bills.getSourceType()) {
-                                if (selected.source.children.length === 0) {
-                                    return selected.children.length !== 0 ? selected.firstChild().sourceType !== project.VolumePrice.getSourceType() : false;
-                                } else {
-                                    return true;
-                                }
-                            } else if (selected.sourceType === project.VolumePrice.getSourceType()) {
-                                return false;
-                            };
-                        } else {
-                            return true;
-                        }
+                            if (            // CSL, 2017-11-28
+                            selected.sourceType === project.Ration.getSourceType() ||
+                            selected.sourceType === project.VolumePrice.getSourceType() ||
+                            (selected.sourceType === project.Bills.getSourceType() && selected.source.children.length === 0)
+                            ) return false
+                            else return true
+                        } else return true
                     },
                     callback: function (key, opt) {
                         ProjectController.addVolumePrice(project, controller);