Selaa lähdekoodia

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

Conflicts:
	web/building_saas/main/js/models/calc_program.js
chenshilong 7 vuotta sitten
vanhempi
commit
c4ea57670e

+ 2 - 0
modules/all_models/bills.js

@@ -20,6 +20,7 @@ let billsSchema = new Schema({
     name: String,
     unit: String,
     quantity: String, // Decimal
+    quantity2:String,//预算项目中的数量2
     quantityEXP:String,//工程量表达式
     feeRateID:Number,
     feeRate:String,
@@ -64,6 +65,7 @@ let billsSchema = new Schema({
     installationKey:String,//用来记录安装增加费的关联字段
     deleteInfo: deleteSchema,
     isEstimate:{type: Number,default:0},       // 1 true 0 false 是否暂估
+    unitPriceAnalysis:{type: Number,default:0},       // 1 true 0 false 单价分析
     specialProvisional:String,
     remark:String,
     engineeringContent:String,//工程内容

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

@@ -169,9 +169,8 @@ let calcTools = {
         }
         else if (!treeNode.updateData.feesIndex){
             treeNode.updateData.feesIndex = {};
-            for (let fee of treeNode.updateData.fees){
+            for (let fee of treeNode.updateData.fees)
                 treeNode.updateData.feesIndex[fee.fieldName] = fee;
-            };
             treeNode.changed = true;
         };
     },
@@ -185,10 +184,9 @@ let calcTools = {
                 'tenderUnitFee': 0,
                 'tenderTotalFee': 0
             };
-            treeNode.updateData.fees.push(fee);
-            treeNode.updateData.feesIndex[fieldName] = fee;
             treeNode.data.fees.push(fee);
             treeNode.data.feesIndex[fieldName] = fee;
+            treeNode.updateData.fees = _.cloneDeep(treeNode.data.fees);
             treeNode.changed = true;
         };
     },
@@ -1999,7 +1997,7 @@ class CalcProgram {
         this.saveNodes(changedNodes, callback);
     };
     setUpdateDataToNode(node){//将updateData里面的值设到node.data上,计算结点时才能拿到最新的值
-        if(_.isEmpty(node.updateData)){
+        if(!_.isEmpty(node.updateData)){
             for(let key in node.updateData){
                 node.data[key] = node.updateData[key];
             }

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

@@ -226,6 +226,11 @@ let MainTreeCol = {
             }
             return false;
         },
+        forQuantity2:function (node) {
+            if(node.sourceType !== ModuleNames.bills) return true;//不是清单,只读
+            if(node.data.type==billType.DXFY||(node.data.type==billType.BILL&&MainTreeCol.readOnly.billsParent(node))) return true;//大项费用、清单父项行,工程量只读。
+            return false
+        },
         forMarketPrice: function (node) {
             return MainTreeCol.readOnly.bills(node) ||
                 (node.sourceType === ModuleNames.ration && node.data.type == rationType.ration) ||
@@ -347,11 +352,11 @@ let MainTreeCol = {
                 return new GC.Spread.Sheets.CellTypes.CheckBox();
             }
         },
+        unitPriceAnalysis:function (node) {
+            if(node.sourceType == ModuleNames.bills) return new GC.Spread.Sheets.CellTypes.CheckBox();
+        },
         evaluationProject:function (node) {
-            if(node.sourceType == ModuleNames.ration){
-                return new GC.Spread.Sheets.CellTypes.CheckBox();
-            }
-
+            if(node.sourceType == ModuleNames.ration) return new GC.Spread.Sheets.CellTypes.CheckBox();
         },
         commonTotalFee: function () {
             return projectObj.getCommonTotalFeeCellType();

+ 45 - 3
web/building_saas/main/js/views/project_view.js

@@ -1706,8 +1706,9 @@ var projectObj = {
             projectObj.onIsEstimateClick(node,info);
         }else if(fieldName == "evaluationProject"){
             projectObj.onEvaluationProjectClic(node,info);
+        }else if(fieldName == "unitPriceAnalysis"){
+            projectObj.onUnitPriceAnalysisClick(node,info);
         }
-
     },
     onEvaluationProjectClic:function (node,info) {
         let checkboxValue = info.sheet.getCell(info.row, info.col).value();
@@ -1719,8 +1720,7 @@ var projectObj = {
             projectObj.project.calcProgram.calcAndSave(node);
         })
     },
-
-    onIsEstimateClick: function(node,info){
+    setAndGetCheckBoxVal:function (info) {
         let checkboxValue = info.sheet.getCell(info.row, info.col).value();
         let cell = info.sheet.getCell(info.row, info.col), newval = 0;
         if (checkboxValue) {
@@ -1730,6 +1730,10 @@ var projectObj = {
             newval = 1;
             cell.value(newval);
         }
+        return newval;
+    },
+    onIsEstimateClick: function(node,info){
+        let newval = projectObj.setAndGetCheckBoxVal(info);
         if(MainTreeCol.readOnly.bills(node)){
             projectObj.updateNodeField(node,newval,'isEstimate');
         }else if(node.data.projectGLJID){//更新的是定额类型的工料机或者是显示在造价书页面的主材、设备
@@ -1738,6 +1742,44 @@ var projectObj = {
             projectObj.project.projectGLJ.pGljUpdate(updateData);
         }
     },
+    onUnitPriceAnalysisClick:function (unode,info) {
+        let updateDatas=[],nodes=[];
+        let newval = projectObj.setAndGetCheckBoxVal(info);
+         //仅对大项费用、清单有效,修改父项清单,子项清单跟随修改。
+        if(unode.sourceType == ModuleNames.bills) unitPriceAnalysisUpdate(unode,newval);
+        if(updateDatas.length > 0){
+            $.bootstrapLoading.start();
+            projectObj.project.updateNodes(updateDatas,function () {
+                for(let n of nodes){
+                    n.data.unitPriceAnalysis = newval;
+                }
+                projectObj.mainController.refreshTreeNode(nodes);
+                $.bootstrapLoading.end();
+            })
+        }
+
+
+         function unitPriceAnalysisUpdate(node,val){
+             updateDatas.push(getUnitPriceUpdataData(node,val));
+             nodes.push(node);
+             if(node.children.length > 0 && node.children[0].sourceType == ModuleNames.bills) {//仅对大项费用、清单有效
+                 for(let i = 0;i<node.children.length;i++ ){
+                     unitPriceAnalysisUpdate(node.children[i],val)
+                 }
+             }
+         }
+
+         function getUnitPriceUpdataData(node,val) {
+             let data =  {
+                 type:node.sourceType,
+                 data:{
+                     ID:node.data.ID,
+                     unitPriceAnalysis:val
+                 }
+             };
+             return data;
+         }
+    },
     onSubcontractClick:function (node) {//点击分包费checkbox
         if (node.updateData.isSubcontract) node.updateData.isSubcontract = false;
         else node.updateData.isSubcontract = true;