|
@@ -150,6 +150,27 @@ let rationCalcBase = [
|
|
|
}
|
|
|
];
|
|
|
|
|
|
+let cpFeeTypes = [
|
|
|
+ {type: 'direct', name: '直接费'},
|
|
|
+ {type: 'labour', name: '人工费'},
|
|
|
+ {type: 'material', name: '材料费'},
|
|
|
+ {type: 'machine', name: '机械费'},
|
|
|
+ {type: 'mainMaterial', name: '主材费'},
|
|
|
+ {type: 'equipment', name: '设备费'},
|
|
|
+ {type: 'manage', name: '企业管理费'},
|
|
|
+ {type: 'profit', name: '利润'},
|
|
|
+ {type: 'risk', name: '风险费'},
|
|
|
+ {type: 'labourDiff', name: '人工价差'},
|
|
|
+ {type: 'materialDiff', name: '材料价差'},
|
|
|
+ {type: 'machineDiff', name: '机械价差'},
|
|
|
+ {type: 'adjustLabour', name: '调整人工费'},
|
|
|
+ {type: 'adjustMachineLabour', name: '调整机上人工费'},
|
|
|
+ {type: 'zangu', name: '暂估'},
|
|
|
+ {type: 'fee1', name: '甲供材料费'},
|
|
|
+ // 模拟用户新增
|
|
|
+ {type: 'common', name: '工程造价'}
|
|
|
+];
|
|
|
+
|
|
|
let analyzer = {
|
|
|
calcTemplate: null,
|
|
|
success: true,
|
|
@@ -363,7 +384,7 @@ let executeObj = {
|
|
|
};
|
|
|
return result;
|
|
|
};
|
|
|
- // 量价没有具体的工料机类型,但仍然要用定额的计算程序,所以要给计算基数直接指定。
|
|
|
+ // 量价。没有具体的工料机类型,但仍然要用定额的计算程序,所以要给计算基数直接指定。
|
|
|
function volumePriceFee() {
|
|
|
let result = 0;
|
|
|
if (
|
|
@@ -399,6 +420,39 @@ let executeObj = {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+let treeNodeTools = {
|
|
|
+ // 获取全部有公式的树节点清单
|
|
|
+ getFormulaNodes: function () {
|
|
|
+ let nodes = [];
|
|
|
+ for (let node of projectObj.project.mainTree.items){
|
|
|
+ if (node.sourceType == ModuleNames.bills && node.data.calcBase && node.data.calcBase != '') nodes.push(node);
|
|
|
+ };
|
|
|
+ return nodes;
|
|
|
+ },
|
|
|
+
|
|
|
+ isRation: function(treeNode){
|
|
|
+ return treeNode.sourceType === ModuleNames.ration && treeNode.data.type === rationType.ration;
|
|
|
+ },
|
|
|
+
|
|
|
+ isLeafBill: function(treeNode){
|
|
|
+ return treeNode.sourceType === projectObj.project.Bills.getSourceType() &&
|
|
|
+ treeNode.source.children &&
|
|
|
+ treeNode.source.children.length === 0;
|
|
|
+ },
|
|
|
+
|
|
|
+ isNullBill: function (treeNode) {
|
|
|
+ return this.isLeafBill(treeNode) && (treeNode.children.length === 0) && (!treeNode.data.calcBase);
|
|
|
+ },
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
class CalcProgram {
|
|
|
constructor(project){
|
|
|
let me = this;
|
|
@@ -437,7 +491,7 @@ class CalcProgram {
|
|
|
|
|
|
me.feeRates = this.project.FeeRate.datas.rates;
|
|
|
me.labourCoes = this.project.labourCoe.datas.coes;
|
|
|
- me.feeTypes = feeType;
|
|
|
+ me.feeTypes = cpFeeTypes;
|
|
|
me.calcBases = rationCalcBase;
|
|
|
me.templates = this.project.calcProgram.datas.templates;
|
|
|
|
|
@@ -594,30 +648,6 @@ class CalcProgram {
|
|
|
};
|
|
|
};
|
|
|
|
|
|
- isLeafBill(treeNode){
|
|
|
- let me = this;
|
|
|
- return treeNode.sourceType === me.project.Bills.getSourceType() &&
|
|
|
- treeNode.source.children &&
|
|
|
- treeNode.source.children.length === 0;
|
|
|
- };
|
|
|
-
|
|
|
- isNullBill(treeNode){
|
|
|
- let me = this;
|
|
|
- return me.isLeafBill(treeNode) && (treeNode.children.length ===0) && (!treeNode.data.calcBase);
|
|
|
- };
|
|
|
-
|
|
|
- isRation(treeNode){
|
|
|
- return treeNode.sourceType === ModuleNames.ration && treeNode.data.type === rationType.ration;
|
|
|
- };
|
|
|
-
|
|
|
- isVolumePrice(treeNode){
|
|
|
- return treeNode.sourceType === ModuleNames.ration && treeNode.data.type === rationType.volumePrice;
|
|
|
- };
|
|
|
-
|
|
|
- isGljRation(treeNode){
|
|
|
- return treeNode.sourceType === ModuleNames.ration && treeNode.data.type === rationType.gljRation;
|
|
|
- };
|
|
|
-
|
|
|
initFeeField(treeNode, fieldName){
|
|
|
if (!treeNode.data.fees) {
|
|
|
treeNode.data.fees = [];
|
|
@@ -688,7 +718,7 @@ class CalcProgram {
|
|
|
|
|
|
let objsArr = (treeNode.calcType == treeNodeCalcType.ctGatherRationsFees) ? project.Ration.getRationsByNode(treeNode) : treeNode.children;
|
|
|
let rst = [];
|
|
|
- for (let ft of feeType) {
|
|
|
+ for (let ft of cpFeeTypes) {
|
|
|
let ftObj = {};
|
|
|
ftObj.fieldName = ft.type;
|
|
|
ftObj.name = ft.name;
|
|
@@ -782,7 +812,9 @@ class CalcProgram {
|
|
|
if (treeNode.data.programID) treeNode.data.programID = null;
|
|
|
|
|
|
let f = treeNode.data.feeRate ? treeNode.data.feeRate : 100;
|
|
|
- let q = treeNode.data.quantity ? treeNode.data.quantity : 0;
|
|
|
+ // let q = treeNode.data.quantity ? treeNode.data.quantity : 0;
|
|
|
+ if (!treeNode.data.quantity) treeNode.data.quantity = 1;
|
|
|
+ let q = treeNode.data.quantity;
|
|
|
let b = treeNode.data.calcBaseValue ? treeNode.data.calcBaseValue : 0;
|
|
|
let uf = (b * f * q / 100).toDecimal(decimalObj.bills.unitPrice);
|
|
|
let tuf = uf;
|
|
@@ -869,10 +901,10 @@ class CalcProgram {
|
|
|
if (isRation){
|
|
|
treeNode.calcType = treeNodeCalcType.ctRationCalcProgram;
|
|
|
}
|
|
|
- else if (me.isNullBill(treeNode)){
|
|
|
+ else if (treeNodeTools.isNullBill(treeNode)){
|
|
|
treeNode.calcType = treeNodeCalcType.ctCommonUnitFee;
|
|
|
}
|
|
|
- else if (me.isLeafBill(treeNode)) {
|
|
|
+ else if (treeNodeTools.isLeafBill(treeNode)) {
|
|
|
if (treeNode.children && treeNode.children.length > 0){
|
|
|
// 清单单价计算模式下的叶子清单:取自己的计算程序ID,找到自己的计算程序计算。(汇总清单所有定额的工料机)
|
|
|
if (me.project.property.billsCalcMode === leafBillGetFeeType.billsPrice)
|
|
@@ -933,7 +965,9 @@ class CalcProgram {
|
|
|
fees: node.data.fees,
|
|
|
isFromDetail:node.data.isFromDetail,
|
|
|
feeRate: node.data.feeRate,
|
|
|
- feeRateID: node.data.feeRateID
|
|
|
+ feeRateID: node.data.feeRateID,
|
|
|
+ contain:node.data.contain,
|
|
|
+ quantityEXP:node.data.quantityEXP
|
|
|
};
|
|
|
if(node.sourceType==ModuleNames.ration && node.data.type==rationType.gljRation){//定额类型的工料机做特殊处理
|
|
|
data.code=node.data.code;
|
|
@@ -982,10 +1016,24 @@ class CalcProgram {
|
|
|
return changedNodes;
|
|
|
};
|
|
|
|
|
|
+ // 计算全部公式项
|
|
|
+ calcFormulaNodes(){
|
|
|
+ let nodes = treeNodeTools.getFormulaNodes();
|
|
|
+ if (nodes.length == 0) return;
|
|
|
+ for (let node of nodes){
|
|
|
+ this.calcFormulaNode(node);
|
|
|
+ };
|
|
|
+ };
|
|
|
+
|
|
|
+ // 计算公式项。(它一定是叶子结点,它的父结点一定没有公式)
|
|
|
+ calcFormulaNode(treeNode){
|
|
|
+ // do
|
|
|
+ };
|
|
|
+
|
|
|
// 计算叶子清单下的所有子结点(如定额、量价、工料机定额等), 并计算自身和所有父结点。最后打包存储。
|
|
|
calcLeafAndSave(treeNode){
|
|
|
let me = this;
|
|
|
- if(!me.isLeafBill(treeNode)) return;
|
|
|
+ if(!treeNodeTools.isLeafBill(treeNode)) return;
|
|
|
if (treeNode.children && treeNode.children.length > 0) {
|
|
|
let changedNodes = [];
|
|
|
for (let child of treeNode.children){
|