Browse Source

bug fixed

zhangweicheng 7 years ago
parent
commit
9d2bedf091

+ 11 - 8
modules/ration_glj/facade/glj_calculate_facade.js

@@ -11,6 +11,7 @@ let ration_coe = mongoose.model('ration_coe');
 let std_ration_lib_ration_items = mongoose.model('std_ration_lib_ration_items');
 let glj_type_util = require('../../../public/cache/std_glj_type_util');
 const scMathUtil = require('../../../public/scMathUtil').getUtil();
+let decimal_facade = require('../../main/facade/decimal_facade');
 
 module.exports={
     calculateQuantity:calculateQuantity,
@@ -86,7 +87,9 @@ function generateUpdateTasks(result) {
 
 
 async function calculateQuantityPerGLJ(glj,index,coeList,assList,adjustState,noNeedCal) {
-    let quantity =  scMathUtil.roundTo(parseFloat(glj.quantity),-6);
+    let decimalObject =await decimal_facade.getProjectDecimal(glj.projectID);
+    let decimal = (decimalObject&&decimalObject.glj&&decimalObject.glj.quantity)?decimalObject.glj.quantity:3;
+    let quantity =  scMathUtil.roundTo(parseFloat(glj.quantity),-decimal);
     let result={
         query:{
             ID:glj.ID,
@@ -99,7 +102,7 @@ async function calculateQuantityPerGLJ(glj,index,coeList,assList,adjustState,noN
     try {
         if(noNeedCal==null){
             if(!glj._doc.hasOwnProperty('customQuantity')||glj.customQuantity==null){
-                quantity =scMathUtil.roundTo(parseFloat(glj.rationItemQuantity),-6);
+                quantity =scMathUtil.roundTo(parseFloat(glj.rationItemQuantity),-decimal);
                 quantity =calculateAss(quantity,assList,glj);
                 quantity = calculateQuantityByCoes(quantity,coeList,glj);
             }else {
@@ -110,9 +113,9 @@ async function calculateQuantityPerGLJ(glj,index,coeList,assList,adjustState,noN
             if(customerCoe.isAdjust==1){
                 quantity = calculateQuantityByCustomerCoes(quantity,customerCoe,glj);
             }
-            result.doc.quantity =_.round(quantity,3);
+            result.doc.quantity =scMathUtil.roundToString(quantity,decimal);
         }
-        generateAdjustState(glj,coeList,adjustState,index);
+        generateAdjustState(glj,coeList,adjustState,index,result.doc.quantity);
         return result;
     }catch (err){
         throw err;
@@ -134,12 +137,12 @@ function calculateAss(quantity,assList,glj) {
     return scMathUtil.roundTo(quantity,-6);
 }
 
-function generateAdjustState(glj,coeList,adjustState,index) {
+function generateAdjustState(glj,coeList,adjustState,index,quantity) {
    //替换工料机 and 添加工料机
     if(glj._doc.createType=='replace'){
         adjustState.push({index:stateSeq.replase,content:glj.rcode+'换'+glj.code});
     }else if(glj._doc.createType=='add'){
-        adjustState.push({index:stateSeq.add,content:'添'+glj.code+'量'+glj.quantity});
+        adjustState.push({index:stateSeq.add,content:'添'+glj.code+'量'+parseFloat(quantity)});
     }
     // to do
 
@@ -158,8 +161,8 @@ function generateAdjustState(glj,coeList,adjustState,index) {
 
     //自定义消耗量
     if(glj._doc.createType!='add'&&glj._doc.hasOwnProperty('customQuantity')){
-        if(glj.customQuantity!==null){
-            adjustState.push({index:stateSeq.cusQuantity,content:glj.code+'量'+glj.customQuantity});
+        if(glj.customQuantity!==null&&glj.customQuantity!=""){
+            adjustState.push({index:stateSeq.cusQuantity,content:glj.code+'量'+parseFloat(glj.customQuantity)});
         }
     }
     //市场单价调整

+ 1 - 1
web/building_saas/css/main.css

@@ -318,5 +318,5 @@ body {
   pointer-events:none
 }
 .text-green{
-    color:#00FF00
+    color: #172a30
 }

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

@@ -471,7 +471,6 @@ var quantity_detail = {
             sheetCommonObj.showData(gljOprObj.detailSheet,gljOprObj.detailSetting,[]);
 
         };
-
         quantity_detail.prototype.quantityEditChecking = function(value,node,fieldName){
             var validate = true;
             if(fieldName=='quantity'){
@@ -486,6 +485,17 @@ var quantity_detail = {
             }
             return validate;
         };
+        quantity_detail.prototype.autoTransformQuantity = function(value,node){
+            let data = node.data;
+            if(node.sourceType === project.Ration.getSourceType()&&data.unit) {
+                let times = parseInt(data.unit);
+                if (isNaN(times)) {
+                    times = 1
+                }
+                value = value / times;
+            }
+            return value;
+        };
         quantity_detail.prototype.getDecimal=function (node) {
             var decimal = 3;
             if(node.sourceType === project.Bills.getSourceType()){

+ 5 - 1
web/building_saas/main/js/views/project_view.js

@@ -276,7 +276,10 @@ var projectObj = {
             else if (fieldName === 'quantity' || fieldName === 'marketUnitFee' || fieldName === 'programID' ||
                 fieldName === 'subType' || fieldName === 'calcBase' || fieldName === 'feesIndex.common.unitFee'){
                 if (fieldName === 'quantity') {
-                   if (value) {value = value.toDecimal(decimalObj.decimal(fieldName,node))};
+                   if (value) {
+                       value = project.quantity_detail.autoTransformQuantity(value,node);
+                       value = value.toDecimal(decimalObj.decimal(fieldName,node))
+                   };
                    if(project.quantity_detail.quantityEditChecking(value,node,fieldName)){
                        node.data.isFromDetail=0;
                        project.quantity_detail.cleanQuantityDetail(node,true);
@@ -555,6 +558,7 @@ var projectObj = {
             col = parseInt(col);
             const sheet = this.mainSpread.getActiveSheet();
             sheet.setSelection(row, col, 1, 1);
+            this.mainController.setTreeSelected(this.mainController.tree.items[row]);//触发树节点选中事件
         }
     },
 };