|  | @@ -261,9 +261,77 @@ let calcTools = {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return result;
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  | -    // 父清单暂估费的汇总计算走计算程序逻辑,不在这里。这里的小数取舍比较复杂,必须严格遵循需求,不能随意改动,否则计算结果会有误差:如差1分钱
 | 
	
		
			
				|  |  | +    // 父清单暂估费是汇总子清单的暂估费,走计算程序逻辑,不在这里
 | 
	
		
			
				|  |  |      estimateFee: function (treeNode, isBase = false){
 | 
	
		
			
				|  |  |          let me = this, sumU = 0, sumT = 0;
 | 
	
		
			
				|  |  | +        let nodeQ = me.uiNodeQty(treeNode);
 | 
	
		
			
				|  |  | +        // 先汇总数量,再乘市场价
 | 
	
		
			
				|  |  | +        function estimateTotalFee(){
 | 
	
		
			
				|  |  | +            let GLJObjs = [];
 | 
	
		
			
				|  |  | +            for (let glj of treeNode.data.gljList) {
 | 
	
		
			
				|  |  | +                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),
 | 
	
		
			
				|  |  | +                        marketPrice: glj.marketPrice});
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                else{   // 组成物
 | 
	
		
			
				|  |  | +                    if (!compositionTypes.includes(glj.type)) continue;
 | 
	
		
			
				|  |  | +                    let mds = projectObj.project.composition.getCompositionByGLJ(glj);
 | 
	
		
			
				|  |  | +                    if (!mds) mds = [];
 | 
	
		
			
				|  |  | +                    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);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                            for (let obj of GLJObjs){
 | 
	
		
			
				|  |  | +                                if (gljOprObj.getIndex(md, gljKeyArray) == gljOprObj.getIndex(obj, gljKeyArray)){
 | 
	
		
			
				|  |  | +                                    isExist = true;
 | 
	
		
			
				|  |  | +                                    obj.quantity = (obj.quantity + mdQ).toDecimal(decimalObj.glj.quantity);
 | 
	
		
			
				|  |  | +                                    break;
 | 
	
		
			
				|  |  | +                                }
 | 
	
		
			
				|  |  | +                            };
 | 
	
		
			
				|  |  | +                            if (!isExist)
 | 
	
		
			
				|  |  | +                                GLJObjs.push({code: md.code, name: md.name, specs: md.specs, unit: md.unit, type: md.type,
 | 
	
		
			
				|  |  | +                                    quantity: mdQ, marketPrice: md.marketPrice});
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            let rst = 0;
 | 
	
		
			
				|  |  | +            for (let obj of GLJObjs){
 | 
	
		
			
				|  |  | +                let tp = (me.uiGLJQty(obj.quantity) * me.uiGLJPrice(obj.marketPrice)).toDecimal(decimalObj.bills.totalPrice);
 | 
	
		
			
				|  |  | +                rst = (rst + tp).toDecimal(decimalObj.bills.totalPrice);
 | 
	
		
			
				|  |  | +            };
 | 
	
		
			
				|  |  | +            return rst;
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +        // 先数量乘市场价,再汇总
 | 
	
		
			
				|  |  | +        function estimateUnitFee(){
 | 
	
		
			
				|  |  | +            let rst = 0;
 | 
	
		
			
				|  |  | +            for (let glj of treeNode.data.gljList) {
 | 
	
		
			
				|  |  | +                if (!allMaterialTypes.includes(glj.type)) continue;
 | 
	
		
			
				|  |  | +                if (glj.isEstimate){
 | 
	
		
			
				|  |  | +                    rst = rst + (me.uiGLJQty(glj.quantity) * me.uiGLJPrice(glj.marketPrice)).toDecimal(decimalObj.process);
 | 
	
		
			
				|  |  | +                    rst = rst.toDecimal(decimalObj.process);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                else{   // 组成物
 | 
	
		
			
				|  |  | +                    if (!compositionTypes.includes(glj.type)) continue;
 | 
	
		
			
				|  |  | +                    let mds = projectObj.project.composition.getCompositionByGLJ(glj);
 | 
	
		
			
				|  |  | +                    if (!mds) mds = [];
 | 
	
		
			
				|  |  | +                    for (let md of mds){
 | 
	
		
			
				|  |  | +                        if (!md.isEstimate) continue;
 | 
	
		
			
				|  |  | +                        let mdU = (me.uiGLJQty(md.consumption) * me.uiGLJPrice(md.marketPrice)).toDecimal(decimalObj.glj.unitPrice);
 | 
	
		
			
				|  |  | +                        rst = rst + (mdU * me.uiGLJQty(glj.quantity)).toDecimal(decimalObj.process);
 | 
	
		
			
				|  |  | +                        rst = rst.toDecimal(decimalObj.process);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            };
 | 
	
		
			
				|  |  | +            rst = rst.toDecimal(decimalObj.bills.unitPrice);
 | 
	
		
			
				|  |  | +            return rst;
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          // 总造价暂估费
 | 
	
		
			
				|  |  |          if (me.isTotalCostBill(treeNode)){
 | 
	
		
			
				|  |  |              let nodes = projectObj.project.mainTree.roots;
 | 
	
	
		
			
				|  | @@ -283,76 +351,29 @@ let calcTools = {
 | 
	
		
			
				|  |  |              sumU = (sumU).toDecimal(decimalObj.bills.unitPrice);
 | 
	
		
			
				|  |  |              sumT = (sumT).toDecimal(decimalObj.bills.totalPrice);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        // 叶子清单、定额的暂估费
 | 
	
		
			
				|  |  |          else{
 | 
	
		
			
				|  |  |              if (!treeNode.data.gljList) return;
 | 
	
		
			
				|  |  | -            // 单价
 | 
	
		
			
				|  |  | -            for (let glj of treeNode.data.gljList) {
 | 
	
		
			
				|  |  | -                if (!allMaterialTypes.includes(glj.type)) continue;
 | 
	
		
			
				|  |  | -                if (glj.isEstimate){
 | 
	
		
			
				|  |  | -                    sumU = sumU + (me.uiGLJQty(glj.quantity) * me.uiGLJPrice(glj.marketPrice)).toDecimal(decimalObj.process);
 | 
	
		
			
				|  |  | -                    sumU = sumU.toDecimal(decimalObj.process);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                else{   // 组成物
 | 
	
		
			
				|  |  | -                    if (!compositionTypes.includes(glj.type)) continue;
 | 
	
		
			
				|  |  | -                    let mds = projectObj.project.composition.getCompositionByGLJ(glj);
 | 
	
		
			
				|  |  | -                    if (!mds) mds = [];
 | 
	
		
			
				|  |  | -                    for (let md of mds){
 | 
	
		
			
				|  |  | -                        if (!md.isEstimate) continue;
 | 
	
		
			
				|  |  | -                        let mdU = (me.uiGLJQty(md.consumption) * me.uiGLJPrice(md.marketPrice)).toDecimal(decimalObj.glj.unitPrice);
 | 
	
		
			
				|  |  | -                        sumU = sumU + (mdU * me.uiGLJQty(glj.quantity)).toDecimal(decimalObj.process);
 | 
	
		
			
				|  |  | -                        sumU = sumU.toDecimal(decimalObj.process);
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            };
 | 
	
		
			
				|  |  | -            sumU = sumU.toDecimal(decimalObj.bills.unitPrice);
 | 
	
		
			
				|  |  | -            if (isBase) return sumU;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            // 合价:数量要先累计,然后乘单价,最后汇总
 | 
	
		
			
				|  |  | -            let isGatherEstimate = (projectObj.project.property.zanguCalcMode == zanguCalcType.gatherMaterial);
 | 
	
		
			
				|  |  | -            if (isGatherEstimate){
 | 
	
		
			
				|  |  | -                let GLJObjs = [];
 | 
	
		
			
				|  |  | -                let rq = me.uiNodeQty(treeNode);
 | 
	
		
			
				|  |  | -                for (let glj of treeNode.data.gljList) {
 | 
	
		
			
				|  |  | -                    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: (rq * glj.quantity).toDecimal(decimalObj.process),
 | 
	
		
			
				|  |  | -                            marketPrice: glj.marketPrice});
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    else{   // 组成物
 | 
	
		
			
				|  |  | -                        if (!compositionTypes.includes(glj.type)) continue;
 | 
	
		
			
				|  |  | -                        let mds = projectObj.project.composition.getCompositionByGLJ(glj);
 | 
	
		
			
				|  |  | -                        if (!mds) mds = [];
 | 
	
		
			
				|  |  | -                        for (let md of mds){
 | 
	
		
			
				|  |  | -                            if (md.isEstimate){
 | 
	
		
			
				|  |  | -                                let isExist = false;
 | 
	
		
			
				|  |  | -                                let totalQ = (rq * me.uiGLJQty(glj.quantity)).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)){
 | 
	
		
			
				|  |  | -                                        isExist = true;
 | 
	
		
			
				|  |  | -                                        obj.quantity = (obj.quantity + mdQ).toDecimal(decimalObj.glj.quantity);
 | 
	
		
			
				|  |  | -                                        break;
 | 
	
		
			
				|  |  | -                                    }
 | 
	
		
			
				|  |  | -                                };
 | 
	
		
			
				|  |  | -                                if (!isExist)
 | 
	
		
			
				|  |  | -                                    GLJObjs.push({code: md.code, name: md.name, specs: md.specs, unit: md.unit, type: md.type,
 | 
	
		
			
				|  |  | -                                        quantity: mdQ, marketPrice: md.marketPrice});
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                };
 | 
	
		
			
				|  |  | +            let isGather = (projectObj.project.property.zanguCalcMode == zanguCalcType.gatherMaterial);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                for (let obj of GLJObjs){
 | 
	
		
			
				|  |  | -                    let t = (me.uiGLJQty(obj.quantity) * me.uiGLJPrice(obj.marketPrice)).toDecimal(decimalObj.bills.totalPrice);
 | 
	
		
			
				|  |  | -                    sumT = sumT + t;
 | 
	
		
			
				|  |  | -                    sumT = sumT.toDecimal(decimalObj.bills.totalPrice);
 | 
	
		
			
				|  |  | -                };
 | 
	
		
			
				|  |  | -                sumT = sumT.toDecimal(decimalObj.bills.totalPrice);
 | 
	
		
			
				|  |  | +            if (calcTools.isRationCategory(treeNode)){
 | 
	
		
			
				|  |  | +                sumU = estimateUnitFee();
 | 
	
		
			
				|  |  | +                if (isBase) return sumU;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                if (isGather)
 | 
	
		
			
				|  |  | +                    sumT = estimateTotalFee()
 | 
	
		
			
				|  |  | +                else
 | 
	
		
			
				|  |  | +                    sumT = (nodeQ * sumU).toDecimal(decimalObj.ration.totalPrice);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            else
 | 
	
		
			
				|  |  | -                sumT = (me.uiNodeQty(treeNode) * sumU).toDecimal(decimalObj.bills.totalPrice);
 | 
	
		
			
				|  |  | +            else if (calcTools.isBill(treeNode)){
 | 
	
		
			
				|  |  | +                if (isGather)
 | 
	
		
			
				|  |  | +                    sumT = estimateTotalFee()
 | 
	
		
			
				|  |  | +                else
 | 
	
		
			
				|  |  | +                    sumT = 0;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                let q = nodeQ ? nodeQ : 1;
 | 
	
		
			
				|  |  | +                sumU = (sumT / q).toDecimal(decimalObj.bills.totalPrice);
 | 
	
		
			
				|  |  | +            };
 | 
	
		
			
				|  |  |          };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          me.checkFeeField(treeNode, {'fieldName': 'estimate', 'unitFee': sumU, 'totalFee': sumT});
 |