|
@@ -118,24 +118,33 @@ const cpFeeTypes = [
|
|
|
{type: 'fee1', name: '甲供材料费'},
|
|
|
{type: 'common', name: '工程造价'}
|
|
|
];
|
|
|
-
|
|
|
function getRationBaseFee(treeNode, gljTypes, priceType){
|
|
|
if (!treeNode.data.gljList) return 0;
|
|
|
+ function uiGLJPrice(price){
|
|
|
+ if (price)
|
|
|
+ return parseFloat(price).toDecimal(decimalObj.glj.unitPrice)
|
|
|
+ else return 0;
|
|
|
+ };
|
|
|
+ function uiGLJQuantity(quantity){
|
|
|
+ if (quantity)
|
|
|
+ return parseFloat(quantity).toDecimal(decimalObj.glj.quantity)
|
|
|
+ else return 0;
|
|
|
+ };
|
|
|
let result = 0;
|
|
|
for (let glj of treeNode.data.gljList) {
|
|
|
let price = 0, temp = 0;
|
|
|
if (gljTypes.indexOf(glj.type) >= 0) {
|
|
|
if (priceType == priceTypes.ptDiffPrice){
|
|
|
- let aprice = glj["adjustPrice"] ? parseFloat(glj["adjustPrice"]) : 0;
|
|
|
- let mprice = glj["marketPrice"] ? parseFloat(glj["marketPrice"]) : 0;
|
|
|
- temp = (glj["quantity"] * mprice).toDecimal(decimalObj.ration.unitPrice) - (glj["quantity"] * aprice).toDecimal(decimalObj.ration.unitPrice);
|
|
|
+ let aprice = uiGLJPrice(glj["adjustPrice"]);
|
|
|
+ let mprice = uiGLJPrice(glj["marketPrice"]);
|
|
|
+ temp = (uiGLJQuantity(glj["quantity"]) * mprice).toDecimal(decimalObj.ration.unitPrice) - (uiGLJQuantity(glj["quantity"]) * aprice).toDecimal(decimalObj.ration.unitPrice);
|
|
|
temp = temp.toDecimal(decimalObj.ration.unitPrice);
|
|
|
}
|
|
|
else {
|
|
|
- if (priceType == priceTypes.ptBasePrice){ price = parseFloat(glj["basePrice"]);}
|
|
|
- else if (priceType == priceTypes.ptAdjustPrice){price = parseFloat(glj["adjustPrice"]);}
|
|
|
- else if (priceType == priceTypes.ptMarketPrice){price = parseFloat(glj["marketPrice"]);}
|
|
|
- temp = (glj["quantity"] * price).toDecimal(decimalObj.ration.unitPrice);
|
|
|
+ if (priceType == priceTypes.ptBasePrice){ price = uiGLJPrice(glj["basePrice"]);}
|
|
|
+ else if (priceType == priceTypes.ptAdjustPrice){price = uiGLJPrice(glj["adjustPrice"]);}
|
|
|
+ else if (priceType == priceTypes.ptMarketPrice){price = uiGLJPrice(glj["marketPrice"]);}
|
|
|
+ temp = (uiGLJQuantity(glj["quantity"]) * price).toDecimal(decimalObj.ration.unitPrice);
|
|
|
};
|
|
|
|
|
|
result = (result + temp).toDecimal(decimalObj.ration.unitPrice);
|
|
@@ -144,7 +153,6 @@ function getRationBaseFee(treeNode, gljTypes, priceType){
|
|
|
return result;
|
|
|
};
|
|
|
|
|
|
-// 定额计算基数。CSL, 2018-01-23
|
|
|
const rationCalcBaser = {
|
|
|
'定额基价人工费':
|
|
|
function (node) {
|
|
@@ -203,6 +211,139 @@ const rationCalcBaser = {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+let nodeTools = {
|
|
|
+ isBill: function(treeNode){
|
|
|
+ return treeNode.sourceType === ModuleNames.bills;
|
|
|
+ },
|
|
|
+ isLeafBill: function(treeNode){
|
|
|
+ return treeNode.sourceType === ModuleNames.bills &&
|
|
|
+ treeNode.source.children &&
|
|
|
+ treeNode.source.children.length === 0;
|
|
|
+ },
|
|
|
+ isNullBill: 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;
|
|
|
+ },
|
|
|
+
|
|
|
+ isRationCategory: function(treeNode){
|
|
|
+ return treeNode.sourceType === ModuleNames.ration;
|
|
|
+ },
|
|
|
+ isRation: function(treeNode){
|
|
|
+ return treeNode.sourceType === ModuleNames.ration && treeNode.data.type === rationType.ration;
|
|
|
+ },
|
|
|
+ isVolumePrice: function (treeNode) {
|
|
|
+ return treeNode.sourceType === ModuleNames.ration && treeNode.data.type === rationType.volumePrice;
|
|
|
+ },
|
|
|
+ isGljRation: function (treeNode) {
|
|
|
+ return treeNode.sourceType === ModuleNames.ration && treeNode.data.type === rationType.gljRation;
|
|
|
+ },
|
|
|
+
|
|
|
+ initFees(treeNode){
|
|
|
+ if (!treeNode.data.fees) {
|
|
|
+ treeNode.data.fees = [];
|
|
|
+ treeNode.data.feesIndex = {};
|
|
|
+ treeNode.changed = true;
|
|
|
+ };
|
|
|
+ },
|
|
|
+ initFeeField(treeNode, fieldName){
|
|
|
+ this.initFees(treeNode);
|
|
|
+ if (!treeNode.data.feesIndex[fieldName]) {
|
|
|
+ let fee = {
|
|
|
+ 'fieldName': fieldName,
|
|
|
+ 'unitFee': 0,
|
|
|
+ 'totalFee': 0,
|
|
|
+ 'tenderUnitFee': 0,
|
|
|
+ 'tenderTotalFee': 0
|
|
|
+ };
|
|
|
+ treeNode.data.fees.push(fee);
|
|
|
+ treeNode.data.feesIndex[fieldName] = fee;
|
|
|
+ treeNode.changed = true;
|
|
|
+ };
|
|
|
+ },
|
|
|
+ checkFeeField(treeNode, feeObj){
|
|
|
+ if (!feeObj) return;
|
|
|
+ if (feeObj.fieldName == '') return;
|
|
|
+
|
|
|
+ // 初始化前先拦截末定义的情况
|
|
|
+ if (!treeNode.data.feesIndex || !treeNode.data.feesIndex[feeObj.fieldName]){
|
|
|
+ if (feeObj.unitFee == 0 && feeObj.totalFee == 0) return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.initFeeField(treeNode, feeObj.fieldName);
|
|
|
+
|
|
|
+ if (treeNode.data.feesIndex[feeObj.fieldName].unitFee != feeObj.unitFee){
|
|
|
+ treeNode.data.feesIndex[feeObj.fieldName].unitFee = feeObj.unitFee;
|
|
|
+ treeNode.changed = true;
|
|
|
+ };
|
|
|
+
|
|
|
+ if (treeNode.data.feesIndex[feeObj.fieldName].totalFee != feeObj.totalFee){
|
|
|
+ treeNode.data.feesIndex[feeObj.fieldName].totalFee = feeObj.totalFee;
|
|
|
+ treeNode.changed = true;
|
|
|
+ };
|
|
|
+ },
|
|
|
+ initSummaryFee(treeNode){
|
|
|
+ if (!treeNode.data.summaryFees){
|
|
|
+ treeNode.data.summaryFees = {
|
|
|
+ totalFee: 0,
|
|
|
+ estimateFee: 0,
|
|
|
+ safetyFee: 0,
|
|
|
+ chargeFee: 0
|
|
|
+ };
|
|
|
+ treeNode.changed = true;
|
|
|
+ };
|
|
|
+ },
|
|
|
+ getCalcType(treeNode) {
|
|
|
+ if (this.isRationCategory(treeNode)){
|
|
|
+ return treeNodeCalcType.ctRationCalcProgram;
|
|
|
+ }
|
|
|
+ else if (this.isNullBill(treeNode)){
|
|
|
+ return treeNodeCalcType.ctNull;
|
|
|
+ }
|
|
|
+ else if (this.isLeafBill(treeNode)) {
|
|
|
+ if (treeNode.children && treeNode.children.length > 0){
|
|
|
+ // 清单单价计算模式下的叶子清单:取自己的计算程序ID,找到自己的计算程序计算。(汇总清单所有定额的工料机)
|
|
|
+ if (projectObj.project.property.billsCalcMode === leafBillGetFeeType.billsPrice)
|
|
|
+ return treeNodeCalcType.ctBillCalcProgram;
|
|
|
+ else // 前三种计算模式下的叶子清单:汇总定额的计算程序的费用类别
|
|
|
+ return treeNodeCalcType.ctGatherRationsFees;
|
|
|
+ }
|
|
|
+ else{ // 公式计算
|
|
|
+ return treeNodeCalcType.ctCalcBaseValue;
|
|
|
+ };
|
|
|
+ }
|
|
|
+ else if (this.isBill(treeNode)) { // 父清单:汇总子清单的费用类别
|
|
|
+ return treeNodeCalcType.ctGatherBillsFees;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return treeNodeCalcType.ctRationCalcProgram;
|
|
|
+ };
|
|
|
+ },
|
|
|
+ uiQuantity(treeNode){
|
|
|
+ return parseFloatPlus(treeNode.data.quantity).toDecimal(decimalObj.decimal("quantity", treeNode));
|
|
|
+ },
|
|
|
+
|
|
|
+ getFee(treeNode, fieldName) { // fieldName: 'common.totalFee'、'equipment.unitFee'
|
|
|
+ let ns = fieldName.split(".");
|
|
|
+ if (ns.length != 2)
|
|
|
+ return 0
|
|
|
+ else if (treeNode.data.feesIndex[ns[0]] && treeNode.data.feesIndex[ns[0]][ns[1]])
|
|
|
+ return parseFloat(treeNode.data.feesIndex[ns[0]][ns[1]])
|
|
|
+ else
|
|
|
+ return 0;
|
|
|
+ },
|
|
|
+ getNodeByFlag(flag) {
|
|
|
+ let bill = cbTools.findBill(flag);
|
|
|
+ if (bill) return this.getNodeByID(bill.ID)
|
|
|
+ else return null;
|
|
|
+ },
|
|
|
+ getNodeByID(ID){
|
|
|
+ return cbTools.getNodeByID(ID);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
let analyzer = {
|
|
|
calcTemplate: null,
|
|
|
success: true,
|
|
@@ -364,7 +505,7 @@ let executeObj = {
|
|
|
( me.treeNode.data.subType === gljType.GENERAL_MACHINE && baseName === '定额基价机械费') ||
|
|
|
( me.treeNode.data.subType === gljType.MAIN_MATERIAL && baseName === '主材费') ||
|
|
|
( me.treeNode.data.subType === gljType.EQUIPMENT && baseName === '设备费')
|
|
|
- ) result = me.treeNode.data.marketUnitFee ? me.treeNode.data.marketUnitFee : 0;
|
|
|
+ ) result = me.treeNode.data.marketUnitFee ? parseFloat(me.treeNode.data.marketUnitFee).toDecimal(decimalObj.ration.unitPrice) : 0;
|
|
|
return result;
|
|
|
};
|
|
|
|
|
@@ -383,139 +524,6 @@ let executeObj = {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-let nodeTools = {
|
|
|
- isBill: function(treeNode){
|
|
|
- return treeNode.sourceType === ModuleNames.bills;
|
|
|
- },
|
|
|
- isLeafBill: function(treeNode){
|
|
|
- return treeNode.sourceType === ModuleNames.bills &&
|
|
|
- treeNode.source.children &&
|
|
|
- treeNode.source.children.length === 0;
|
|
|
- },
|
|
|
- isNullBill: 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;
|
|
|
- },
|
|
|
-
|
|
|
- isRationCategory: function(treeNode){
|
|
|
- return treeNode.sourceType === ModuleNames.ration;
|
|
|
- },
|
|
|
- isRation: function(treeNode){
|
|
|
- return treeNode.sourceType === ModuleNames.ration && treeNode.data.type === rationType.ration;
|
|
|
- },
|
|
|
- isVolumePrice: function (treeNode) {
|
|
|
- return treeNode.sourceType === ModuleNames.ration && treeNode.data.type === rationType.volumePrice;
|
|
|
- },
|
|
|
- isGljRation: function (treeNode) {
|
|
|
- return treeNode.sourceType === ModuleNames.ration && treeNode.data.type === rationType.gljRation;
|
|
|
- },
|
|
|
-
|
|
|
- initFees(treeNode){
|
|
|
- if (!treeNode.data.fees) {
|
|
|
- treeNode.data.fees = [];
|
|
|
- treeNode.data.feesIndex = {};
|
|
|
- treeNode.changed = true;
|
|
|
- };
|
|
|
- },
|
|
|
- initFeeField(treeNode, fieldName){
|
|
|
- this.initFees(treeNode);
|
|
|
- if (!treeNode.data.feesIndex[fieldName]) {
|
|
|
- let fee = {
|
|
|
- 'fieldName': fieldName,
|
|
|
- 'unitFee': 0,
|
|
|
- 'totalFee': 0,
|
|
|
- 'tenderUnitFee': 0,
|
|
|
- 'tenderTotalFee': 0
|
|
|
- };
|
|
|
- treeNode.data.fees.push(fee);
|
|
|
- treeNode.data.feesIndex[fieldName] = fee;
|
|
|
- treeNode.changed = true;
|
|
|
- };
|
|
|
- },
|
|
|
- checkFeeField(treeNode, feeObj){
|
|
|
- if (!feeObj) return;
|
|
|
- if (feeObj.fieldName == '') return;
|
|
|
-
|
|
|
- // 初始化前先拦截末定义的情况
|
|
|
- if (!treeNode.data.feesIndex || !treeNode.data.feesIndex[feeObj.fieldName]){
|
|
|
- if (feeObj.unitFee == 0 && feeObj.totalFee == 0) return;
|
|
|
- }
|
|
|
-
|
|
|
- this.initFeeField(treeNode, feeObj.fieldName);
|
|
|
-
|
|
|
- if (treeNode.data.feesIndex[feeObj.fieldName].unitFee != feeObj.unitFee){
|
|
|
- treeNode.data.feesIndex[feeObj.fieldName].unitFee = feeObj.unitFee;
|
|
|
- treeNode.changed = true;
|
|
|
- };
|
|
|
-
|
|
|
- if (treeNode.data.feesIndex[feeObj.fieldName].totalFee != feeObj.totalFee){
|
|
|
- treeNode.data.feesIndex[feeObj.fieldName].totalFee = feeObj.totalFee;
|
|
|
- treeNode.changed = true;
|
|
|
- };
|
|
|
- },
|
|
|
- initSummaryFee(treeNode){
|
|
|
- if (!treeNode.data.summaryFees){
|
|
|
- treeNode.data.summaryFees = {
|
|
|
- totalFee: 0,
|
|
|
- estimateFee: 0,
|
|
|
- safetyFee: 0,
|
|
|
- chargeFee: 0
|
|
|
- };
|
|
|
- treeNode.changed = true;
|
|
|
- };
|
|
|
- },
|
|
|
- getCalcType(treeNode) {
|
|
|
- if (this.isRationCategory(treeNode)){
|
|
|
- return treeNodeCalcType.ctRationCalcProgram;
|
|
|
- }
|
|
|
- else if (this.isNullBill(treeNode)){
|
|
|
- return treeNodeCalcType.ctNull;
|
|
|
- }
|
|
|
- else if (this.isLeafBill(treeNode)) {
|
|
|
- if (treeNode.children && treeNode.children.length > 0){
|
|
|
- // 清单单价计算模式下的叶子清单:取自己的计算程序ID,找到自己的计算程序计算。(汇总清单所有定额的工料机)
|
|
|
- if (projectObj.project.property.billsCalcMode === leafBillGetFeeType.billsPrice)
|
|
|
- return treeNodeCalcType.ctBillCalcProgram;
|
|
|
- else // 前三种计算模式下的叶子清单:汇总定额的计算程序的费用类别
|
|
|
- return treeNodeCalcType.ctGatherRationsFees;
|
|
|
- }
|
|
|
- else{ // 公式计算
|
|
|
- return treeNodeCalcType.ctCalcBaseValue;
|
|
|
- };
|
|
|
- }
|
|
|
- else if (this.isBill(treeNode)) { // 父清单:汇总子清单的费用类别
|
|
|
- return treeNodeCalcType.ctGatherBillsFees;
|
|
|
- }
|
|
|
- else {
|
|
|
- return treeNodeCalcType.ctRationCalcProgram;
|
|
|
- };
|
|
|
- },
|
|
|
- uiQuantity(treeNode){
|
|
|
- return parseFloatPlus(treeNode.data.quantity).toDecimal(decimalObj.decimal("quantity", treeNode));
|
|
|
- },
|
|
|
-
|
|
|
- getFee(treeNode, fieldName) { // fieldName: 'common.totalFee'、'equipment.unitFee'
|
|
|
- let ns = fieldName.split(".");
|
|
|
- if (ns.length != 2)
|
|
|
- return 0
|
|
|
- else if (treeNode.data.feesIndex[ns[0]] && treeNode.data.feesIndex[ns[0]][ns[1]])
|
|
|
- return parseFloat(treeNode.data.feesIndex[ns[0]][ns[1]])
|
|
|
- else
|
|
|
- return 0;
|
|
|
- },
|
|
|
- getNodeByFlag(flag) {
|
|
|
- let bill = cbTools.findBill(flag);
|
|
|
- if (bill) return this.getNodeByID(bill.ID)
|
|
|
- else return null;
|
|
|
- },
|
|
|
- getNodeByID(ID){
|
|
|
- return cbTools.getNodeByID(ID);
|
|
|
- }
|
|
|
-};
|
|
|
-
|
|
|
class CalcProgram {
|
|
|
constructor(project){
|
|
|
let me = this;
|
|
@@ -1237,4 +1245,4 @@ class CalcProgram {
|
|
|
calcNodes(me.project.mainTree.roots);
|
|
|
return rst;
|
|
|
};
|
|
|
-}
|
|
|
+};
|