|
|
@@ -1620,6 +1620,9 @@ class CalcProgram {
|
|
|
};
|
|
|
};
|
|
|
|
|
|
+ /*删掉多余的费用。例如:从其它计算方式(有很多费)切换到公式计算方式(只需要common费),多出来的费要删除。
|
|
|
+ reserveArr 值取自:情况①遍历treeNode的计算规则,取有绑定的字段名。这些字段名以外的fee是因旧计算多出来的,需要删除。没有绑定的
|
|
|
+ 费用类别,不要同步到清单,也需要删除。*/
|
|
|
deleteUselessFees(treeNode, reserveArr){
|
|
|
treeNode.data.fees = _.filter(treeNode.data.fees, function (item) {
|
|
|
if(!reserveArr.includes(item.fieldName)){
|
|
|
@@ -1631,22 +1634,21 @@ class CalcProgram {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+ // 不能直接删除该属性,否则无法冲掉库中已存储的值。下同。
|
|
|
+ deleteProperties (treeNode, propNamesArr){
|
|
|
+ for (let pn of propNamesArr){
|
|
|
+ if (treeNode.data[pn]){
|
|
|
+ treeNode.data[pn] = null;
|
|
|
+ treeNode.changed = true;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ };
|
|
|
+
|
|
|
// 只计算treeNode自身。changedArr: 外部传来的一个数组,专门存储发生变动的节点。
|
|
|
innerCalc(treeNode, changedArr, tender){
|
|
|
if (treeNode.sourceType === ModuleNames.ration_glj) return; // 仅用作树节点显示的工料机不能参与计算。
|
|
|
|
|
|
- // 不能直接删除该属性,否则无法冲掉库中已存储的值。下同。
|
|
|
- function deleteProperties (treeNode, propNamesArr){
|
|
|
- for (let pn of propNamesArr){
|
|
|
- if (treeNode.data[pn]){
|
|
|
- treeNode.data[pn] = null;
|
|
|
- treeNode.changed = true;
|
|
|
- }
|
|
|
- };
|
|
|
- };
|
|
|
- /*删掉多余的费用。例如:从其它计算方式(有很多费)切换到公式计算方式(只需要common费),多出来的费要删除。
|
|
|
- reserveArr 值取自:情况①遍历treeNode的计算规则,取有绑定的字段名。这些字段名以外的fee是因旧计算多出来的,需要删除。没有绑定的
|
|
|
- 费用类别,不要同步到清单,也需要删除。*/
|
|
|
+
|
|
|
|
|
|
let me = this;
|
|
|
//设置定额工料机映射表
|
|
|
@@ -1667,7 +1669,7 @@ class CalcProgram {
|
|
|
// 叶子清单:公式计算
|
|
|
else if (treeNode.calcType == treeNodeCalcType.ctCalcBaseValue){
|
|
|
delete treeNode.data.gljList;
|
|
|
- deleteProperties(treeNode, ['programID']);
|
|
|
+ me.deleteProperties(treeNode, ['programID']);
|
|
|
me.deleteUselessFees(treeNode, ['common', 'rationCommon']);
|
|
|
let tf = treeNode.data.calcBaseValue ? treeNode.data.calcBaseValue : 0;
|
|
|
let ttf = treeNode.data.tenderCalcBaseValue ? treeNode.data.tenderCalcBaseValue : 0;
|
|
|
@@ -1694,46 +1696,9 @@ class CalcProgram {
|
|
|
// }
|
|
|
treeNode.data.calcTemplate = {"calcItems": []};
|
|
|
}
|
|
|
- // 叶子清单:无定额、无公式计算(什么都没有时),手工修改单价或金额。
|
|
|
- else if (treeNode.calcType == treeNodeCalcType.ctNull){
|
|
|
- delete treeNode.data.gljList;
|
|
|
- deleteProperties(treeNode, ['calcBase', 'calcBaseValue', 'tenderCalcBaseValue', 'programID']);
|
|
|
- me.deleteUselessFees(treeNode, ['common', 'rationCommon']);
|
|
|
-
|
|
|
- if (treeNode.data.feesIndex && treeNode.data.feesIndex.common){
|
|
|
- let uf, tf;
|
|
|
- let ftObj = {fieldName: 'common'};
|
|
|
-
|
|
|
- if (treeNode.data.calcFlag == treeNodeCalcFlag.customUnitPrice){ // 修改了清单单价:以单价为准,算金额
|
|
|
- uf = parseFloatPlus(treeNode.data.feesIndex.common.unitFee);
|
|
|
- tf = (uf * nQ).toDecimal(decimalObj.bills.totalPrice);
|
|
|
- }
|
|
|
- else if (treeNode.data.calcFlag == treeNodeCalcFlag.customTotalPrice){ // 修改了清单金额:以金额为准,算单价。修改了清单数量也一样
|
|
|
- tf = parseFloatPlus(treeNode.data.feesIndex.common.totalFee);
|
|
|
- uf = nQ ? (tf / nQ) : tf; // 如果工程量为0或空,综合单价直接等于综合合价
|
|
|
- uf = uf.toDecimal(decimalObj.bills.unitPrice);
|
|
|
- if (calcTools.isBillProject()) { // 招投标项目, 还要反算
|
|
|
- tf = (uf * nQ).toDecimal(decimalObj.bills.totalPrice);
|
|
|
- };
|
|
|
- };
|
|
|
-
|
|
|
- ftObj.unitFee = uf;
|
|
|
- ftObj.totalFee = tf;
|
|
|
- calcTools.checkFeeField(treeNode, ftObj);
|
|
|
-
|
|
|
- // 数量、金额时,同步定额建安费
|
|
|
- if (calcTools.isInheritFrom(treeNode, 1)){
|
|
|
- let ftObj2 = {
|
|
|
- fieldName: 'rationCommon',
|
|
|
- unitFee: uf,
|
|
|
- totalFee: tf
|
|
|
- };
|
|
|
- calcTools.checkFeeField(treeNode, ftObj2);
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
- treeNode.data.calcTemplate = {"calcItems": []};
|
|
|
- }
|
|
|
+ // 叶子清单:手工修改单价或金额。(无定额、无公式计算,什么都没有时)。
|
|
|
+ else if (treeNode.calcType == treeNodeCalcType.ctNull)
|
|
|
+ me.innerCalcBillCustom(treeNode)
|
|
|
// 定额:计算程序
|
|
|
else
|
|
|
me.innerCalcRation(treeNode, tender);
|
|
|
@@ -1882,6 +1847,47 @@ class CalcProgram {
|
|
|
treeNode.data.calcTemplate = {"calcItems": rst};
|
|
|
};
|
|
|
|
|
|
+ innerCalcBillCustom(treeNode){
|
|
|
+ let me = this;
|
|
|
+ delete treeNode.data.gljList;
|
|
|
+ me.deleteProperties(treeNode, ['calcBase', 'calcBaseValue', 'tenderCalcBaseValue', 'programID']);
|
|
|
+ me.deleteUselessFees(treeNode, ['common', 'rationCommon']);
|
|
|
+
|
|
|
+ if (treeNode.data.feesIndex && treeNode.data.feesIndex.common){
|
|
|
+ let uf, tf;
|
|
|
+ let ftObj = {fieldName: 'common'};
|
|
|
+ let nQ = calcTools.uiNodeQty(treeNode);
|
|
|
+ if (treeNode.data.calcFlag == treeNodeCalcFlag.customUnitPrice){ // 修改了清单单价:以单价为准,算金额
|
|
|
+ uf = parseFloatPlus(treeNode.data.feesIndex.common.unitFee);
|
|
|
+ tf = (uf * nQ).toDecimal(decimalObj.bills.totalPrice);
|
|
|
+ }
|
|
|
+ else if (treeNode.data.calcFlag == treeNodeCalcFlag.customTotalPrice){ // 修改了清单金额:以金额为准,算单价。修改了清单数量也一样
|
|
|
+ tf = parseFloatPlus(treeNode.data.feesIndex.common.totalFee);
|
|
|
+ uf = nQ ? (tf / nQ) : tf; // 如果工程量为0或空,综合单价直接等于综合合价
|
|
|
+ uf = uf.toDecimal(decimalObj.bills.unitPrice);
|
|
|
+ if (calcTools.isBillProject()) { // 招投标项目, 还要反算
|
|
|
+ tf = (uf * nQ).toDecimal(decimalObj.bills.totalPrice);
|
|
|
+ };
|
|
|
+ };
|
|
|
+
|
|
|
+ ftObj.unitFee = uf;
|
|
|
+ ftObj.totalFee = tf;
|
|
|
+ calcTools.checkFeeField(treeNode, ftObj);
|
|
|
+
|
|
|
+ // 数量、金额时,同步定额建安费
|
|
|
+ if (calcTools.isInheritFrom(treeNode, 1)){
|
|
|
+ let ftObj2 = {
|
|
|
+ fieldName: 'rationCommon',
|
|
|
+ unitFee: uf,
|
|
|
+ totalFee: tf
|
|
|
+ };
|
|
|
+ calcTools.checkFeeField(treeNode, ftObj2);
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ treeNode.data.calcTemplate = {"calcItems": []};
|
|
|
+ };
|
|
|
+
|
|
|
// 存储、刷新零散的多个结点。
|
|
|
saveNodes(treeNodes, callback){
|
|
|
if (treeNodes.length < 1) {
|