|
@@ -83,6 +83,10 @@ let executeObj = {
|
|
|
};
|
|
|
|
|
|
return rst;
|
|
|
+ },
|
|
|
+ HJ: function () {
|
|
|
+ let me = this;
|
|
|
+ return me.treeNode.data.baseTotalPrice;
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -338,8 +342,13 @@ class Calculation {
|
|
|
for (let idx of template.compiledSeq) {
|
|
|
let item = template.calcItems[idx];
|
|
|
item.dispExprUser = item.dispExpr; // 用于界面显示。disExpr是公式模板,不允许修改:人工系数占位符被修改后变成数值,第二次无法正确替换。
|
|
|
- item.compiledExpr = item.expression.split('@(').join('$CE.at(');
|
|
|
- item.compiledExpr = item.compiledExpr.split('base(').join('$CE.base(');
|
|
|
+ if (item.expression == 'HJ')
|
|
|
+ item.compiledExpr = '$CE.HJ()'
|
|
|
+ else{
|
|
|
+ item.compiledExpr = item.expression.split('@(').join('$CE.at(');
|
|
|
+ item.compiledExpr = item.compiledExpr.split('base(').join('$CE.base(');
|
|
|
+ };
|
|
|
+
|
|
|
if (item.labourCoeID){
|
|
|
let lc = me.compiledLabourCoes["LabourCoe_" + item.labourCoeID].coe;
|
|
|
item.dispExprUser = item.dispExpr.replace(/L/gi, lc.toString());
|
|
@@ -383,23 +392,39 @@ class Calculation {
|
|
|
};
|
|
|
};
|
|
|
|
|
|
- calculate($treeNode){
|
|
|
+ calculate(treeNode){
|
|
|
let me = this;
|
|
|
- let templateID = $treeNode.data.programID;
|
|
|
+ let templateID = treeNode.data.programID;
|
|
|
if (!templateID) templateID = 1;
|
|
|
let template = me.compiledTemplates[templateID];
|
|
|
- $treeNode.data.calcTemplate = template;
|
|
|
+ treeNode.data.calcTemplate = template;
|
|
|
+
|
|
|
+ let project = projectObj.project;
|
|
|
+
|
|
|
+ // 缺省计算程序需要提供总金额作为计算基数,然后每条按比例(费率)计算,不需要工料机明细。
|
|
|
+ if (treeNode.data.baseTotalPrice != undefined){
|
|
|
+ delete treeNode.data.gljList;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (treeNode.sourceType === project.Ration.getSourceType()) {
|
|
|
+ treeNode.data.gljList = project.ration_glj.getGljArrByRation(treeNode.data.ID);
|
|
|
+ }
|
|
|
+ else if (treeNode.sourceType === project.Bills.getSourceType()) {
|
|
|
+ let rations = project.Ration.getBillsSortRation(treeNode.source.getID());
|
|
|
+ treeNode.data.gljList = project.ration_glj.getGatherGljArrByRations(rations);
|
|
|
+ };
|
|
|
+ };
|
|
|
|
|
|
- if ($treeNode && template.hasCompiled) {
|
|
|
+ if (treeNode && template.hasCompiled) {
|
|
|
let $CE = executeObj;
|
|
|
- $CE.treeNode = $treeNode;
|
|
|
+ $CE.treeNode = treeNode;
|
|
|
$CE.template = template;
|
|
|
$CE.calcBase = me.compiledCalcBases;
|
|
|
|
|
|
- if (!$treeNode.data.fees) {
|
|
|
- $treeNode.data.fees = [];
|
|
|
- $treeNode.data.feesIndex = {};
|
|
|
- $treeNode.changed = true;
|
|
|
+ if (!treeNode.data.fees) {
|
|
|
+ treeNode.data.fees = [];
|
|
|
+ treeNode.data.feesIndex = {};
|
|
|
+ treeNode.changed = true;
|
|
|
};
|
|
|
|
|
|
for (let idx of template.compiledSeq) {
|
|
@@ -409,14 +434,14 @@ class Calculation {
|
|
|
if (!feeRate) feeRate = 100; // 100%
|
|
|
calcItem.unitFee = round(eval(calcItem.compiledExpr) * feeRate * 0.01); // 如果eval()对清单树有影响,就换成小麦的Expression对象再试
|
|
|
|
|
|
- let quantity = $treeNode.data.quantity;
|
|
|
+ let quantity = treeNode.data.quantity;
|
|
|
if (!quantity) quantity = 0;
|
|
|
calcItem.totalFee = round(calcItem.unitFee * quantity);
|
|
|
|
|
|
// 费用同步到定额
|
|
|
// 引入小麦的字段检测后,快速切换定额出现计算卡顿现象,过多的循环造成。这里把她的代码拆出来,减少微循环。
|
|
|
if (calcItem.fieldName != '') {
|
|
|
- if (!$treeNode.data.feesIndex[calcItem.fieldName]){
|
|
|
+ if (!treeNode.data.feesIndex[calcItem.fieldName]){
|
|
|
let fee = {
|
|
|
'fieldName': calcItem.fieldName,
|
|
|
'unitFee': calcItem.unitFee,
|
|
@@ -424,19 +449,19 @@ class Calculation {
|
|
|
'tenderUnitFee': 0,
|
|
|
'tenderTotalFee': 0
|
|
|
};
|
|
|
- $treeNode.data.fees.push(fee);
|
|
|
- $treeNode.data.feesIndex[calcItem.fieldName] = fee;
|
|
|
- $treeNode.changed = true;
|
|
|
+ treeNode.data.fees.push(fee);
|
|
|
+ treeNode.data.feesIndex[calcItem.fieldName] = fee;
|
|
|
+ treeNode.changed = true;
|
|
|
}
|
|
|
else{
|
|
|
- if ($treeNode.data.feesIndex[calcItem.fieldName].unitFee != calcItem.unitFee){
|
|
|
- $treeNode.data.feesIndex[calcItem.fieldName].unitFee = calcItem.unitFee;
|
|
|
- $treeNode.changed = true;
|
|
|
+ if (treeNode.data.feesIndex[calcItem.fieldName].unitFee != calcItem.unitFee){
|
|
|
+ treeNode.data.feesIndex[calcItem.fieldName].unitFee = calcItem.unitFee;
|
|
|
+ treeNode.changed = true;
|
|
|
};
|
|
|
|
|
|
- if ($treeNode.data.feesIndex[calcItem.fieldName].totalFee != calcItem.totalFee){
|
|
|
- $treeNode.data.feesIndex[calcItem.fieldName].totalFee = calcItem.totalFee;
|
|
|
- $treeNode.changed = true;
|
|
|
+ if (treeNode.data.feesIndex[calcItem.fieldName].totalFee != calcItem.totalFee){
|
|
|
+ treeNode.data.feesIndex[calcItem.fieldName].totalFee = calcItem.totalFee;
|
|
|
+ treeNode.changed = true;
|
|
|
};
|
|
|
}
|
|
|
};
|