Pārlūkot izejas kodu

暂估费计算不正确。

chenshilong 7 gadi atpakaļ
vecāks
revīzija
054feb114d

+ 29 - 9
web/building_saas/main/js/models/calc_program.js

@@ -115,6 +115,9 @@ let calcTools = {
     isNullBill: function (treeNode) {
         return this.isLeafBill(treeNode) && (treeNode.children.length === 0) && (!treeNode.data.calcBase);
     },
+    isCalcBaseBill: function(treeNode){
+        return this.isLeafBill(treeNode) && (treeNode.children.length === 0) && (treeNode.data.calcBase);
+    },
     isTotalCostBill: function (treeNode) {
         return treeNode.data.flagsIndex && treeNode.data.flagsIndex.fixed && treeNode.data.flagsIndex.fixed.flag &&
             treeNode.data.flagsIndex.fixed.flag == fixedFlag.ENGINEERINGCOST;
@@ -131,7 +134,19 @@ let calcTools = {
     isGljRation: function (treeNode) {
         return this.isRationCategory(treeNode) && treeNode.data.type === rationType.gljRation;
     },
-    getGLJList: function (treeNode) {
+    isInheritFrom: function (treeNode, flagsArr){
+        let cur = treeNode;
+        while (cur.parent) {
+            cur = cur.parent;
+        };
+
+        let flag = -1;
+        if (cur.data.flagsIndex && cur.data.flagsIndex.fixed && cur.data.flagsIndex.fixed.flag)
+            flag = cur.data.flagsIndex.fixed.flag;
+
+        return flagsArr.includes(flag);
+    },
+    getGLJList: function (treeNode, needOneBill) {
         delete treeNode.data.gljList;
         if (this.isRationCategory(treeNode)) {
             if (treeNode.data.type != rationType.volumePrice) {
@@ -143,7 +158,7 @@ let calcTools = {
             let q = nodeQ ? nodeQ : 1;
             let rNodes = projectObj.project.Ration.getRationNodes(treeNode);
             let rations = rNodes.map(function (node) {return node.data});
-            treeNode.data.gljList = projectObj.project.ration_glj.getGatherGljArrByRations(rations, q);
+            treeNode.data.gljList = projectObj.project.ration_glj.getGatherGljArrByRations(rations, needOneBill, q);
         };
     },
 
@@ -287,7 +302,7 @@ let calcTools = {
         let nodeQ = me.uiNodeQty(treeNode);
         let isGather = (projectObj.project.property.zanguCalcMode == zanguCalcType.gatherMaterial);
 
-        // 先汇总数量,再乘市场价
+        // 先汇总数量,再乘市场价。如果是叶子清单,进入这里的gljList中的材料,已经是同类材料跨定额汇总过的了。
         function eTFee(){
             if (!treeNode.data.gljList) return 0;
             let GLJObjs = [];
@@ -295,7 +310,8 @@ let calcTools = {
                 if (!allMaterialTypes.includes(glj.type)) continue;
                 if (glj.isEstimate){
                     GLJObjs.push({code: glj.code, name: glj.name, specs: glj.specs, unit: glj.unit, type: glj.type,
-                        quantity: (nodeQ * glj.quantity).toDecimal(decimalObj.process),
+                        // quantity: (nodeQ * glj.quantity).toDecimal(decimalObj.process),
+                        quantity: me.uiGLJQty((glj.totalQuantity)).toDecimal(decimalObj.process),
                         marketPrice: glj.marketPrice});
                 }
                 else{   // 组成物
@@ -305,8 +321,9 @@ let calcTools = {
                     for (let md of mds){
                         if (md.isEstimate){
                             let isExist = false;
-                            let totalQ = (nodeQ * me.uiGLJQty(glj.quantity)).toDecimal(decimalObj.glj.quantity);
-                            let mdQ = (totalQ * me.uiGLJQty(md.consumption)).toDecimal(decimalObj.process);
+                            // let totalQ = (nodeQ * me.uiGLJQty(glj.quantity)).toDecimal(decimalObj.glj.quantity);
+                            let totalQ = me.uiGLJQty((glj.totalQuantity)).toDecimal(decimalObj.glj.quantity);
+                             let mdQ = (totalQ * me.uiGLJQty(md.consumption)).toDecimal(decimalObj.process);
 
                             for (let obj of GLJObjs){
                                 if (gljOprObj.getIndex(md, gljKeyArray) == gljOprObj.getIndex(obj, gljKeyArray)){
@@ -1404,7 +1421,7 @@ class CalcProgram {
 
             let nodes = [];
             if (treeNode.calcType == treeNodeCalcType.ctGatherRationsFees){
-                calcTools.getGLJList(treeNode);
+                calcTools.getGLJList(treeNode, true);
                 nodes = me.project.Ration.getRationNodes(treeNode);
             }
             else nodes = treeNode.children;
@@ -1533,7 +1550,7 @@ class CalcProgram {
         // 定额或叶子清单自己的计算程序计算
         else{
             let fnArr = [];
-            calcTools.getGLJList(treeNode);
+            calcTools.getGLJList(treeNode, true);
 
             if (treeNode.calcType == treeNodeCalcType.ctRationCalcProgram) {
                 // 量价、工料机类型的定额要求市场合价
@@ -1580,8 +1597,11 @@ class CalcProgram {
             };
         };
 
-        if (!calcTools.isTotalCostBill(treeNode))  // 已在上面的分支中计算过
+        if (!calcTools.isTotalCostBill(treeNode)){   // 已在上面的分支中计算过
+            calcTools.getGLJList(treeNode, false);
             calcTools.estimateFee(treeNode);
+        }
+
         if (treeNode.changed && !changedArr.includes(treeNode)) changedArr.push(treeNode);
     };
 

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

@@ -128,9 +128,9 @@ const priceTypes = {
 const subSheetIndex = {
     ssiRationGLJ: 0,
     ssiRationCoe: 1,
-    ssiRationAssistant: 2,
+    // ssiRationAssistant: 2,
     ssiQuantityDetail: 3,
-    ssiCalcProgram: 4,
+    ssiCalcProgram: 2,
     ssiMemo: 5,
     ssiFeature: 6
 };

+ 2 - 2
web/building_saas/main/js/models/ration.js

@@ -143,8 +143,8 @@ var Ration = {
 
             function getSubBillsIDs(node) {
                 if (!node) return;
-                if (node.sourceType != sBills) return;
-                if (!node.children || node.children.length == 0 || node.children[0].sourceType != sBills)
+                if (node.sourceType != ModuleNames.bills) return;
+                if (!node.children || node.children.length == 0 || node.children[0].sourceType != ModuleNames.bills)
                     IDs.push(node.data.ID)
                 else
                     getSubBillsIDs(node.children[0]);

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

@@ -56,7 +56,7 @@ var ration_glj = {
             }
         };
 
-        ration_glj.prototype.getGatherGljArrByRations = function (rations, billQuantity) {
+        ration_glj.prototype.getGatherGljArrByRations = function (rations, needOneBill, billQuantity) {
             let result = [];
             let clone = function (obj) {
                 if (obj === null) return null;
@@ -89,6 +89,7 @@ var ration_glj = {
                             result.push(sameGlj);
                         } else {
                             sameGlj.quantity = sameGlj.quantity + (glj.quantity * ration.quantity).toDecimal(4);
+                            sameGlj.totalQuantity = (parseFloat(sameGlj.totalQuantity) + parseFloat(glj.totalQuantity)).toDecimal(4);
                         }
                     }
                 }
@@ -96,6 +97,8 @@ var ration_glj = {
 
             result = gljOprObj.combineWithProjectGlj(result);
 
+            if (!needOneBill) return result;
+
             // 上面取的是清单下所有工料机的总量,我要算清单单价,所以要取单位清单的工料机数量,所以下面要除以清单数量。
             let oneBill = JSON.parse(JSON.stringify(result));
 

+ 1 - 1
web/building_saas/main/js/views/main_tree_col.js

@@ -83,7 +83,7 @@ let MainTreeCol = {
             return node.data.subType != 201 && node.data.subType != 4 && node.data.subType != 5
         },
         commonUnitFee: function (node) {
-            return true;//!calcTools.isNullBill(node); 设置为只读,有新需求再修改
+            return !(calcTools.isLeafBill(node) && !calcTools.isCalcBaseBill(node) && !calcTools.isInheritFrom(node, [fixedFlag.SUB_ENGINERRING, fixedFlag.MEASURE]));
         },
         //根据节点、父节点类型判断是否可用计算基数
         calcBaseType: function (node) {

+ 2 - 2
web/building_saas/main/js/views/project_view.js

@@ -415,13 +415,13 @@ var projectObj = {
             else if(fieldName ==='contain'){//编辑含量
                 project.Ration.updateContain(value,node);
             }
-            else if (fieldName === 'quantity' || fieldName === 'marketUnitFee' || fieldName === 'programID' ||
+            else if (fieldName === 'quantity' || fieldName === 'marketUnitFee' || fieldName === 'commonUnitFee' || fieldName === 'programID' ||
                 fieldName === 'subType' || fieldName === 'calcBase' || fieldName === 'isSubcontract'){
                 if (fieldName === 'quantity') {
                     project.quantity_detail.editMainTreeNodeQuantity(value,node,fieldName,editingText);
                     return;
                 }
-                else if (fieldName === 'marketUnitFee') {
+                else if (fieldName === 'marketUnitFee' || fieldName === 'commonUnitFee' ) {
                     if (value) {value = parseFloat(value).toDecimal(decimalObj.decimal("unitPrice", node))};
                 }
                 else if (fieldName === 'calcBase') {