zhangweicheng 7 years ago
parent
commit
95397a8c89

+ 3 - 1
web/building_saas/glj/js/project_glj.js

@@ -341,7 +341,9 @@ function successTrigger(field, info) {
             break;
     }
     // 重新加载数据到缓存
-    projectObj.project.projectGLJ.loadData();
+    projectObj.project.projectGLJ.loadData(function () {
+        projectObj.project.projectGLJ.loadCacheData();
+    });
 
     // 更新定额工料机
     gljOprObj.refreshView();

+ 3 - 2
web/building_saas/glj/js/project_glj_spread.js

@@ -356,10 +356,11 @@ ProjectGLJSpread.prototype.compositionCalculate = function(row) {
                 continue;
             }
             let rowConsumption = consumption[index] === undefined ? 0 : consumption[index];
+            let decimal = getDecimal("glj.unitPrice");
             // 计算价格
-            let rowMarketPrice = (marketPrice * rowConsumption).toDecimal(2);
+            let rowMarketPrice = (marketPrice * rowConsumption).toDecimal(decimal);
             parentMarketPrice[active] = parentMarketPrice[active] === undefined ?
-                rowMarketPrice : (parentMarketPrice[active] + rowMarketPrice).toDecimal(2);
+                rowMarketPrice : (parentMarketPrice[active] + rowMarketPrice).toDecimal(decimal);
 
         }
 

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

@@ -34,7 +34,7 @@ const gljType = {
     COMMERCIAL_MORTAR: 206,
     // ==============材料类型=================
     // ==============机械类型=================
-    // 普通机械
+    // 机械台班
     GENERAL_MACHINE: 301,
     // 机械组成物
     MACHINE_COMPOSITION: 302,

+ 15 - 0
web/building_saas/main/js/models/project_glj.js

@@ -170,6 +170,8 @@ ProjectGLJ.prototype.updateBasePriceFromRG=function(recode,updateField,newval){
             me.refreshProjectGLJPrice(data);
             me.refreshRationGLJPrice(glj);
             gljOprObj.showRationGLJSheetData();
+            me.refreshTreeNodePriceIfNeed(glj);
+            
             $.bootstrapLoading.end();
         }
         $.bootstrapLoading.start();
@@ -180,6 +182,18 @@ ProjectGLJ.prototype.updateBasePriceFromRG=function(recode,updateField,newval){
         gljOprObj.showRationGLJSheetData();
     }
 }
+ProjectGLJ.prototype.refreshTreeNodePriceIfNeed = function (data) {
+    if((data.unit_price.type = gljType.MAIN_MATERIAL||data.type==gljType.EQUIPMENT)&&projectInfoObj.projectInfo.property.displaySetting.disPlayMainMateria==true){
+        var nodes = _.filter(projectObj.project.mainTree.items,function (tem) {
+            if(tem.sourceType==ModuleNames.ration_glj&&tem.data.projectGLJID ==data.id){
+                tem.data.marketUnitFee = data.unit_price.market_price;
+                return true;
+            }
+        })
+        projectObj.mainController.refreshTreeNode(nodes);
+
+    }
+}
 
 ProjectGLJ.prototype.refreshRationGLJPrice=function (glj) {
     for(let ration_glj of gljOprObj.sheetData){
@@ -209,6 +223,7 @@ ProjectGLJ.prototype.refreshProjectGLJPrice=function(data){
                 glj.unit_price.market_price = d.market_price;
                 this.setAdjustPrice(glj);
                 this.refreshRationGLJPrice(glj);
+                this.refreshTreeNodePriceIfNeed(glj);
             }
         }
     }

+ 16 - 5
web/building_saas/main/js/models/ration_glj.js

@@ -286,20 +286,19 @@ var ration_glj = {
             var callback=function (data) {
                 let initShow = false;//是否需要表格初始化显示
                 if(updateField=='customQuantity'){
-                    console.log(data);
                     me.refreshAfterQuantityUpdate(data,node);
                 }else {
                     var doc = data.doc;
                     for(var key in doc){
                         recode[key] = doc[key];
                     }
-                    console.log(data);
                     if(data.hasOwnProperty('adjustState')){//更新定额调整状态
                         me.updateRationAdjustState(data.adjustState,recode.rationID,node);
                     }
                     if(recode.subList&&recode.subList.length>0){
                         initShow = true;
                     }
+                    node?"":me.refreshTreeNodeIfNeeded(recode);//如果不是在造价书页面直接编辑,则不用刷新
                 }
                 if(initShow==false){//不需要初始化,只需耍新当前显示就可以了
                     gljOprObj.showRationGLJSheetData();
@@ -343,7 +342,7 @@ var ration_glj = {
             })
             if(node){
                 node.data.adjustState=adjustState;
-                nodes.push(node)
+                nodes.push(node);
             }
             if(rnode){
                 nodes.push(rnode);
@@ -382,7 +381,7 @@ var ration_glj = {
               }
               if(glj.hasOwnProperty("compilationId")){
                   ration_glj.from="cpt";
-                  if(glj.code.indexOf('-')!=-1){//这条工料机是用户通过修改称、规格、型号等保存到补充工料机库的
+                  if(glj.code.indexOf('-')!=-1){//这条工料机是用户通过修改称、规格、型号等保存到补充工料机库的
                       ration_glj.original_code = glj.code.split('-')[0];//取-前的编号作为原始编号
                   }
               }
@@ -493,7 +492,13 @@ var ration_glj = {
                 return;
             }
             if(fieldName=="marketUnitFee"){
-
+                var decimal =getDecimal("glj.unitPrice");
+                var newval = number_util.checkNumberValue(value,decimal);
+                if(newval){
+                    fieldName="marketPrice";
+                    projectObj.project.projectGLJ.updatePriceFromRG(node.data,fieldName,newval);
+                    return;
+                }
             }else {
                 if(value!==undefined&&value!==null){
                     if(fieldName=="subType"){
@@ -507,6 +512,12 @@ var ration_glj = {
            // node.data.subType = value;
             projectObj.mainController.refreshTreeNode([node]);
         };
+        ration_glj.prototype.refreshTreeNodeIfNeeded=function (data) {
+            if((data.type == gljType.MAIN_MATERIAL||data.type==gljType.EQUIPMENT)&&projectInfoObj.projectInfo.property.displaySetting.disPlayMainMateria==true){
+                this.transferToNodeData(data);
+                gljOprObj.refreshTreeNode({"type":ModuleNames.ration_glj,"ID":data.ID});
+            }
+        }
         return new ration_glj(project);
     }
 };

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

@@ -559,7 +559,7 @@ var gljOprObj = {
         this.sheet.setRowCount(0);
         //console.log(+new Date())
         //this.sheet.getRange(0,-1,this.sheet.getRowCount(),-1).visible(true); //这个方法导致加载缓慢
-        this.sheetData=_.sortBy(this.sheetData,'type');
+        this.sheetData=_.sortByAll(this.sheetData,['type','code']);
         this.sumQuantity();//计算总消耗量
         this.addMixRatioToShow();//显示组成物信息
         this.initRationTree(init);
@@ -751,7 +751,7 @@ var gljOprObj = {
         var newval;
         if(updateField=='marketPrice'||updateField=='customQuantity'||updateField=='basePrice'){
             if(args.editingText==null){
-                newval="";
+                updateField=='marketPrice'||updateField=='customQuantity'?newval=0:newval="";
             }else {
                 var decimal = updateField=='customQuantity'?getDecimal("glj.quantity"):getDecimal("glj.unitPrice");
                 newval = number_util.checkNumberValue(args.editingText,decimal);
@@ -954,7 +954,7 @@ var gljOprObj = {
                     selected.data.adjustState=result.adjustState;
                     //project.ration_glj.datas = project.ration_glj.datas.concat(result.newRecodes);//显示和缓存统一,这样的话就不用更新两个位置了
                     project.ration_glj.datas = project.ration_glj.datas.concat(result.showData);
-                    gljOprObj.sheetData = gljOprObj.sheetData.concat(result.showData)
+                    gljOprObj.sheetData = gljOprObj.sheetData.concat(result.showData);
                     gljOprObj.showRationGLJSheetData();
                     project.projectGLJ.loadData();
                     projectObj.mainController.refreshTreeNode([selected]);
@@ -1053,7 +1053,6 @@ var gljOprObj = {
             nodes.push(node);
         }
     }
-
     projectObj.mainController.refreshTreeNode(nodes);
 
     },
@@ -1162,7 +1161,11 @@ var gljOprObj = {
             }
         };
         return new TreeNodeCellType()
+    },
+    marketPriceReadOnly:function(node){
+        return node.data.type==gljType.CONCRETE||node.data.type==gljType.MORTAR||node.data.type==gljType.MIX_RATIO||node.data.type==gljType.GENERAL_MACHINE||node.data.isEstimate==1
     }
+
 }
 
 $(function(){

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

@@ -116,6 +116,9 @@ let MainTreeCol = {
         },
         forQuantity:function (node) {
             return MainTreeCol.readOnly.glj(node)||MainTreeCol.readOnly.billsParent(node)
+        },
+        forMarketPrice:function (node) {
+            return MainTreeCol.readOnly.bills(node)||(MainTreeCol.readOnly.ration(node)&&node.data.type == rationType.ration)||gljOprObj.marketPriceReadOnly(node);
         }
     },
     cellType: {