|
@@ -100,6 +100,56 @@ let defaultBillTemplate = {
|
|
|
]
|
|
|
};
|
|
|
|
|
|
+const baseCalcType = {baseCalc: 0, adjustCalc: 1, budgetCalc: 2, diffCalc: 3, offerCalc: 4};
|
|
|
+
|
|
|
+let rationCalcBase = [
|
|
|
+ {
|
|
|
+ 'dispName': '定额基价人工费',
|
|
|
+ 'calcType': baseCalcType.baseCalc,
|
|
|
+ 'gljTypes': [gljType.LABOUR]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 'dispName': '定额基价材料费',
|
|
|
+ 'calcType': baseCalcType.baseCalc,
|
|
|
+ 'gljTypes': [gljType.GENERAL_MATERIAL, gljType.CONCRETE, gljType.MORTAR, gljType.MIX_RATIO, gljType.COMMERCIAL_CONCRETE, gljType.COMMERCIAL_MORTAR]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 'dispName': '定额基价机械费',
|
|
|
+ 'calcType': baseCalcType.baseCalc,
|
|
|
+ 'gljTypes': [gljType.GENERAL_MACHINE]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 'dispName': '定额基价机上人工费',
|
|
|
+ 'calcType': baseCalcType.baseCalc,
|
|
|
+ 'gljTypes': [gljType.MACHINE_LABOUR]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 'dispName': '人工费价差',
|
|
|
+ 'calcType': baseCalcType.diffCalc,
|
|
|
+ 'gljTypes': [gljType.LABOUR]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 'dispName': '材料费价差',
|
|
|
+ 'calcType': baseCalcType.diffCalc,
|
|
|
+ 'gljTypes': [gljType.GENERAL_MATERIAL, gljType.CONCRETE, gljType.MORTAR, gljType.MIX_RATIO, gljType.COMMERCIAL_CONCRETE, gljType.COMMERCIAL_MORTAR]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 'dispName': '机械费价差',
|
|
|
+ 'calcType': baseCalcType.diffCalc,
|
|
|
+ 'gljTypes': [gljType.GENERAL_MACHINE]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 'dispName': '主材费',
|
|
|
+ 'calcType': baseCalcType.budgetCalc,
|
|
|
+ 'gljTypes': [gljType.MAIN_MATERIAL]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 'dispName': '设备费',
|
|
|
+ 'calcType': baseCalcType.budgetCalc,
|
|
|
+ 'gljTypes': [gljType.EQUIPMENT]
|
|
|
+ }
|
|
|
+];
|
|
|
+
|
|
|
let analyzer = {
|
|
|
calcTemplate: null,
|
|
|
success: true,
|
|
@@ -293,10 +343,10 @@ let executeObj = {
|
|
|
for (let glj of me.treeNode.data.gljList) {
|
|
|
let price = 0;
|
|
|
if (base.gljTypes.indexOf(glj.type) >= 0) {
|
|
|
- if (base.calcType == baseCalc){ price = parseFloat(glj["basePrice"]);}
|
|
|
- else if (base.calcType == adjustCalc){price = parseFloat(glj["adjustPrice"]);}
|
|
|
- else if (base.calcType == budgetCalc){price = parseFloat(glj["marketPrice"]);}
|
|
|
- else if (base.calcType == diffCalc){
|
|
|
+ if (base.calcType == baseCalcType.baseCalc){ price = parseFloat(glj["basePrice"]);}
|
|
|
+ else if (base.calcType == baseCalcType.adjustCalc){price = parseFloat(glj["adjustPrice"]);}
|
|
|
+ else if (base.calcType == baseCalcType.budgetCalc){price = parseFloat(glj["marketPrice"]);}
|
|
|
+ else if (base.calcType == baseCalcType.diffCalc){
|
|
|
let aprice = glj["adjustPrice"] ? glj["adjustPrice"] : 0;
|
|
|
let mprice = glj["marketPrice"] ? glj["marketPrice"] : 0;
|
|
|
price = (parseFloat(mprice) - parseFloat(aprice)).toDecimal(me.digitDefault);
|
|
@@ -316,7 +366,7 @@ let executeObj = {
|
|
|
( me.treeNode.data.subType === gljType.GENERAL_MACHINE && base.dispName === '定额基价机械费') ||
|
|
|
( me.treeNode.data.subType === gljType.MAIN_MATERIAL && base.dispName === '主材费') ||
|
|
|
( me.treeNode.data.subType === gljType.EQUIPMENT && base.dispName === '设备费')
|
|
|
- ) result = me.treeNode.data.marketUnitFee;
|
|
|
+ ) result = me.treeNode.data.marketUnitFee ? me.treeNode.data.marketUnitFee : 0;
|
|
|
|
|
|
return result;
|
|
|
};
|
|
@@ -541,6 +591,13 @@ class CalcProgram {
|
|
|
};
|
|
|
};
|
|
|
|
|
|
+ isLeafBill(treeNode){
|
|
|
+ let me = this;
|
|
|
+ return treeNode.sourceType === me.project.Bills.getSourceType() &&
|
|
|
+ treeNode.source.children &&
|
|
|
+ treeNode.source.children.length === 0;
|
|
|
+ };
|
|
|
+
|
|
|
// 仅内部调用。注意:外部不能直接使用,因为这里传入的树节点必须有一定的初始化。
|
|
|
InnerCalc(treeNode){
|
|
|
let me = this;
|
|
@@ -582,32 +639,76 @@ class CalcProgram {
|
|
|
};
|
|
|
};
|
|
|
|
|
|
+ function isBaseFeeType(type){
|
|
|
+ return ['labour', 'material', 'machine', 'mainMaterial', 'equipment'].indexOf(type) > -1;
|
|
|
+ };
|
|
|
+
|
|
|
// 汇总定额或子清单的费用类别
|
|
|
- if (treeNode.calcType == treeNodeCalcType.ctGatherRations || treeNode.calcType == treeNodeCalcType.ctGatherBills){
|
|
|
+ if (treeNode.calcType == treeNodeCalcType.ctGatherRationsFees || treeNode.calcType == treeNodeCalcType.ctGatherBillsFees){
|
|
|
treeNode.data.programID = null;
|
|
|
initFees(treeNode);
|
|
|
|
|
|
- let objsArr = (treeNode.calcType == treeNodeCalcType.ctGatherRations) ? project.Ration.getRationsByNode(treeNode) : treeNode.children;
|
|
|
+ let objsArr = (treeNode.calcType == treeNodeCalcType.ctGatherRationsFees) ? project.Ration.getRationsByNode(treeNode) : treeNode.children;
|
|
|
let rst = [];
|
|
|
for (let ft of feeType) {
|
|
|
let ftObj = {};
|
|
|
ftObj.fieldName = ft.type;
|
|
|
ftObj.name = ft.name;
|
|
|
- let uf = 0, tf = 0, tuf = 0, ttf = 0;
|
|
|
- for (let item of objsArr) {
|
|
|
- let data = (treeNode.calcType == treeNodeCalcType.ctGatherRations) ? item : item.data;
|
|
|
- if (data.feesIndex && data.feesIndex[ft.type]) {
|
|
|
- uf = (uf + parseFloat(data.feesIndex[ft.type].unitFee)).toDecimal(me.digitDefault);
|
|
|
- tf = (tf + parseFloat(data.feesIndex[ft.type].totalFee)).toDecimal(me.digitDefault);
|
|
|
- tuf = (tuf + parseFloat(data.feesIndex[ft.type].tenderUnitFee)).toDecimal(me.digitDefault);
|
|
|
- ttf = (ttf + parseFloat(data.feesIndex[ft.type].tenderTotalFee)).toDecimal(me.digitDefault);
|
|
|
+ let buf = 0, btf = 0, btuf = 0, bttf = 0;
|
|
|
+
|
|
|
+ if (treeNode.calcType == treeNodeCalcType.ctGatherBillsFees){
|
|
|
+ for (let item of objsArr) {
|
|
|
+ let data = item.data;
|
|
|
+ if (data.feesIndex && data.feesIndex[ft.type]) {
|
|
|
+ buf = (buf + parseFloat(data.feesIndex[ft.type].unitFee)).toDecimal(me.digitDefault);
|
|
|
+ btf = (btf + parseFloat(data.feesIndex[ft.type].totalFee)).toDecimal(me.digitDefault);
|
|
|
+ btuf = (btuf + parseFloat(data.feesIndex[ft.type].tenderUnitFee)).toDecimal(me.digitDefault);
|
|
|
+ bttf = (bttf + parseFloat(data.feesIndex[ft.type].tenderTotalFee)).toDecimal(me.digitDefault);
|
|
|
+ };
|
|
|
+ };
|
|
|
+ }
|
|
|
+ else if (treeNode.calcType == treeNodeCalcType.ctGatherRationsFees){ // 这里的算法要配合冷姐姐的神图才能看懂^_^
|
|
|
+ let sum_rtf = 0, sum_rttf = 0;
|
|
|
+ let bq = parseFloat(treeNode.data.quantity ? treeNode.data.quantity : 1);
|
|
|
+
|
|
|
+ for (let data of objsArr) {
|
|
|
+ let rq = parseFloat(data.quantity ? data.quantity : 0);
|
|
|
+
|
|
|
+ let ruf = 0, rtuf = 0, rtf = 0, rttf = 0;
|
|
|
+ if (data.feesIndex && data.feesIndex[ft.type]) {
|
|
|
+ ruf = parseFloat(data.feesIndex[ft.type].unitFee);
|
|
|
+ rtuf = parseFloat(data.feesIndex[ft.type].tenderUnitFee);
|
|
|
+ rtf = parseFloat(data.feesIndex[ft.type].totalFee);
|
|
|
+ rttf = parseFloat(data.feesIndex[ft.type].tenderTotalFee);
|
|
|
+ };
|
|
|
+
|
|
|
+ if (me.project.projSetting.billsCalcMode === leafBillGetFeeType.rationContent) {
|
|
|
+ buf = (buf + (ruf * rq / bq).toDecimal(2)).toDecimal(2);
|
|
|
+ btuf = (btuf + (rtuf * rq / bq).toDecimal(2)).toDecimal(2);
|
|
|
+ };
|
|
|
+
|
|
|
+ sum_rtf = (sum_rtf + rtf).toDecimal(2);
|
|
|
+ sum_rttf = (sum_rttf + rttf).toDecimal(2);
|
|
|
+ };
|
|
|
+
|
|
|
+ if (me.project.projSetting.billsCalcMode === leafBillGetFeeType.rationPrice || me.project.projSetting.billsCalcMode === leafBillGetFeeType.rationPriceConverse) {
|
|
|
+ buf = (sum_rtf / bq).toDecimal(2);
|
|
|
+ btuf = (sum_rttf / bq).toDecimal(2);
|
|
|
+ };
|
|
|
+ if (isBaseFeeType(ft.type) || (me.project.projSetting.billsCalcMode === leafBillGetFeeType.rationPriceConverse && ft.type == "common")){
|
|
|
+ btf = sum_rtf;
|
|
|
+ bttf = sum_rttf;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ btf = (buf * bq).toDecimal(2);
|
|
|
+ bttf = (btuf * bq).toDecimal(2);
|
|
|
};
|
|
|
};
|
|
|
- ftObj.unitFee = uf.toDecimal(me.digit);
|
|
|
- ftObj.totalFee = tf.toDecimal(me.digit);
|
|
|
- ftObj.tenderUnitFee = tuf.toDecimal(me.digit);
|
|
|
- ftObj.tenderTotalFee = ttf.toDecimal(me.digit);
|
|
|
|
|
|
+ ftObj.unitFee = buf;
|
|
|
+ ftObj.totalFee = btf;
|
|
|
+ ftObj.tenderUnitFee = btuf;
|
|
|
+ ftObj.tenderTotalFee = bttf;
|
|
|
checkFee(treeNode, ftObj);
|
|
|
|
|
|
rst.push(ftObj);
|
|
@@ -676,7 +777,7 @@ class CalcProgram {
|
|
|
};
|
|
|
}
|
|
|
};
|
|
|
- }
|
|
|
+ };
|
|
|
|
|
|
// 计算本节点(默认同时递归计算所有父节点,可选)
|
|
|
calculate(treeNode, calcParents = true){
|
|
@@ -684,27 +785,27 @@ class CalcProgram {
|
|
|
|
|
|
let isRation = treeNode.sourceType === me.project.Ration.getSourceType();
|
|
|
let isBill = treeNode.sourceType === me.project.Bills.getSourceType();
|
|
|
- let isLeafBill = isBill && treeNode.source.children && treeNode.source.children.length === 0; // 是清单且其下没有子清单
|
|
|
- let isBillPriceCalc = me.project.projSetting.billsCalcMode === billsPrice;
|
|
|
+ let isBillPriceCalc = me.project.projSetting.billsCalcMode === leafBillGetFeeType.billsPrice;
|
|
|
+ let isLeafBill = me.isLeafBill(treeNode);
|
|
|
|
|
|
if (isRation){
|
|
|
treeNode.calcType = treeNodeCalcType.ctRationCalcProgram;
|
|
|
}
|
|
|
else if (isLeafBill) {
|
|
|
if (treeNode.children && treeNode.children.length > 0){
|
|
|
- me.calcLeafBillChildren(treeNode);
|
|
|
+ // me.calcLeafBillChildren(treeNode);
|
|
|
|
|
|
- if (isBillPriceCalc) // 清单单价计算模式下的叶子清单:取自己的计算程序ID,找到自己的计算程序计算
|
|
|
+ if (isBillPriceCalc) // 清单单价计算模式下的叶子清单:取自己的计算程序ID,找到自己的计算程序计算。(汇总清单所有定额的工料机)
|
|
|
treeNode.calcType = treeNodeCalcType.ctBillCalcProgram;
|
|
|
else // 前三种计算模式下的叶子清单:汇总定额的计算程序的费用类别
|
|
|
- treeNode.calcType = treeNodeCalcType.ctGatherRations;
|
|
|
+ treeNode.calcType = treeNodeCalcType.ctGatherRationsFees;
|
|
|
}
|
|
|
else{ // 公式计算
|
|
|
treeNode.calcType = treeNodeCalcType.ctCalcBaseValue;
|
|
|
};
|
|
|
}
|
|
|
else if (isBill) // 父清单:汇总子清单的费用类别
|
|
|
- treeNode.calcType = treeNodeCalcType.ctGatherBills;
|
|
|
+ treeNode.calcType = treeNodeCalcType.ctGatherBillsFees;
|
|
|
|
|
|
me.InnerCalc(treeNode);
|
|
|
|
|
@@ -792,6 +893,7 @@ class CalcProgram {
|
|
|
// 重新计算叶子清单下的所有子结点:如定额、工料机定额等(calculate算法基于定额、工料机定额的计算结果是正确的,实际上有时它们的计算结果并不是最新的)
|
|
|
calcLeafBillChildren(treeNode){
|
|
|
let me = this;
|
|
|
+ if(!me.isLeafBill(treeNode)) return;
|
|
|
if (treeNode.children && treeNode.children.length > 0) {
|
|
|
let needSaveNodes = [];
|
|
|
for (let child of treeNode.children){
|