Explorar o código

混凝土等组成物的处理

zhangweicheng %!s(int64=7) %!d(string=hai) anos
pai
achega
30e4dc6f2b

+ 7 - 1
modules/glj/models/unit_price_model.js

@@ -271,6 +271,11 @@ class UnitPriceModel extends BaseModel {
         return rList;
     }
 
+    needUpdateParent(connect_key){
+        let noNeedUpdateType = ["202","203","204"];//父类型为混凝土、砂浆,配合比,类型的,不用更新价格
+        let keyList = connect_key.split("|-|");
+        return noNeedUpdateType.indexOf(keyList[4]) == -1
+    }
     async checkAndUpdateParent(unitPrice,field,project_id,newValueMap,batchUpdate=false){//检查是否属于某个工料机的组成物,如果是,并且不是批量更新的情况下,直接更新,如果是批量更新,返回更新任务
         //查找是否是属于某个项目工料机的组成物
         let mixRatioModel = new MixRatioModel();
@@ -281,7 +286,8 @@ class UnitPriceModel extends BaseModel {
         let rList= [];
         if(mixRatioList&&mixRatioList.length>0){
             for(let m of mixRatioList){
-                if(!connectKeyMap.hasOwnProperty(m.connect_key)){//为了去重复,组成物会与其它项目同步,所以有可能重复。
+                // 父类型不为混凝土、砂浆,配合比,类型的,才要更新价格
+                if(this.needUpdateParent(m.connect_key) && !connectKeyMap.hasOwnProperty(m.connect_key)){//为了去重复,组成物会与其它项目同步,所以有可能重复。
                     rList.push(await this.updateParentUnitPrice(m,field,project_id,newValueMap,batchUpdate));
                     connectKeyMap[m.connect_key]=true;
                 }

+ 17 - 1
public/web/gljUtil.js

@@ -36,7 +36,7 @@ let gljUtil = {
                 let m_index = this.getIndex(m,this.gljKeyArray);
                 let m_glj = quantityMap[m_index];
                 let p_glj = quantityMap[pkey];
-                if(m_glj&&p_glj){
+                if(m_glj&&p_glj&&!gljUtil.isConcreteType(p_glj.type) ){//混凝土、砂浆、配合比组成物的消耗量在定额下已经有体现了,不用再计算进去
                     let quantity = scMathUtil.roundForObj(parseFloat(p_glj[qField])*parseFloat(m.consumption),q_decimal);
                     let techQuantity = scMathUtil.roundForObj(parseFloat(p_glj[tField])*parseFloat(m.consumption),q_decimal);
                     let subdivisionQuantity = scMathUtil.roundForObj(parseFloat(p_glj[sField])*parseFloat(m.consumption),q_decimal);
@@ -308,6 +308,22 @@ let gljUtil = {
         }, "code"])
         return list;
     },
+    isConcreteType:function (type) {
+        let concreteType = [gljUtil.gljType.CONCRETE,gljUtil.gljType.MORTAR,gljUtil.gljType.MIX_RATIO];//混凝土大类:混凝土、砂浆,配合比
+        return concreteType.indexOf(type)!=-1
+    },
+    hasComposition:function (ration_glj,isRationType) {//判断是否有组成物,有则返回true   现在主材类型的工料机也有可能有组成物。
+        let type = isRationType==true? ration_glj.subType:ration_glj.type;
+        if(gljUtil.notEditType.indexOf(type)!=-1||type==gljType.MAIN_MATERIAL){
+            let keyArray = isRationType==true? rationKeyArray:gljKeyArray;
+            let con_key = gljUtil.getIndex(ration_glj,keyArray);
+            var mixRatioMap = projectObj.project.projectGLJ.datas.mixRatioMap;
+            if(mixRatioMap[con_key]&&mixRatioMap[con_key].length>0){
+                return true;
+            }
+        }
+        return false;
+    },
     fixedFlag : {
         // 分部分项工程
         SUB_ENGINERRING: 1,

+ 7 - 26
web/building_saas/main/js/views/glj_view.js

@@ -430,16 +430,7 @@ var gljOprObj = {
         }
     },
     hasComposition:function (ration_glj,isRationType) {//判断是否有组成物,有则返回true   现在主材类型的工料机也有可能有组成物。
-        let type = isRationType==true? ration_glj.subType:ration_glj.type;
-        if(gljUtil.notEditType.indexOf(type)!=-1||type==gljType.MAIN_MATERIAL){
-            let keyArray = isRationType==true? rationKeyArray:gljKeyArray;
-            let con_key = this.getIndex(ration_glj,keyArray);
-            var mixRatioMap = projectObj.project.projectGLJ.datas.mixRatioMap;
-            if(mixRatioMap[con_key]&&mixRatioMap[con_key].length>0){
-                return true;
-            }
-        }
-        return false;
+        return gljUtil.hasComposition(ration_glj,isRationType);
     },
     onRangeChanged: function (sender, args) {
         var me = gljOprObj;
@@ -771,14 +762,7 @@ var gljOprObj = {
         return gljUtil.calcPriceDiff(glj,calcOptions);
     },
     getIndex(obj, pops){
-        let t_index = '';
-        let k_arr = [];
-        for (let p of pops) {
-            let tmpK = (obj[p] == undefined || obj[p] == null || obj[p] == '') ? 'null' : obj[p];
-            k_arr.push(tmpK);
-        }
-        t_index = k_arr.join("|-|");
-        return t_index;
+      return gljUtil.getIndex(obj,pops);
     },
     getConditionByKey(conKey){//将连接字符串转换成对象
         let valueArray = conKey.split("|-|");
@@ -1379,13 +1363,11 @@ var gljOprObj = {
         return cellType;
     },
     marketPriceReadOnly: function (node) {
-        let hasCom = false;
-        if(node.sourceType==ModuleNames.ration&&node.data.type==rationType.gljRation){
-            hasCom = this.hasComposition(node.data,true);
-        }else {
-            hasCom = this.hasComposition(node.data);
-        }
-        return hasCom;//2018-9-14 需求变更暂估工料机也能修改市场价原语句:return hasCom|| node.data.isEstimate == 1
+        let isRationType = node.sourceType==ModuleNames.ration&&node.data.type==rationType.gljRation;
+        let type = isRationType==true? node.data.subType:node.data.type;
+        if(gljUtil.isConcreteType(type)) return true;
+        return this.hasComposition(node.data,isRationType); //2018-9-14 需求变更暂估工料机也能修改市场价原语句:return hasCom|| node.data.isEstimate == 1
+
     },
     locateZTree: function(ID) {
         let zTree = $.fn.zTree.getZTreeObj("gljTree");
@@ -1609,7 +1591,6 @@ $(function () {
     }
 })
 
-
 function  operationWithRound(value1,value2,field,symble) {
     let decimal = getDecimal(field);
     value1 = scMathUtil.roundForObj(value1,decimal);

+ 14 - 6
web/building_saas/main/js/views/project_glj_view.js

@@ -258,6 +258,9 @@ projectGljObject={
             return false;
         }
         if(dataCode=='basePrice'||dataCode=='marketPrice'||dataCode=='supply'){//有组成物时,市场单价、定额价、供货方式不能修改
+            if((dataCode=='basePrice'||dataCode=='marketPrice')&&gljUtil.isConcreteType(data.type)){//混凝土,浆砂,配合比,不能修改市场单价,定额价
+                return false;
+            }
             if (data.ratio_data  && data.ratio_data.length > 0){
                 return false;
             }
@@ -462,12 +465,14 @@ projectGljObject={
             parentKey = record.connect_key;
             unit_price_file_id = record.unit_price.unit_price_file_id;
         }
-        for(let sub of me.mixRatioData){
-            let marketPrice = scMathUtil.roundForObj(sub.unit_price.market_price,getDecimal("process"));
-            let basePrice = scMathUtil.roundForObj(sub.unit_price.base_price,getDecimal("process"));
-            let consumption =  updateMap[sub.mix_ratio_id]?updateMap[sub.mix_ratio_id].consumption:scMathUtil.roundForObj(sub.consumption,getDecimal("glj.quantity"));
-            parentMarketPrice = scMathUtil.roundForObj(marketPrice*consumption + parentMarketPrice,getDecimal("process"));
-            parentBasePrice = scMathUtil.roundForObj(basePrice*consumption + parentBasePrice,getDecimal("process"));
+        if(!gljUtil.isConcreteType(parseInt(parentKey.split("|-|")[4]))){//父类型不属于混凝土浆砂配合比,才要计算
+            for(let sub of me.mixRatioData){
+                let marketPrice = scMathUtil.roundForObj(sub.unit_price.market_price,getDecimal("process"));
+                let basePrice = scMathUtil.roundForObj(sub.unit_price.base_price,getDecimal("process"));
+                let consumption =  updateMap[sub.mix_ratio_id]?updateMap[sub.mix_ratio_id].consumption:scMathUtil.roundForObj(sub.consumption,getDecimal("glj.quantity"));
+                parentMarketPrice = scMathUtil.roundForObj(marketPrice*consumption + parentMarketPrice,getDecimal("process"));
+                parentBasePrice = scMathUtil.roundForObj(basePrice*consumption + parentBasePrice,getDecimal("process"));
+            }
         }
         parentBasePrice = scMathUtil.roundForObj(parentBasePrice,getDecimal("glj.unitPrice"));
         parentMarketPrice = scMathUtil.roundForObj(parentMarketPrice,getDecimal("glj.unitPrice"));
@@ -831,6 +836,9 @@ projectGljObject={
         let me = this;
         let parentMarketPrice = 0;
         let parentBasePrice = 0;
+        let parentKey = me.mixRatioData[affectRow].connect_key;
+        let parentType = parentKey.split("|-|")[4];
+        if(gljUtil.isConcreteType(parseInt(parentType))) return [0,0]; //父工料机是混凝土浆砂,配合比,则父价格为0,不用计算
         for(let i = 0;i < me.mixRatioData.length;i++){
             let ratio = me.mixRatioData[i];
             let marketPrice = ratio.unit_price.market_price;