Переглянути джерело

Merge branch 'master' of http://192.168.1.12:3000/SmartCost/ConstructionCost

TonyKang 7 роки тому
батько
коміт
ea094cdcd2

+ 1 - 0
modules/all_models/bills.js

@@ -57,6 +57,7 @@ let billsSchema = new Schema({
     flags: [subSchema.flagsSchema],
     installationKey:String,//用来记录安装增加费的关联字段
     deleteInfo: deleteSchema,
+    isEstimate:{type: Number,default:0},       // 1 true 0 false 是否暂估
     remark:String
 });
 

+ 1 - 1
modules/glj/controllers/glj_controller.js

@@ -101,7 +101,7 @@ class GLJController extends BaseController {
             let model = null;
             switch (modelString) {
                 case 'glj':
-                    if (extend !== '') {
+                    if (extend&&extend !== '') {
                         extend = JSON.parse(extend);
                         for (let code in extend) {
                             updateData[code] = extend[code];

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

@@ -1408,7 +1408,11 @@ class CalcProgram {
                     delete treeNode.data.gljList;
                     let muf = treeNode.data.marketUnitFee ? treeNode.data.marketUnitFee : 0;
                     let q = calcTools.uiNodeQty(treeNode) ? calcTools.uiNodeQty(treeNode) : 0;
-                    treeNode.data.marketTotalFee = (muf * q).toDecimal(decimalObj.ration.totalPrice);
+                    let mtf = (muf * q).toDecimal(decimalObj.ration.totalPrice);
+                    if (treeNode.data.marketTotalFee != mtf){
+                        treeNode.data.marketTotalFee = mtf;
+                        treeNode.changed = true;
+                    } ;
                 }
                 else{
                     treeNode.data.gljList = me.project.ration_glj.getGljArrByRation(treeNode.data.ID);

+ 33 - 6
web/building_saas/main/js/models/project_glj.js

@@ -445,12 +445,21 @@ ProjectGLJ.prototype.changeIsEvaluate=function (id){
         gljs.push(glj);
         let nodes = projectGLJ.getImpactRationNodes(gljs);//取到因为改变工料机价格而受影响的定额
         //更新对应的工料机类型的定额
-        let ration =_.find(projectObj.project.Ration.datas,{'type':rationType.gljRation,'projectGLJID':glj.id});
-        if(ration){
-            ration.isEstimate =glj.is_evaluate?1:0;
-            let ration_node = projectObj.project.mainTree.getNodeByID(ration.ID);
-            ration_node?projectObj.mainController.refreshTreeNode([ration_node]):"";
+        let rations =_.filter(projectObj.project.Ration.datas,{'type':rationType.gljRation,'projectGLJID':glj.id});
+        let ration_nodes = [];
+        for(r of rations){
+            if(r){
+                r.isEstimate =glj.is_evaluate?1:0;
+                let ration_node = projectObj.project.mainTree.getNodeByID(r.ID);
+                ration_node?ration_nodes.push(ration_node):'';
+            }
+        }
+        let ration_glj_nodes = projectGLJ.getMainAndEquGLJNodeByID(glj.id);//取显示在造价书界面上的主材和设备节点
+        for(rg of ration_glj_nodes){
+            rg.data.isEstimate =glj.is_evaluate?1:0;
+            ration_nodes.push(rg);
         }
+        ration_nodes.length>0?projectObj.mainController.refreshTreeNode(ration_nodes):"";
         projectObj.project.calcProgram.calcRationsAndSave(nodes);//触发计算程序
         return gljs;
     }
@@ -477,10 +486,19 @@ ProjectGLJ.prototype.refreshTreeNodePriceIfNeed = function (data) {
             }
         })
         projectObj.mainController.refreshTreeNode(nodes);
-
     }
 }
 
+ProjectGLJ.prototype.getMainAndEquGLJNodeByID = function (id) {//通过ID取显示到主树上的主材和设备节点
+    let nodes = [];
+    if(projectInfoObj.projectInfo.property.displaySetting.disPlayMainMaterial == true){
+         nodes = _.filter(projectObj.project.mainTree.items, function (tem) {
+            return tem.sourceType == ModuleNames.ration_glj && tem.data.projectGLJID == id
+        })
+    }
+    return nodes;
+};
+
 //根据工料机,取得所有受影响的定额节点
 ProjectGLJ.prototype.getImpactRationNodes = function (gljs) {
     let nodes = [];
@@ -509,6 +527,8 @@ ProjectGLJ.prototype.getImpactRationNodes = function (gljs) {
     }
     return nodes;
 };
+
+
 ProjectGLJ.prototype.refreshRationGLJPrice = function (glj) {
     for (let ration_glj of gljOprObj.sheetData) {
         if (ration_glj.projectGLJID == glj.id) {
@@ -651,6 +671,13 @@ ProjectGLJ.prototype.getMarketPrice = function (glj) {
     }
 }
 
+ProjectGLJ.prototype.isEstimateType = function(type){
+    let typeString = type + "";
+    if (typeString.startsWith("2")||typeString=='4'||typeString=='5') {//只有材料、主材、设备类型才显示是否暂估
+       return type;
+    }
+    return false;
+};
 
 ProjectGLJ.prototype.getShortNameByID = function (ID) {
     let gljTypeMap = this.datas.constData.gljTypeMap;

+ 28 - 13
web/building_saas/main/js/models/ration_glj.js

@@ -67,15 +67,20 @@ var ration_glj = {
                 return null;
             }
             for (let ration of rations) {
-                let rationGljs = this.getGljArrByRation(ration.ID);
-                for (let glj of rationGljs) {
-                    let sameGlj = findGlj(glj, result);
-                    if (!sameGlj) {
-                        sameGlj = clone(glj);
-                        sameGlj.quantity = (sameGlj.quantity * ration.quantity).toDecimal(4);
-                        result.push(sameGlj);
-                    } else {
-                        sameGlj.quantity = sameGlj.quantity + (glj.quantity * ration.quantity).toDecimal(4);
+                if (ration.type == rationType.volumePrice || ration.type == rationType.gljRation){
+                    result.push(ration);
+                }
+                else{
+                    let rationGljs = this.getGljArrByRation(ration.ID);
+                    for (let glj of rationGljs) {
+                        let sameGlj = findGlj(glj, result);
+                        if (!sameGlj) {
+                            sameGlj = clone(glj);
+                            sameGlj.quantity = (sameGlj.quantity * ration.quantity).toDecimal(4);
+                            result.push(sameGlj);
+                        } else {
+                            sameGlj.quantity = sameGlj.quantity + (glj.quantity * ration.quantity).toDecimal(4);
+                        }
                     }
                 }
             }
@@ -83,9 +88,20 @@ var ration_glj = {
             result = gljOprObj.combineWithProjectGlj(result);
 
             // 上面取的是清单下所有工料机的总量,我要算清单单价,所以要取单位清单的工料机数量,所以下面要除以清单数量。
-            let oneBill = Array.from(result);
+            let oneBill = JSON.parse(JSON.stringify(result));
+
             for (let glj of oneBill){
-                  glj.quantity = (glj.quantity / billQuantity).toDecimal(decimalObj.glj.quantity);
+                if (glj.type == rationType.volumePrice){  // 量价、工料机形式的定额要进行数据变换才能参与基数计算。
+                    glj.type = glj.subType;
+                    glj.basePrice = glj.marketUnitFee;
+                    glj.marketPrice = glj.marketUnitFee;
+                    glj.adjustPrice = glj.marketUnitFee;
+                }
+                else if (glj.type == rationType.gljRation){
+                    glj.type = glj.subType;
+                };
+
+                glj.quantity = (glj.quantity / billQuantity).toDecimal(decimalObj.glj.quantity);
             };
             return oneBill;
         }
@@ -685,8 +701,7 @@ var ration_glj = {
                 var mixRatioMap = projectGLJData.mixRatioMap;
                 var glj = _.find(projectGljs, {'id': ration.projectGLJID});
                 if (glj) {
-                    let typeString = glj.type + "";
-                    if (typeString.indexOf("2") != -1) {//只有材料类型才显示是否暂估
+                    if(projectObj.project.projectGLJ.isEstimateType(glj.type)){
                         ration.isEstimate = glj.is_evaluate;
                     }
                     ration = gljOprObj.setGLJPrice(ration,glj);

+ 2 - 4
web/building_saas/main/js/views/glj_view.js

@@ -946,8 +946,7 @@ var gljOprObj = {
             for (var i = 0; i < ration_gljs.length; i++) {
                 var glj = _.find(projectGljs, {'id': ration_gljs[i].projectGLJID});
                 if (glj) {
-                    let typeString = ration_gljs[i].type + "";
-                    if (typeString.startsWith("2")||typeString=='4'||typeString=='5') {//只有材料类型才显示是否暂估
+                    if(projectObj.project.projectGLJ.isEstimateType(ration_gljs[i].type )){
                         ration_gljs[i].isEstimate = glj.is_evaluate;
                     }
                     ration_gljs[i].shortName =projectObj.project.projectGLJ.getShortNameByID(ration_gljs[i].type);
@@ -1052,8 +1051,7 @@ var gljOprObj = {
                 isAdd: pg.unit_price.is_add,
                 GLJID: pg.glj_id
             };
-            let typeString = pg.type + "";
-            if (typeString.startsWith("2")||typeString=='4'||typeString=='5') {//只有材料类型才显示是否暂估
+            if(projectObj.project.projectGLJ.isEstimateType(pg.type)){
                 tem.isEstimate =  pg.is_evaluate;
             }
             this.setGLJPrice(tem,pg);

+ 6 - 0
web/building_saas/main/js/views/main_tree_col.js

@@ -267,6 +267,12 @@ let MainTreeCol = {
         isSubcontract: function (node){
             if (calcTools.isRationCategory(node))
                 return new GC.Spread.Sheets.CellTypes.CheckBox();
+        },
+        isEstimate:function (node) {
+            //只对分项、补项、材料(包括混凝土等)、主材、设备有效
+            if(MainTreeCol.readOnly.glj(node)||(calcTools.isGljRation(node)&&projectObj.project.projectGLJ.isEstimateType(node.data.subType))||(MainTreeCol.readOnly.bills(node)&&(node.data.type == billType.BX||node.data.type == billType.FX))){
+                return new GC.Spread.Sheets.CellTypes.CheckBox();
+            }
         }
     },
     editChecking:function(node){

+ 39 - 9
web/building_saas/main/js/views/project_view.js

@@ -373,20 +373,24 @@ var projectObj = {
             };*/
         }
     },
-    updateRemark : function (node,value) {
-        console.log(value);
-        if(node.data.remark == value){
+    updateNodeField : function (node,value,filedID,callback) {
+        if(node.data[filedID] == value){
             return;
         }
         let data =  {
             type:node.sourceType,
             data:{
-                ID:node.data.ID,
-                remark:value
+                ID:node.data.ID
             }
         };
+        data.data[filedID] = value;
+        $.bootstrapLoading.start();
         projectObj.project.updateNodes([data],function () {
-            node.data.remark = value;
+            node.data[filedID] = value;
+            if(callback){
+                callback();
+            }
+            $.bootstrapLoading.end();
         })
     },
     updateCellValue: function (node, value, colSetting,editingText) {
@@ -394,7 +398,7 @@ var projectObj = {
         if(node.sourceType==project.ration_glj.getSourceType()){
             project.ration_glj.updateFromMainSpread(value,node,fieldName);
         }else if(fieldName === 'remark'){
-            projectObj.updateRemark(node,value);
+            projectObj.updateNodeField(node,value,'remark');
         }  else if(calcTools.isGljRation(node)){
             gljOprObj.updateRationTypeGLJ(value,node,fieldName);
         } else if (value !== calcFees.getFee(node.data, fieldName)||fieldName == 'quantity') {//工程量需要进行转换,所以做特殊处理
@@ -1030,10 +1034,36 @@ var projectObj = {
  },
 
     onButtonClick: function (e, info) {
+        let colSetting = projectObj.mainController.setting.cols[info.col];
         let node = projectObj.project.mainTree.items[info.row];
-        if (node.data.isSubcontract) node.data.isSubcontract = false
+        let fieldName = colSetting.data.field;
+        if(fieldName == "isSubcontract"){
+            projectObj.onSubcontractClick(node);
+        }else if(fieldName == "isEstimate"){
+            projectObj.onIsEstimateClick(node,info);
+        }
+    },
+    onIsEstimateClick: function(node,info){
+        let checkboxValue = info.sheet.getCell(info.row, info.col).value();
+        let cell = info.sheet.getCell(info.row, info.col), newval = 0;
+        if (checkboxValue) {
+            newval = 0;
+            cell.value(newval);
+        } else {
+            newval = 1;
+            cell.value(newval);
+        }
+        if(MainTreeCol.readOnly.bills(node)){
+            projectObj.updateNodeField(node,newval,'isEstimate');
+        }else if(node.data.projectGLJID){//更新的是定额类型的工料机或者是显示在造价书页面的主材、设备
+            console.log(node);
+            let updateData = {id: node.data.projectGLJID, field: 'is_evaluate', value: newval};
+            projectObj.project.projectGLJ.pGljUpdate(updateData);
+        }
+    },
+    onSubcontractClick:function (node) {//点击分包费checkbox
+        if (node.data.isSubcontract) node.data.isSubcontract = false;
         else node.data.isSubcontract = true;
-
         node.changed = true;
         projectObj.project.calcProgram.calcAndSave(node);
     },