فهرست منبع

工料机汇总与材料计算互动,处理单位kg-T 转换

zhangweicheng 5 سال پیش
والد
کامیت
9b3b4d2345

+ 17 - 2
modules/main/facade/ration_facade.js

@@ -1199,15 +1199,30 @@ async function CalculateQuantity (ration,billsItemID,projectID) {
     let decimalObject =await decimal_facade.getProjectDecimal(projectID,project);
     let quantity_decimal = (decimalObject&&decimalObject.ration&&decimalObject.ration.quantity)?decimalObject.ration.quantity:3;
     let pbill = await bill_model.model.findOne({projectID:projectID,ID:billsItemID});
+    let rationTimes = 1 ;//清单单位转定额单位的倍数,如 kg 转 t 时是1000
+    let t_unit = ration.unit?ration.unit:"";
+    let b_unit = pbill.unit?pbill.unit:"";
+    ration.quantityEXP="QDL";
+    if((/.*kg$/i).test(b_unit)){
+      if((/t/i).test(t_unit)) {
+        rationTimes = 1000;//如 kg 转 t 时是1000
+        ration.quantityEXP="QDL*0.001"
+      }
+      if((/10t/i).test(t_unit)){
+        rationTimes = 10000;//如 kg 转 10t 时是1000
+        ration.quantityEXP="QDL*0.0001"
+      } 
+    }
+    
    /* let  t_unit = ration.unit?ration.unit.replace(/^\d+/,""):""; 2019-02-01 养护去掉清单与定额单位的这个判断
     if(t_unit!=pbill.unit){//如果定额工程量的单位去除前面的数字后不等于清单单位,定额工程量保持不变
         return ;
     }*/
     let billsQuantity = pbill.quantity ? pbill.quantity : 0;
     let bill_decimal = await decimal_facade.getBillsQuantityDecimal(projectID,pbill.unit,project);
+    let ftimes = rationTimes == 1?FilterNumberFromUnit(ration.unit):rationTimes;
     billsQuantity=scMathUtil.roundForObj(billsQuantity,bill_decimal);
-    ration.quantityEXP="QDL";
-    ration.quantity = scMathUtil.roundForObj(billsQuantity / FilterNumberFromUnit(ration.unit),quantity_decimal);//不管是否打勾都做转换
+    ration.quantity = scMathUtil.roundForObj(billsQuantity / ftimes ,quantity_decimal);//不管是否打勾都做转换
     ration.contain =  scMathUtil.roundForObj(ration.quantity/billsQuantity,6);
 };
 

+ 5 - 0
public/web/gljUtil.js

@@ -511,6 +511,11 @@ let gljUtil = {
             }
         }
     },
+    isKGtoT:function(bills_unit,ration_unit){//是否由KG转成T,b_unit清单单位,t_unit定额单位
+      let t_unit = ration_unit?ration_unit:"";
+      let b_unit = bills_unit?bills_unit:"";
+      return (/.*kg$/i).test(b_unit) && (/.*t$/i).test(t_unit);
+    },
     fixedFlag : {
         // 分部分项工程
         SUB_ENGINERRING: 1,

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

@@ -747,7 +747,10 @@ var quantity_detail = {
                             if(isNaN(times)){
                                 times = 1;
                             }
-                            rationNode.updateData.quantity = scMathUtil.roundForObj(ration_value / times,getDecimal("quantity",rationNode));
+                            let unitTimes = 1;//清单单位转定额单位的倍数,如 kg 转 t 时是1000
+                            if(gljUtil.isKGtoT(node.data.unit,rationNode.data.unit)) unitTimes = 1000;
+
+                            rationNode.updateData.quantity = scMathUtil.roundForObj(ration_value / (times * unitTimes),getDecimal("quantity",rationNode));
                             rationNode.updateData.contain = value?scMathUtil.roundForObj(rationNode.updateData.quantity/value,getDecimal("process")):0;
                             rationNode.changed = true;
                             needUpdateChildren.push(rationNode);

+ 6 - 3
web/building_saas/main/js/models/ration.js

@@ -796,9 +796,12 @@ var Ration = {
             node.updateData.contain = contain;
             node.updateData.quantityEXP="QDL*"+contain;
             node.updateData.quantity=scMathUtil.roundForObj(billQuantity*contain,getDecimal("quantity",node));
-            let times = parseInt(node.data.unit);
-            if (!isNaN(times)) {
-                node.updateData.quantityEXP+='*'+times;
+            if(!gljUtil.isKGtoT(billNode.data.unit,node.data.unit)){
+              console.log('hehe')
+              let times = parseInt(node.data.unit);
+              if (!isNaN(times)) {
+                  node.updateData.quantityEXP+='*'+times;
+              }
             }
             //  node.data.quantity = projectObj.project.quantity_detail.autoTransformQuantity(node.data.quantity,node);//按单位做转换
             node.changed = true;

+ 6 - 1
web/building_saas/main/js/views/material_calc_view.js

@@ -231,8 +231,12 @@ materialCalcObj = {
         this.materialDatas = this.getMaterialCalcDatas();
         sheetCommonObj.showData(this.materialSheet, this.materialSetting,this.materialDatas);
         this.materialSheet.setRowCount(this.materialDatas.length);
-        sel.row = oldData?_.findIndex(this.materialDatas,{'id':oldData.id}):-1;
+        let pglj = projectGljObject.getProjectGLJSelected()
+        sel.row = pglj?_.findIndex(this.materialDatas,{'id':pglj.id}):-1;
+        if(sel.row == -1) sel.row = oldData?_.findIndex(this.materialDatas,{'id':oldData.id}):-1;
+      
         this.materialSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
+        this.materialSheet.showRow(sel.row==-1?0:sel.row, GC.Spread.Sheets.VerticalPosition.center);
     },
     showPriceDatas:function () {
         if(!$('#priceSheet').is(':visible')) return;
@@ -317,6 +321,7 @@ materialCalcObj = {
         if(newSel.row != oldSel.row){
             me.showPriceDatas();
             me.showFreightDatas();
+            projectGljObject.setSelectionWhenMaterialChange(me.getMaterialSelected())
         }
     },
     onFreightSelectionChange:function (sender,args) {

+ 20 - 4
web/building_saas/main/js/views/project_glj_view.js

@@ -377,8 +377,23 @@ projectGljObject={
         let dataCode = me.projectGljSetting.header[args.col].dataCode;
         if(dataCode=='name'&& recode && gljUtil.isMaterialType(recode.type)) projectObj.project.projectGLJ.updateCalcMaterial(recode,'calcMaterial',1);
     },
-    onProjectGljSelectionChange:function (sender, args) {
+    setSelectionWhenMaterialChange:function(material){
+      if(material){
+        let i = _.findIndex(this.projectGljSheetData,{id:material.id})
+        if(i != -1){
+          let os = this.projectGljSheet.getSelections();
+          let ns = [{col:os[0].col,colCount:1,row:i,rowCount:1}]
+          this.projectGljSheet.setSelection(ns[0].row,ns[0].col,ns[0].rowCount,ns[0].colCount);
+          this.projectGljSheet.showRow(i, GC.Spread.Sheets.VerticalPosition.center);
+          this.onProjectGljSelectionChange({},{newSelections:ns,oldSelections:os},true);
+        }
+
+
+      }
+    },
+    onProjectGljSelectionChange:function (sender, args,fromMaterial=false) {
         let me = projectGljObject;
+        console.log(args)
         let newSel = args.newSelections[0];
         let oldSel = args.oldSelections?args.oldSelections[0]:{};
         me.projectGljSheet.suspendPaint();
@@ -390,7 +405,7 @@ projectGljObject={
             if(me.projectGljSheetData[orow]){
               let tstyle = gljOprObj.getSelStyle(false,{},me.projectGljSheetData[orow].bgColour);
               me.projectGljSheet.setStyle(orow, -1, tstyle);
-              me.projectGljRowChang();
+              me.projectGljRowChang(fromMaterial);
             }
         }else{
           me.projectGljSheet.repaint();
@@ -398,7 +413,7 @@ projectGljObject={
         me.projectGljSheet.resumeEvent();
         me.projectGljSheet.resumePaint();
     },
-    projectGljRowChang:function(row){
+    projectGljRowChang:function(fromMaterial){
         let me = projectGljObject;
         let sel = me.mixRatioSheet.getSelections()[0];
         sel.row = -1;
@@ -406,6 +421,7 @@ projectGljObject={
         sel.rowCount = 1;
         sel.colCount = 1;
         me.showMixRatioData();
+        if(fromMaterial != true) materialCalcObj.showDatas();
     },
     rightClickCallback:function (row) {
         let me = projectGljObject;
@@ -622,7 +638,7 @@ projectGljObject={
         this.projectGljSheet.setRowCount(this.projectGljSheetData.length);
         sheetCommonObj.showData(this.projectGljSheet, this.projectGljSetting,this.projectGljSheetData);
         //this.projectGljSheet.setRowCount(this.projectGljSheetData.length);
-        sel.row = oldData?_.findIndex(this.projectGljSheetData,{'id':oldData.id}):'';
+        sel.row = oldData?_.findIndex(this.projectGljSheetData,{'id':oldData.id}):0;
         this.projectGljSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
     },
     showMaterialTreeData:function () {