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

1.内蒙定额计算算法变更使用“临时材料费”
2.定额搜索,章节树定位跳转

zhongzewei 6 лет назад
Родитель
Сommit
e4bd5f6bc8

+ 3 - 1
web/maintain/ration_repository/js/section_tree.js

@@ -692,7 +692,9 @@ let sectionTreeObj = {
             if (!sectionNode) {
                 return;
             }
-            me.sheet.setActiveCell(sectionNode.serialNo(), 1);
+            let sectionRow = sectionNode.serialNo();
+            me.sheet.setActiveCell(sectionRow, 1);
+            me.sheet.showRow(sectionRow, GC.Spread.Sheets.VerticalPosition.top);
             let doAfterGetRation = function (rations) {
                 let findRation = _.find(rations, {code: rationCode}),
                     rIdx = rations.indexOf(findRation),

+ 87 - 64
web/over_write/js/neimenggu_2017.js

@@ -39,27 +39,39 @@ if(typeof materialComponent !== 'undefined'){
 //覆盖前端定额基价计算
 //基价=人工费+材料费+机械费+管理费利润
 //管理费利润=Round(人工费*(管理费消耗量+利润消耗量)%,2) 注:书中管理费、利润的单位都是“%”
+//材料费相关:应该是先算单位不是%的,算一个临时材料费,然后%的单个材料费算法是临时材料费*消耗量*0.01,然后最终的材料费是临时材料费+%的单个材料费
 if (typeof rationGLJOprObj !== 'undefined' && typeof rationGLJOprObj.rationCal !== 'undefined') {
     rationGLJOprObj.rationCal = function () {
         let me = rationGLJOprObj;
         let price = {gljType1: [], gljType2: [], gljType3: []},
+            // 临时材料费(非%单位的材料)
+            tempPrice = {gljType1: 0, gljType2: 0, gljType3: 0},
             rst = {labourPrice: 0, materialPrice: 0, machinePrice: 0},
             rationBasePrc = 0;
         let manageProfitConsume = 0;   //管理费、利润消耗量
         if(me.currentRationItem && me.cache['_GLJ_' + me.currentRationItem.ID]){
             let cacheArr = me.cache['_GLJ_' + me.currentRationItem.ID];
+            // 获取临时材料费
             cacheArr.forEach(function (gljData) {
-                if(gljData.gljType && gljData.consumeAmt){
+                if(gljData.gljType && gljData.consumeAmt && gljData.unit !== '%'){
                     let parentGLJType = parseInt(String(gljData.gljType)[0]);
                     if (parentGLJType <= 3) { // 人工、材料、机械
-                        // 单位为%,单条基价计算为定额价*消耗量*0.01
-                        if (gljData.unit === '%') {
-                            price['gljType' + parentGLJType].push(scMathUtil.roundTo(gljData.basePrice * gljData.consumeAmt * 0.01, -3));//取三位
-                        } else {
-                            price['gljType' + parentGLJType].push(scMathUtil.roundTo(gljData.basePrice * gljData.consumeAmt, -3));//取三位
-                        }
+                        let single = scMathUtil.roundTo(gljData.basePrice * gljData.consumeAmt, -3);
+                        tempPrice['gljType' + parentGLJType] = scMathUtil.roundTo(tempPrice['gljType' + parentGLJType] + single, me.processDecimal);
                     }
-                    if([6, 7].includes(gljData.gljType)){
+                }
+            });
+            // 临时材料费放入待汇总价格数组中
+            for (let attr in price) {
+                price[attr].push(tempPrice[attr])
+            }
+            cacheArr.forEach(function (gljData) {
+                if(gljData.gljType && gljData.consumeAmt){
+                    let parentGLJType = parseInt(String(gljData.gljType)[0]);
+                    if (parentGLJType <= 3 && gljData.unit === '%') { // 人工、材料、机械
+                        // %的单个材料费算法是临时材料费*消耗量*0.01
+                        price['gljType' + parentGLJType].push(scMathUtil.roundTo(tempPrice['gljType' + parentGLJType] * gljData.consumeAmt * 0.01, -3));//取三位
+                    } else if([6, 7].includes(gljData.gljType)){
                         manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljData.consumeAmt, -6);
                     }
                 }
@@ -100,65 +112,75 @@ if (typeof rationGLJOprObj !== 'undefined' && typeof rationGLJOprObj.rationCal !
     }
 }
 
-if (typeof module !== 'undefined') {
-    module.exports = {
-        // 计算定额基价
-        calcRation: function (gljArr, scMathUtil) {
-            let labourPrc = [],
-                materialPrc = [],
-                machinePrc = [],
-                manageProfitConsume = 0,
-                singlePrc,
-                updatePrc = {labourPrice: 0, materialPrice: 0, machinePrice: 0, manageProfitPrice: 0, basePrice: 0};
-            gljArr.forEach(function (gljItem) {
-                if(gljItem.gljParentType !== -1){
-                    if (gljItem.gljParentType <= 3 && gljItem.unit === '%') {
-                        singlePrc = scMathUtil.roundTo(gljItem.basePrice * gljItem.consumeAmt * 0.01, -3);
-                    } else {
-                        singlePrc = scMathUtil.roundTo(gljItem.basePrice * gljItem.consumeAmt, -3);
-                    }
-                    if(gljItem.gljParentType === 1){
-                        labourPrc.push(singlePrc);
-                    } else if(gljItem.gljParentType ===2){
-                        materialPrc.push(singlePrc);
-                    } else if(gljItem.gljParentType === 3){
-                        machinePrc.push(singlePrc);
-                    } else if(gljItem.gljParentType === 6){
-                        manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljItem.consumeAmt, -6);
-                    } else if(gljItem.gljParentType === 7){
-                        manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljItem.consumeAmt, -6);
-                    }
-                }
-            });
-            if(labourPrc.length > 0){
-                let sumLaP = 0;
-                for(let i=0; i<labourPrc.length; i++){
-                    sumLaP = scMathUtil.roundTo(sumLaP + labourPrc[i], -6);
-                }
-                updatePrc.labourPrice = scMathUtil.roundTo(sumLaP, -2);
-                updatePrc.manageProfitPrice = scMathUtil.roundTo(updatePrc.labourPrice * manageProfitConsume * 0.01, -2);
-                updatePrc.basePrice = scMathUtil.roundTo(updatePrc.labourPrice + updatePrc.manageProfitPrice, -2);
-            }
-            if(materialPrc.length > 0){
-                let sumMtP = 0;
-                for(let i= 0; i<materialPrc.length; i++){
-                    sumMtP = scMathUtil.roundTo(sumMtP + materialPrc[i], -6);
-                }
-                updatePrc.materialPrice = scMathUtil.roundTo(sumMtP, -2);
-                updatePrc.basePrice = scMathUtil.roundTo(updatePrc.basePrice + updatePrc.materialPrice, -2);
+// 后端用 计算定额基价
+function calcRation(gljArr, scMathUtil) {
+    let labourPrc = [],
+        materialPrc = [],
+        machinePrc = [],
+        manageProfitConsume = 0,
+        updatePrc = {labourPrice: 0, materialPrice: 0, machinePrice: 0, manageProfitPrice: 0, basePrice: 0};
+    // 临时材料费
+    let tempPrice = {gljType1: 0, gljType2: 0, gljType3: 0};
+    gljArr.forEach(function (gljItem) {
+        if (gljItem.gljParentType !== -1 &&
+            gljItem.gljParentType <= 3 &&
+            gljItem.unit !== '%') {
+            let single = scMathUtil.roundTo(gljItem.basePrice * gljItem.consumeAmt, -3);
+            tempPrice['gljType' + gljItem.gljParentType] = scMathUtil.roundTo(tempPrice['gljType' + gljItem.gljParentType] + single, -6);
+        }
+    });
+    labourPrc.push(tempPrice.gljType1);
+    materialPrc.push(tempPrice.gljType2);
+    machinePrc.push(tempPrice.gljType3);
+    gljArr.forEach(function (gljItem) {
+        let singlePrc = 0;
+        if(gljItem.gljParentType !== -1){
+            if (gljItem.gljParentType <= 3 && gljItem.unit === '%') {
+                singlePrc = scMathUtil.roundTo(tempPrice['gljType' + gljItem.gljParentType] * gljItem.consumeAmt * 0.01, -3);
+            } else if (gljItem.gljParentType > 3) {
+                singlePrc = scMathUtil.roundTo(gljItem.basePrice * gljItem.consumeAmt, -3);
             }
-            if(machinePrc.length > 0){
-                let sumMaP = 0;
-                for(let i =0; i< machinePrc.length; i++){
-                    sumMaP = scMathUtil.roundTo(sumMaP + machinePrc[i], -6);
-                }
-                updatePrc.machinePrice = scMathUtil.roundTo(sumMaP, -2);
-                updatePrc.basePrice = scMathUtil.roundTo(updatePrc.basePrice + updatePrc.machinePrice, -2);
+            if(gljItem.gljParentType === 1){
+                labourPrc.push(singlePrc);
+            } else if(gljItem.gljParentType ===2){
+                materialPrc.push(singlePrc);
+            } else if(gljItem.gljParentType === 3){
+                machinePrc.push(singlePrc);
+            } else if(gljItem.gljParentType === 6){
+                manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljItem.consumeAmt, -6);
+            } else if(gljItem.gljParentType === 7){
+                manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljItem.consumeAmt, -6);
             }
-            return updatePrc;
         }
-    };
+    });
+    if(labourPrc.length > 0){
+        let sumLaP = 0;
+        for(let i=0; i<labourPrc.length; i++){
+            sumLaP = scMathUtil.roundTo(sumLaP + labourPrc[i], -6);
+        }
+        updatePrc.labourPrice = scMathUtil.roundTo(sumLaP, -2);
+        updatePrc.manageProfitPrice = scMathUtil.roundTo(updatePrc.labourPrice * manageProfitConsume * 0.01, -2);
+        updatePrc.basePrice = scMathUtil.roundTo(updatePrc.labourPrice + updatePrc.manageProfitPrice, -2);
+    }
+    if(materialPrc.length > 0){
+        let sumMtP = 0;
+        for(let i= 0; i<materialPrc.length; i++){
+            sumMtP = scMathUtil.roundTo(sumMtP + materialPrc[i], -6);
+        }
+        updatePrc.materialPrice = scMathUtil.roundTo(sumMtP, -2);
+        updatePrc.basePrice = scMathUtil.roundTo(updatePrc.basePrice + updatePrc.materialPrice, -2);
+    }
+    if(machinePrc.length > 0){
+        let sumMaP = 0;
+        for(let i =0; i< machinePrc.length; i++){
+            sumMaP = scMathUtil.roundTo(sumMaP + machinePrc[i], -6);
+        }
+        updatePrc.machinePrice = scMathUtil.roundTo(sumMaP, -2);
+        updatePrc.basePrice = scMathUtil.roundTo(updatePrc.basePrice + updatePrc.machinePrice, -2);
+    }
+    return updatePrc;
 }
+
 //计税方式
 const taxModel = {'common': 1, 'simple': 2};
 //价格属性:计税方式
@@ -206,6 +228,7 @@ const consumeAmtPropertiesTemplate = [
 if(typeof module !== 'undefined'){
     module.exports = {
         pricePropertiesTemplate: pricePropertiesTemplate,
-        consumeAmtPropertiesTemplate: consumeAmtPropertiesTemplate
+        consumeAmtPropertiesTemplate: consumeAmtPropertiesTemplate,
+        calcRation: calcRation
     };
 }