|
@@ -98,57 +98,8 @@ 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 cpFeeTypes = [
|
|
|
+const priceTypes = {ptBasePrice: 1, ptAdjustPrice: 2, ptMarketPrice: 3, ptDiffPrice: 4};
|
|
|
+const cpFeeTypes = [
|
|
|
{type: 'direct', name: '直接费'},
|
|
|
{type: 'labour', name: '人工费'},
|
|
|
{type: 'material', name: '材料费'},
|
|
@@ -165,10 +116,93 @@ let cpFeeTypes = [
|
|
|
{type: 'adjustMachineLabour', name: '调整机上人工费'},
|
|
|
{type: 'estimate', name: '暂估费'},
|
|
|
{type: 'fee1', name: '甲供材料费'},
|
|
|
- // 模拟用户新增
|
|
|
{type: 'common', name: '工程造价'}
|
|
|
];
|
|
|
|
|
|
+function getRationBaseFee(treeNode, gljTypes, priceType){
|
|
|
+ if (!treeNode.data.gljList) 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);
|
|
|
+ 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);
|
|
|
+ };
|
|
|
+
|
|
|
+ result = (result + temp).toDecimal(decimalObj.ration.unitPrice);
|
|
|
+ };
|
|
|
+ };
|
|
|
+ return result;
|
|
|
+};
|
|
|
+
|
|
|
+// 定额计算基数。CSL, 2018-01-23
|
|
|
+const rationCalcBaser = {
|
|
|
+ '定额基价人工费':
|
|
|
+ function (node) {
|
|
|
+ return getRationBaseFee(node, [gljType.LABOUR], priceTypes.ptBasePrice);
|
|
|
+ },
|
|
|
+ '定额基价材料费':
|
|
|
+ function (node) {
|
|
|
+ return getRationBaseFee(node, baseMaterialTypes, priceTypes.ptBasePrice);
|
|
|
+ },
|
|
|
+ '定额基价机械费':
|
|
|
+ function (node) {
|
|
|
+ return getRationBaseFee(node, [gljType.GENERAL_MACHINE], priceTypes.ptBasePrice);
|
|
|
+ },
|
|
|
+ '定额基价机上人工费':
|
|
|
+ function machineLabourFee(node) {
|
|
|
+ if (!node.data.gljList) return 0;
|
|
|
+ let result = 0, mdSum = 0;
|
|
|
+ for (let glj of node.data.gljList) {
|
|
|
+ if (glj.type == gljType.GENERAL_MACHINE) {
|
|
|
+ // 获取机械组成物
|
|
|
+ let mds = projectObj.project.composition.getCompositionByGLJ(glj);
|
|
|
+ if (!mds) mds = [];
|
|
|
+ for (let md of mds) {
|
|
|
+ if (md.type == gljType.MACHINE_LABOUR) {
|
|
|
+ let q = md["consumption"] ? md["consumption"] : 0;
|
|
|
+ let p = md["basePrice"] ? md["basePrice"] : 0;
|
|
|
+ mdSum = mdSum + (q * p).toDecimal(decimalObj.process);
|
|
|
+ mdSum = (mdSum).toDecimal(decimalObj.process);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ result = result + (glj["quantity"] * mdSum).toDecimal(decimalObj.process);
|
|
|
+ result = (result).toDecimal(decimalObj.process);
|
|
|
+ };
|
|
|
+ };
|
|
|
+ return result;
|
|
|
+ },
|
|
|
+ '人工费价差':
|
|
|
+ function (node) {
|
|
|
+ return getRationBaseFee(node, [gljType.LABOUR], priceTypes.ptDiffPrice);
|
|
|
+ },
|
|
|
+ '材料费价差':
|
|
|
+ function (node) {
|
|
|
+ return getRationBaseFee(node, baseMaterialTypes, priceTypes.ptDiffPrice);
|
|
|
+ },
|
|
|
+ '机械费价差':
|
|
|
+ function (node) {
|
|
|
+ return getRationBaseFee(node, [gljType.GENERAL_MACHINE], priceTypes.ptDiffPrice);
|
|
|
+ },
|
|
|
+ '主材费':
|
|
|
+ function (node) {
|
|
|
+ return getRationBaseFee(node, [gljType.MAIN_MATERIAL], priceTypes.ptMarketPrice);
|
|
|
+ },
|
|
|
+ '设备费':
|
|
|
+ function (node) {
|
|
|
+ return getRationBaseFee(node, [gljType.EQUIPMENT], priceTypes.ptMarketPrice);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
let analyzer = {
|
|
|
calcTemplate: null,
|
|
|
success: true,
|
|
@@ -313,101 +347,32 @@ let analyzer = {
|
|
|
let executeObj = {
|
|
|
treeNode: null,
|
|
|
template: null,
|
|
|
- calcBase: null,
|
|
|
|
|
|
at: function(ID) {
|
|
|
- let me = executeObj,
|
|
|
- rst = 0;
|
|
|
- rst = me.template.compiledCalcItems[ID].unitFee;
|
|
|
+ let me = executeObj;
|
|
|
+ let rst = me.template.compiledCalcItems[ID].unitFee;
|
|
|
rst = parseFloat(rst);
|
|
|
return rst;
|
|
|
},
|
|
|
- base: function(calcBaseName) {
|
|
|
- let me = executeObj, rst = 0,
|
|
|
- base = me.calcBase[calcBaseName];
|
|
|
-
|
|
|
- if (base != null) {
|
|
|
- function isSubset(sub, arr){
|
|
|
- for(var i = 0, len = sub.length; i < len; i++){
|
|
|
- if(arr.indexOf(sub[i]) == -1) return false;
|
|
|
- }
|
|
|
- return true;
|
|
|
- };
|
|
|
- // 机上人工费:多一层
|
|
|
- function machineLabourFee() {
|
|
|
- if (!me.treeNode.data.gljList) return 0;
|
|
|
- let result = 0, mdSum = 0;
|
|
|
- for (let glj of me.treeNode.data.gljList) {
|
|
|
- if (glj.type == gljType.GENERAL_MACHINE) {
|
|
|
- // 获取机械组成物
|
|
|
- let mds = projectObj.project.composition.getCompositionByGLJ(glj);
|
|
|
- if (!mds) mds = [];
|
|
|
- for (let md of mds){
|
|
|
- if (base.gljTypes.indexOf(md.type) >= 0) {
|
|
|
- let q = md["consumption"] ? md["consumption"] : 0;
|
|
|
- let p = md["basePrice"] ? md["basePrice"] : 0;
|
|
|
- mdSum = mdSum + (q * p).toDecimal(decimalObj.process);
|
|
|
- mdSum = (mdSum).toDecimal(decimalObj.process);
|
|
|
- }
|
|
|
- };
|
|
|
- result = result + (glj["quantity"] * mdSum).toDecimal(decimalObj.process);
|
|
|
- result = (result).toDecimal(decimalObj.process);
|
|
|
- };
|
|
|
- };
|
|
|
- return result;
|
|
|
- };
|
|
|
- function commonGLJFee(){
|
|
|
- if (!me.treeNode.data.gljList) return 0;
|
|
|
- let result = 0;
|
|
|
- for (let glj of me.treeNode.data.gljList) {
|
|
|
- let price = 0, temp = 0;
|
|
|
- if (base.gljTypes.indexOf(glj.type) >= 0) {
|
|
|
- if (base.calcType == baseCalcType.diffCalc){
|
|
|
- let aprice = glj["adjustPrice"] ? glj["adjustPrice"] : 0;
|
|
|
- aprice = parseFloat(aprice);
|
|
|
- let mprice = glj["marketPrice"] ? glj["marketPrice"] : 0;
|
|
|
- mprice = parseFloat(mprice);
|
|
|
- temp = (glj["quantity"] * mprice).toDecimal(decimalObj.ration.unitPrice) - (glj["quantity"] * aprice).toDecimal(decimalObj.ration.unitPrice);
|
|
|
- temp = temp.toDecimal(decimalObj.ration.unitPrice);
|
|
|
- }
|
|
|
- else {
|
|
|
- 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"]);}
|
|
|
- temp = (glj["quantity"] * price).toDecimal(decimalObj.ration.unitPrice);
|
|
|
- };
|
|
|
-
|
|
|
- result = (result + temp).toDecimal(decimalObj.ration.unitPrice);
|
|
|
- };
|
|
|
- };
|
|
|
- return result;
|
|
|
- };
|
|
|
- // 量价、工料机形式的定额, 要把自己的市场单价用于计算程序中的基数。
|
|
|
- function marketPriceToBase() {
|
|
|
- let result = 0;
|
|
|
- if (
|
|
|
- ( me.treeNode.data.subType === gljType.LABOUR && base.dispName === '定额基价人工费') ||
|
|
|
- ( baseMaterialTypes.includes(me.treeNode.data.subType) && base.dispName === '定额基价材料费') ||
|
|
|
- ( 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 ? me.treeNode.data.marketUnitFee : 0;
|
|
|
-
|
|
|
- return result;
|
|
|
- };
|
|
|
-
|
|
|
- if (me.treeNode.data.type == rationType.volumePrice || me.treeNode.data.type == rationType.gljRation){
|
|
|
- rst = marketPriceToBase();
|
|
|
- }
|
|
|
- else{
|
|
|
- if (isSubset(base.gljTypes, [gljType.MACHINE_LABOUR]))
|
|
|
- rst = machineLabourFee()
|
|
|
- else
|
|
|
- rst = commonGLJFee();
|
|
|
- }
|
|
|
+ base: function(baseName) {
|
|
|
+ let me = executeObj;
|
|
|
+ function marketPriceToBase(baseName) {
|
|
|
+ let result = 0;
|
|
|
+ if (
|
|
|
+ ( me.treeNode.data.subType === gljType.LABOUR && baseName === '定额基价人工费') ||
|
|
|
+ ( baseMaterialTypes.includes(me.treeNode.data.subType) && baseName === '定额基价材料费') ||
|
|
|
+ ( 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;
|
|
|
+ return result;
|
|
|
};
|
|
|
|
|
|
- return rst;
|
|
|
+ // 量价、工料机形式的定额, 要把自己的市场单价用于计算程序中的基数。
|
|
|
+ if (me.treeNode.data.type == rationType.volumePrice || me.treeNode.data.type == rationType.gljRation)
|
|
|
+ return marketPriceToBase(baseName)
|
|
|
+ else
|
|
|
+ return rationCalcBaser[baseName](me.treeNode);
|
|
|
},
|
|
|
HJ: function () {
|
|
|
let me = this;
|
|
@@ -593,7 +558,7 @@ class CalcProgram {
|
|
|
me.feeRates = this.project.FeeRate.datas.rates;
|
|
|
me.labourCoes = this.project.labourCoe.datas.coes;
|
|
|
me.feeTypes = cpFeeTypes;
|
|
|
- me.calcBases = rationCalcBase;
|
|
|
+ // me.calcBases = rationCalcBase;
|
|
|
me.templates = this.project.calcProgram.datas.templates;
|
|
|
|
|
|
// me.templates.push(defaultBillTemplate);
|
|
@@ -630,9 +595,9 @@ class CalcProgram {
|
|
|
me.compiledFeeTypeNames.push(ft.name);
|
|
|
}
|
|
|
|
|
|
- for (let cb of me.calcBases) {
|
|
|
+/* for (let cb of me.calcBases) {
|
|
|
me.compiledCalcBases[cb.dispName] = cb; // 中文预编译,可靠性有待验证
|
|
|
- }
|
|
|
+ }*/
|
|
|
};
|
|
|
|
|
|
compileTemplate(template){
|
|
@@ -1091,7 +1056,6 @@ class CalcProgram {
|
|
|
let $CE = executeObj;
|
|
|
$CE.treeNode = treeNode;
|
|
|
$CE.template = template;
|
|
|
- $CE.calcBase = me.compiledCalcBases;
|
|
|
|
|
|
nodeTools.initFees(treeNode);
|
|
|
|
|
@@ -1243,6 +1207,7 @@ class CalcProgram {
|
|
|
let changedNodes = this.calculate(treeNode);
|
|
|
this.saveNodes(changedNodes);
|
|
|
};
|
|
|
+
|
|
|
calcAllNodesAndSave(calcType = calcAllType.catAll){
|
|
|
let changedNodes = this.calcAllNodes(calcType);
|
|
|
this.saveNodes(changedNodes);
|
|
@@ -1255,17 +1220,6 @@ class CalcProgram {
|
|
|
let rst = 0;
|
|
|
|
|
|
function calcNodes(nodes) {
|
|
|
- /*for (let node of nodes) {
|
|
|
- if (node.children.length > 0) {
|
|
|
- calcNodes(node.children);
|
|
|
- }
|
|
|
- else{
|
|
|
- if (!excludeNodes.includes(node) && node.sourceType != ModuleNames.ration_glj) {
|
|
|
- rst = (rst + nodeTools.getFee(node, 'common.totalFee')).toDecimal(decimalObj.bills.totalPrice);
|
|
|
- };
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
for (let node of nodes) {
|
|
|
if (!excludeNodes.includes(node)){
|
|
|
if (node.children.length > 0) {
|