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

Merge branch '1.0.0_online' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost into 1.0.0_online

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

+ 18 - 4
web/building_saas/main/js/models/quantity_detail.js

@@ -801,7 +801,7 @@ var quantity_detail = {
             //value = scMathUtil.roundForObj(value,getDecimal("ration.quantity"));
             value = project.quantity_detail.autoTransformQuantity(value,node);//先转换再4舍5入
             value = scMathUtil.roundForObj(value,decimalObj.decimal("quantity",node));
-            if( quantityEXP!="GCLMXHJ" && oldQuantityEXP == node.data.quantityEXP && node.data.quantity == value){ //除了修改工程量明细表达式进来的操作,相当于什么都没改,不用做提交操作
+            if( quantityEXP!="MBGCL"&& quantityEXP!="GCLMXHJ" && oldQuantityEXP == node.data.quantityEXP && node.data.quantity == value){ //除了修改工程量明细表达式和模析子目进来的操作,相当于什么都没改,不用做提交操作
                 projectObj.mainController.refreshTreeNode([node]);//这里要再刷新一下,因为工程量要把手工输入的值刷新为转换后的值再显示
                 return;
             }
@@ -813,9 +813,18 @@ var quantity_detail = {
                 node.data.contain=0;
             }
             node.changed = true;
-            project.calcProgram.calcAndSave(node, function () {
+            let rationNodes = mbzm_obj.updateReferenceRationNodeQuantity(node);
+            rationNodes.push(node);
+            project.calcProgram.calcNodesAndSave(rationNodes, function () {
                 project.projectGLJ.calcQuantity();
-                if(project.Bills.isFBFX(node)) { //判断是否属于分部分项工程 ,是的话才需要做计取安装费计算
+                let calcInstall = false;
+                for(let t of rationNodes){
+                    if(project.Bills.isFBFX(t)){//判断是否属于分部分项工程 ,是的话才需要做计取安装费计算
+                        calcInstall = true;
+                        break;
+                    }
+                }
+                if(calcInstall == true) {
                     project.installation_fee.calcInstallationFee(function (isChange,rations) {
                         if(isChange){
                             project.calcProgram.calcNodesAndSave(rations);
@@ -823,7 +832,12 @@ var quantity_detail = {
                     });
                 }
             });
-            projectObj.mainController.refreshTreeNode(node.children);//刷新子工料机总消耗量
+            let childrenNodes = [];
+            for(let r of rationNodes){
+                childrenNodes = childrenNodes.concat(r.children)
+            }
+            if(childrenNodes.length > 0) projectObj.mainController.refreshTreeNode(childrenNodes);//刷新子工料机总消耗量
+            mbzm_obj.refreshSheetData();
             gljOprObj.refreshView();
         };
         quantity_detail.prototype.getDecimal=function (node) {

+ 74 - 10
web/building_saas/main/js/views/mbzm_view.js

@@ -17,7 +17,7 @@ let mbzm_obj={
             {headerName: "模板类别", headerWidth: 260, dataCode: "name", dataType: "String", hAlign: "left"},
             {headerName: "单位", headerWidth: 45, dataCode: "unit", dataType: "String", hAlign: "center",getText:'forUnit'},
             {headerName: "系数", headerWidth: 65, dataCode: "coe", dataType: "Number",validator:"number"},
-            {headerName: "工程量", headerWidth: 65, dataCode: "quantity", dataType: "Number",validator:"number"},
+            {headerName: "工程量", headerWidth: 65, dataCode: "quantity", dataType: "Number",validator:"number",getText:'forQuantity'},//这里做成当系数不为0时,动态生成工程量,同步更新太麻烦
             {headerName: "关联类别", headerWidth: 100, dataCode: "type", dataType: "String"},
             {headerName: "清单位置", headerWidth: 200, dataCode: "position", hAlign: "left", dataType: "String",cellType:'selectButton',getText:'forPosition'},
         ],
@@ -34,6 +34,9 @@ let mbzm_obj={
             },
             forUnit:function (item) {//这里显示的单位是去掉定额单位前面的数字的结果
                return item.unit &&_.isString(item.unit)?item.unit.replace(/^\d+/,""):""
+            },
+            forQuantity:function (item) {
+                return mbzm_obj.getQuantity(item);
             }
         }
     },
@@ -68,7 +71,7 @@ let mbzm_obj={
         this.spread?this.spread.refresh():this.initSpread();
     },
     refreshSheetData:function () {
-        sheetCommonObj.showData(this.sheet, this.setting,this.datas);
+        if($('#mbzmSpread').is(':visible')) sheetCommonObj.showData(this.sheet, this.setting,this.datas);
     },
     showMBZMData:function(node){
         let selected = node?node:projectObj.project.mainTree.selected;
@@ -105,11 +108,8 @@ let mbzm_obj={
             me.refreshSheetData();
             return;
         }
-        if (dataCode === 'coe') {//默认为0,可输入数值,输入数值后,后面的工程量=混凝土子目工程量*系数。
-            let rationQuantity = selected.data.quantity;
-            rationQuantity = rationQuantity?scMathUtil.roundForObj(rationQuantity, getDecimal('ration.quantity')):0;
-            value = scMathUtil.roundForObj(value, getDecimal('process'));
-            recode["quantity"] = scMathUtil.roundForObj(rationQuantity * value, getDecimal('ration.quantity'))+"";
+        if (dataCode === 'coe') {//  //为了避免各种同步更新,后面的工程量改成实时动态计算,所以这里更新为0
+            recode["quantity"] = "0";
         }
         if (dataCode === 'quantity') {//定额默认显示为0,可输入数值,输入数值后,则清空前面的系数列
             value = scMathUtil.roundForObj(value, getDecimal('ration.quantity'))+"";
@@ -118,6 +118,21 @@ let mbzm_obj={
         recode[dataCode] = value;
         me.refreshSheetData();
     },
+    getQuantity:function(item){//当系数不为0的时候实时获取消耗量
+        if(item.coe && item.coe!="0"){
+            let selected = projectObj.project.mainTree.selected;
+            let rationQuantity = selected.data.quantity;
+            rationQuantity = rationQuantity?scMathUtil.roundForObj(rationQuantity, getDecimal('ration.quantity')):0;
+            let times = parseInt(selected.data.unit);
+            times = isNaN(times)?1:times;//工程量要乘以定额单位的倍数
+            let value = scMathUtil.roundForObj(item.coe, getDecimal('process'));
+            //为了避免各种同步更新这里改成实时动态计算带系数的工程量
+            return scMathUtil.roundForObj(rationQuantity * value*times, getDecimal('ration.quantity'))+"";
+        }else {
+            return item.quantity;
+        }
+
+    },
     updatePosition:function (recode) {
         let selection = this.sheet.getSelections()[0];
         let selectedItem =this.datas[selection.row];
@@ -134,7 +149,7 @@ let mbzm_obj={
         let rations = {update:[],create:[]},bills={update:[],create:[]};
         if(this.datas.length <= 0) return;
         for(let d of this.datas){
-            if(gljUtil.isDef(d.quantity)&& parseFloat(d.quantity)>0){
+            if((gljUtil.isDef(d.quantity)&& parseFloat(d.quantity)>0)||(d.coe && d.coe!="0")){
                 if(this.positionChecking(createLocation,d) == false){//清单位置检查
                     alert(`请选择${d.code}生成的清单位置`);
                     return;
@@ -211,7 +226,8 @@ let mbzm_obj={
         return validate
     },
     getNodeUpdateData:function(data,referenceRationID,type,rations,bills){
-        let quantity = this.getQuantity(data);//工程量要经过转换
+        let quantity = this.getQuantity(data);//取实时或手输工程量
+        quantity = this.transferToRationQuantity(data.unit,quantity);//工程量要经过转换
         let mainRation = projectObj.project.mainTree.getNodeByID(referenceRationID);
         let billsID="";
         //先检查要更新的定额是否已经存在
@@ -402,7 +418,7 @@ let mbzm_obj={
         }
         return{itemQuery:itemQuery,newData:newData,defaultLibID: rationLibObj.getDefaultStdRationLibID(),calQuantity:false,brUpdate:[],needInstall:needInstall}
     },
-    getQuantity:function (data) {//取最新的消耗量,需经过转换
+/*    getQuantity:function (data) {//取最新的消耗量,需经过转换
         if(data.unit){
             let times = parseInt(data.unit);
             if(!isNaN(times)){
@@ -410,6 +426,15 @@ let mbzm_obj={
             }
         }
         return data.quantity
+    },*/
+    transferToRationQuantity:function (unit,quantity) {
+        if(unit){
+            let times = parseInt(unit);
+            if(!isNaN(times)){
+                return scMathUtil.roundForObj(parseFloat(quantity)/times,getDecimal("ration.quantity"))+""
+            }
+        }
+        return quantity;
     },
     getExistRation:function (data,referenceRationID,type) {
         let temRation = null;
@@ -475,6 +500,45 @@ let mbzm_obj={
             }
         }
         return refNode;
+    },
+    updateReferenceRationNodeQuantity:function (node) {
+        let rationNodes = [],codeMap={};
+        let  template = projectObj.project.ration_template.getTemplateByRationID(node.data.ID);
+        if(template) {
+            for(let t of template.templateList){
+                if(t.coe && t.coe!="0"){
+                    codeMap[t.code] = t;
+                }
+            }
+            let times = parseInt(node.data.unit);
+            times = isNaN(times)?1:times;//工程量要乘以定额单位的倍数
+            let referenceRations = this.findReferenceRation(node.data.ID);
+            for(let r of  referenceRations ){
+                let t_tem = codeMap[r.code];
+                if(t_tem){
+                    let rationQuantity = node.data.quantity?scMathUtil.roundForObj(node.data.quantity, getDecimal('ration.quantity')):0;
+                    let t_quantity = scMathUtil.roundForObj(rationQuantity * parseFloat(t_tem.coe)*times, getDecimal('ration.quantity')); //这个也要同步更新
+                    let rnode =  projectObj.project.mainTree.findNode(r.ID);
+                    if(rnode && r.quantityEXP == "MBGCL"){//表达式是模板工程量的才要同步更新
+                        let t_times = parseInt(rnode.data.unit);
+                        t_times = isNaN(t_times)?1:t_times;//工程量要乘以定额单位的倍数
+                        rnode.data.quantity = scMathUtil.roundForObj(t_quantity/t_times,getDecimal('ration.quantity'));
+                        if(rnode.parent.data.quantity&&rnode.parent.data.quantity!=0&&rnode.parent.data.quantity!=""){
+                            var billQuantity = scMathUtil.roundForObj(rnode.parent.data.quantity,getDecimal("quantity",node.parent));
+                            rnode.data.contain = scMathUtil.roundForObj(rnode.data.quantity/billQuantity,getDecimal("process"));
+                        }else {
+                            rnode.data.contain=0;
+                        }
+                        rnode.change = true;
+                        rationNodes.push(rnode)
+                    }
+                }
+            }
+        }
+        return rationNodes;
+    },
+    findReferenceRation:function(rationID){
+        return _.filter(projectObj.project.Ration.datas,{'referenceRationID':rationID})
     }
 };
 

+ 13 - 5
web/building_saas/main/js/views/quantity_edit_view.js

@@ -146,12 +146,20 @@ let quantityEditObj = {
         let value = me.evalQuantityExp(quantityEXP,node);
         if(value!=='evalError'){
             if(node.data.hasOwnProperty('isFromDetail')&&node.data.isFromDetail==1){
-                hintBox.infoBox('操作确认', '已有工程量明细,是否清空明细表?', 2, function () {
-                    node.data.isFromDetail=0;
-                    me.updateQuantityEXP(value,quantityEXP,node);
-                }, function () {
+                if(quantityEXP!="GCLMXHJ"){
+                    hintBox.infoBox('操作确认', '已有工程量明细,是否清空明细表?', 2, function () {
+                        node.data.isFromDetail=0;
+                        me.updateQuantityEXP(value,quantityEXP,node);
+                    }, function () {
+                        projectObj.mainController.refreshTreeNode([node]);
+                    },['确定','取消'],false);
+                }else {//表达式已经是工程量明细合计了,重新刷新就可
                     projectObj.mainController.refreshTreeNode([node]);
-                },['确定','取消'],false);
+                }
+                return true;
+            }
+            if(quantityEXP=="MBGCL") {
+                projectObj.mainController.refreshTreeNode([node]);
                 return true;
             }
             me.updateQuantityEXP(value,quantityEXP,node);