|
@@ -507,7 +507,7 @@ let treeNodeTools = {
|
|
|
return treeNodeCalcType.ctRationCalcProgram;
|
|
|
}
|
|
|
else if (this.isNullBill(treeNode)){
|
|
|
- return treeNodeCalcType.ctCommonUnitFee;
|
|
|
+ return treeNodeCalcType.ctNull;
|
|
|
}
|
|
|
else if (this.isLeafBill(treeNode)) {
|
|
|
if (treeNode.children && treeNode.children.length > 0){
|
|
@@ -827,7 +827,6 @@ class CalcProgram {
|
|
|
for (let glj of treeNode.data.gljList) {
|
|
|
if (eTypes.indexOf(glj.type) >= 0) {
|
|
|
if (glj.isEstimate){
|
|
|
- 'code','name','specs','unit','type'
|
|
|
GLJObjs.push({code: glj.code, name: glj.name, specs: glj.specs, unit: glj.unit, type: glj.type,
|
|
|
quantity: glj.quantity, marketPrice: glj.marketPrice});
|
|
|
}
|
|
@@ -877,17 +876,29 @@ class CalcProgram {
|
|
|
};
|
|
|
|
|
|
// 删掉多余的费用。例如:从其它计算方式切换到公式计算方式,会多出其它的费(不光是common)
|
|
|
- function deleteUselessFees(treeNode){
|
|
|
- let reserveArr = treeNodeTools.isTotalCostBill(treeNode)? ['common', 'estimate']:['common'];
|
|
|
- if (treeNode.data.fees && treeNode.data.fees.length > 0){
|
|
|
- let feesArr = treeNode.data.fees;
|
|
|
- for (let i = 0; i < feesArr.length; i++) {
|
|
|
- if (!reserveArr.includes(feesArr[i].fieldName)) {
|
|
|
- delete treeNode.data.feesIndex[feesArr[i].fieldName];
|
|
|
- feesArr.splice(i, 1);
|
|
|
+ function deleteUselessFees(treeNode, fieldNameArr){
|
|
|
+ if (fieldNameArr){ // 用于计算程序没有绑定的费用类别,不要同步到清单,而清单因为以前计算过该类别又有值,需删除。如切换取费类别,旧费要清掉。
|
|
|
+ for (var i = 0; i < treeNode.data.fees.length; i++) {
|
|
|
+ let fee = treeNode.data.fees[i];
|
|
|
+ if (!fieldNameArr.includes(fee.fieldName)){
|
|
|
+ treeNode.data.fees.splice(i, 1);
|
|
|
+ delete treeNode.data.feesIndex[fee.fieldName];
|
|
|
treeNode.changed = true;
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
+ else{ // 总造价清单只留common, estimate两个费用类别。其它公式清单只留common。
|
|
|
+ let reserveArr = treeNodeTools.isTotalCostBill(treeNode)? ['common', 'estimate']:['common'];
|
|
|
+ if (treeNode.data.fees && treeNode.data.fees.length > 0){
|
|
|
+ let feesArr = treeNode.data.fees;
|
|
|
+ for (let i = 0; i < feesArr.length; i++) {
|
|
|
+ if (!reserveArr.includes(feesArr[i].fieldName)) {
|
|
|
+ delete treeNode.data.feesIndex[feesArr[i].fieldName];
|
|
|
+ feesArr.splice(i, 1);
|
|
|
+ treeNode.changed = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
};
|
|
|
};
|
|
|
|
|
@@ -964,22 +975,17 @@ class CalcProgram {
|
|
|
};
|
|
|
treeNode.data.calcTemplate = {"calcItems": rst};
|
|
|
}
|
|
|
- // 叶子清单的手工综合单价计算
|
|
|
- else if (treeNode.calcType == treeNodeCalcType.ctCommonUnitFee){
|
|
|
+ // 叶子清单无子结点、无公式计算(啥都没有时)
|
|
|
+ else if (treeNode.calcType == treeNodeCalcType.ctNull){
|
|
|
delete treeNode.data.gljList;
|
|
|
if (treeNode.data.calcBase) treeNode.data.calcBase = null; // 不能直接删除该属性,否则无法冲掉库中已存储的值
|
|
|
if (treeNode.data.calcBaseValue) treeNode.data.calcBaseValue = null; // 不能直接删除该属性,否则无法冲掉库中已存储的值
|
|
|
if (treeNode.data.programID) treeNode.data.programID = null;
|
|
|
-
|
|
|
- let uf = (treeNode.data.feesIndex && treeNode.data.feesIndex.common && treeNode.data.feesIndex.common.unitFee) ? treeNode.data.feesIndex.common.unitFee : 0;
|
|
|
- uf = uf.toDecimal(decimalObj.bills.unitPrice);
|
|
|
- let tuf = (treeNode.data.feesIndex && treeNode.data.feesIndex.common && treeNode.data.feesIndex.common.tenderUnitFee) ? treeNode.data.feesIndex.common.tenderUnitFee : 0;
|
|
|
- tuf = tuf.toDecimal(decimalObj.bills.unitPrice);
|
|
|
- let q = treeNode.data.quantity ? treeNode.data.quantity : 0;
|
|
|
- let tf = (uf * q).toDecimal(decimalObj.bills.totalPrice);
|
|
|
- let ttf = (tuf * q).toDecimal(decimalObj.bills.totalPrice);
|
|
|
- deleteUselessFees(treeNode);
|
|
|
- treeNodeTools.checkFeeField(treeNode, {'fieldName': 'common', 'unitFee': uf, 'totalFee': tf});
|
|
|
+ if (treeNode.data.fees && treeNode.data.fees.length > 0){
|
|
|
+ treeNode.data.fees = null;
|
|
|
+ treeNode.data.feesIndex = null;
|
|
|
+ treeNode.changed = true;
|
|
|
+ }
|
|
|
treeNode.data.calcTemplate = {"calcItems": []};
|
|
|
}
|
|
|
// 叶子清单公式计算
|
|
@@ -1015,6 +1021,7 @@ class CalcProgram {
|
|
|
}
|
|
|
// 定额或叶子清单自己的计算程序计算
|
|
|
else{
|
|
|
+ let fnArr = [];
|
|
|
if (treeNode.calcType == treeNodeCalcType.ctRationCalcProgram) {
|
|
|
if (treeNode.data.type == rationType.volumePrice){
|
|
|
delete treeNode.data.gljList;
|
|
@@ -1029,6 +1036,7 @@ class CalcProgram {
|
|
|
treeNode.data.gljList = me.project.ration_glj.getGljArrByRation(treeNode.data.ID);
|
|
|
// 计算程序里没有暂估费的计算规则,会漏掉,所以这里要专门算。
|
|
|
calcEstimateFee(treeNode);
|
|
|
+ fnArr.push('estimate');
|
|
|
};
|
|
|
|
|
|
if (treeNode.data.programID == undefined){
|
|
@@ -1045,6 +1053,7 @@ class CalcProgram {
|
|
|
|
|
|
// 叶子清单自己的计算程序计算,其暂估费也要汇总算。
|
|
|
calcEstimateFee(treeNode);
|
|
|
+ fnArr.push('estimate');
|
|
|
};
|
|
|
|
|
|
let template = me.compiledTemplates[treeNode.data.programID];
|
|
@@ -1071,8 +1080,12 @@ class CalcProgram {
|
|
|
else quantity = parseFloat(quantity).toDecimal(decimalObj.decimal('quantity', treeNode));
|
|
|
calcItem.totalFee = (calcItem.unitFee * quantity).toDecimal(decimalObj.decimal('totalPrice', treeNode));
|
|
|
|
|
|
- treeNodeTools.checkFeeField(treeNode, calcItem);
|
|
|
+ if (calcItem.fieldName) {
|
|
|
+ fnArr.push(calcItem.fieldName);
|
|
|
+ treeNodeTools.checkFeeField(treeNode, calcItem);
|
|
|
+ };
|
|
|
};
|
|
|
+ deleteUselessFees(treeNode, fnArr);
|
|
|
};
|
|
|
};
|
|
|
|