|
@@ -707,10 +707,14 @@ let calcTools = {
|
|
|
glj.tenderQuantity = (glj.quantity * qCoe).toDecimal(decimalObj.glj.quantity);
|
|
|
},
|
|
|
calcGLJTenderPrice: function (glj) {
|
|
|
- let pCoe = 1;
|
|
|
- if (projectObj.project.property.tenderSetting && projectObj.project.property.tenderSetting.gljPriceTenderCoe)
|
|
|
- pCoe = projectObj.project.property.tenderSetting.gljPriceTenderCoe;
|
|
|
- glj.tenderPrice = (glj.marketPrice * pCoe).toDecimal(decimalObj.glj.unitPrice);
|
|
|
+ // let pCoe = 1;
|
|
|
+ // if (projectObj.project.property.tenderSetting && projectObj.project.property.tenderSetting.gljPriceTenderCoe)
|
|
|
+ // pCoe = projectObj.project.property.tenderSetting.gljPriceTenderCoe;
|
|
|
+ // if (compositionTypes.indexOf(glj.type) >= 0)
|
|
|
+ //
|
|
|
+ // else
|
|
|
+ // glj.tenderPrice = (glj.marketPrice * pCoe).toDecimal(decimalObj.glj.unitPrice);
|
|
|
+ glj.tenderPrice = projectObj.project.projectGLJ.getTenderMarketPrice(projectObj.project.projectGLJ.getDataByID(glj.projectGLJID));
|
|
|
},
|
|
|
// 界面显示的工料机价格,包括定额价、市场价等。参数 price 传入一个普通的价格数值即可。
|
|
|
uiGLJPrice: function (price){
|
|
@@ -728,8 +732,14 @@ let calcTools = {
|
|
|
getRationsByProjectGLJ(PGLJID){
|
|
|
let rationIDs = [];
|
|
|
let RGs = projectObj.project.ration_glj.datas;
|
|
|
+ let PGLJIDs = [];
|
|
|
+ if(Array.isArray(PGLJID)){//为了提高效率,改成支持传入数组
|
|
|
+ PGLJIDs = PGLJID
|
|
|
+ }else {
|
|
|
+ PGLJIDs = [PGLJID];
|
|
|
+ }
|
|
|
for (let rg of RGs){
|
|
|
- if (rg.projectGLJID == PGLJID){
|
|
|
+ if (PGLJIDs.indexOf(rg.projectGLJID) !== -1){
|
|
|
rationIDs.push(rg.rationID);
|
|
|
}
|
|
|
};
|
|
@@ -743,7 +753,7 @@ let calcTools = {
|
|
|
// 工料机形式的定额
|
|
|
let items = projectObj.project.mainTree.items;
|
|
|
for (let item of items){
|
|
|
- if (item.data.projectGLJID == PGLJID)
|
|
|
+ if (PGLJIDs.indexOf(item.data.projectGLJID) !== -1)
|
|
|
rationNodes.push(item);
|
|
|
};
|
|
|
|
|
@@ -899,6 +909,7 @@ const rationCalcBases = {
|
|
|
};
|
|
|
|
|
|
let analyzer = {
|
|
|
+ error: '',
|
|
|
standard: function(expr){
|
|
|
let str = expr;
|
|
|
str = str.replace(/\s/g, ""); // 去空格、去中文空格
|
|
@@ -942,8 +953,18 @@ let analyzer = {
|
|
|
return template.calcItems[idx];
|
|
|
},
|
|
|
isCycleCalc: function (expression, ID, template) { // 这里判断expression,是ID引用: @5+@6
|
|
|
- if (expression.includes(`@${ID}`))
|
|
|
- return true;
|
|
|
+ let atID = `@${ID}`;
|
|
|
+ // 避免部分匹配,如:@10匹配@1
|
|
|
+ let idx = expression.indexOf(atID);
|
|
|
+ if (idx >= 0){
|
|
|
+ let nextPos = idx + atID.length;
|
|
|
+ if (nextPos >= expression.length)
|
|
|
+ return true;
|
|
|
+
|
|
|
+ let char = expression.charAt(nextPos);
|
|
|
+ if (!char.isNumberStr())
|
|
|
+ return true;
|
|
|
+ };
|
|
|
|
|
|
let atIDs = analyzer.getAtIDArr(expression);
|
|
|
for (let atID of atIDs) {
|
|
@@ -960,6 +981,7 @@ let analyzer = {
|
|
|
try {
|
|
|
expr = expr.replace(/\[[\u4E00-\u9FA5]+\]/gi, '0');
|
|
|
expr = expr.replace(/@\d+/gi, '0');
|
|
|
+ expr = expr.replace(/L/gi, '0');
|
|
|
if (expr.includes('00'))
|
|
|
return false;
|
|
|
|
|
@@ -975,14 +997,16 @@ let analyzer = {
|
|
|
let expr = me.standard(dispExpr);
|
|
|
let invalidChars = /[^0-9\u4e00-\u9fa5\+\-\*\/\(\)\.\[\]FL%]/g;
|
|
|
if (invalidChars.test(expr)){
|
|
|
- hintBox.infoBox('错误提示',`表达式中含有${hintBox.font('无效字符')}!`,1);
|
|
|
+ analyzer.error = `表达式中含有${hintBox.font('无效字符')}!`;
|
|
|
+ // hintBox.infoBox('错误提示',`表达式中含有${hintBox.font('无效字符')}!`,1);
|
|
|
return false;
|
|
|
};
|
|
|
|
|
|
let i = expr.search(/\df/ig); // 4F3
|
|
|
let j = expr.search(/\d\[/ig); // 4[定额基价人工费]
|
|
|
if (i > -1 || j > -1){
|
|
|
- hintBox.infoBox('错误提示', `表达式中${hintBox.font('缺少运算符')}!`, 1);
|
|
|
+ analyzer.error = `表达式中${hintBox.font('缺少运算符')}!`;
|
|
|
+ // hintBox.infoBox('错误提示', `表达式中${hintBox.font('缺少运算符')}!`, 1);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@@ -991,26 +1015,30 @@ let analyzer = {
|
|
|
let pattBase = new RegExp(/\[[\u4E00-\u9FA5]+\]/gi);
|
|
|
let arrBase = expr.match(pattBase);
|
|
|
if (arrCn && !arrBase){
|
|
|
- hintBox.infoBox('错误提示', `定额基数必须用中括号${hintBox.font('[]')}括起来!`, 1);
|
|
|
+ analyzer.error = `定额基数必须用中括号${hintBox.font('[]')}括起来!`;
|
|
|
+ // hintBox.infoBox('错误提示', `定额基数必须用中括号${hintBox.font('[]')}括起来!`, 1);
|
|
|
return false;
|
|
|
};
|
|
|
if (arrCn && arrBase && (arrCn.length != arrBase.length)){
|
|
|
for (let cn of arrCn){
|
|
|
let tempBase = `[${cn}]`;
|
|
|
if (!arrBase.includes(tempBase)){
|
|
|
- hintBox.infoBox('错误提示', `定额基数“${hintBox.font(cn)}”必须用中括号${hintBox.font('[]')}括起来!`, 1);
|
|
|
+ analyzer.error = `定额基数“${hintBox.font(cn)}”必须用中括号${hintBox.font('[]')}括起来!`;
|
|
|
+ // hintBox.infoBox('错误提示', `定额基数“${hintBox.font(cn)}”必须用中括号${hintBox.font('[]')}括起来!`, 1);
|
|
|
return false;
|
|
|
}
|
|
|
};
|
|
|
// 这里要加一个保险。因为上面的 for 循环在“主材费 + [主材费]” 情况下有Bug
|
|
|
- hintBox.infoBox('错误提示', `定额基数必须用中括号${hintBox.font('[]')}括起来!`, 1);
|
|
|
+ analyzer.error =`定额基数必须用中括号${hintBox.font('[]')}括起来!`;
|
|
|
+ // hintBox.infoBox('错误提示', `定额基数必须用中括号${hintBox.font('[]')}括起来!`, 1);
|
|
|
return false;
|
|
|
};
|
|
|
if (arrBase){
|
|
|
for (let base of arrBase){
|
|
|
let baseName = base.slice(1, -1);
|
|
|
if (!rationCalcBases[baseName]){
|
|
|
- hintBox.infoBox('错误提示', `定额基数${hintBox.font('[' +baseName + ']')}末定义!`, 1);
|
|
|
+ analyzer.error = `定额基数${hintBox.font('[' +baseName + ']')}末定义!`;
|
|
|
+ // hintBox.infoBox('错误提示', `定额基数${hintBox.font('[' +baseName + ']')}末定义!`, 1);
|
|
|
return false;
|
|
|
}
|
|
|
};
|
|
@@ -1021,18 +1049,21 @@ let analyzer = {
|
|
|
let num = F.slice(1);
|
|
|
if (num > template.calcItems.length){
|
|
|
let s = hintBox.font('F'+num);
|
|
|
- hintBox.infoBox('错误提示', `表达式中 “${hintBox.font(s)}” 行号引用错误!`, 1);
|
|
|
+ analyzer.error = `表达式中 “${hintBox.font(s)}” 行号引用错误!`;
|
|
|
+ // hintBox.infoBox('错误提示', `表达式中 “${hintBox.font(s)}” 行号引用错误!`, 1);
|
|
|
return false;
|
|
|
};
|
|
|
};
|
|
|
|
|
|
let expression = me.getExpression(expr, template);
|
|
|
if (me.isCycleCalc(expression, itemID, template)){
|
|
|
- hintBox.infoBox('错误提示', `表达式中有${hintBox.font('循环计算')}!`, 1);
|
|
|
+ analyzer.error = `表达式中有${hintBox.font('循环计算')}!`;
|
|
|
+ // hintBox.infoBox('错误提示', `表达式中有${hintBox.font('循环计算')}!`, 1);
|
|
|
return false;
|
|
|
};
|
|
|
if (!testValue(expression)){
|
|
|
- hintBox.infoBox('错误提示', `表达式中有${hintBox.font('语法错误')}!`, 1);
|
|
|
+ analyzer.error = `表达式中有${hintBox.font('语法错误')}!`;
|
|
|
+ // hintBox.infoBox('错误提示', `表达式中有${hintBox.font('语法错误')}!`, 1);
|
|
|
return false;
|
|
|
};
|
|
|
|
|
@@ -1136,6 +1167,17 @@ let analyzer = {
|
|
|
}
|
|
|
return false;
|
|
|
},
|
|
|
+ refreshUsedCalcItemsStatement: function(template, calcItem){
|
|
|
+ let atID = '@' + calcItem.ID;
|
|
|
+ for (var i = 0; i < template.calcItems.length; i++) {
|
|
|
+ let item = template.calcItems[i];
|
|
|
+ let atIDArr = analyzer.getAtIDArr(item.expression);
|
|
|
+ if (atIDArr.indexOf(atID) >= 0){
|
|
|
+ item.statement = analyzer.getStatement(item.expression, template);
|
|
|
+ };
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
calcItemLabourCoe: function(calcItem){
|
|
|
let lc = 0;
|
|
|
if (calcItem.labourCoeID)
|
|
@@ -1158,7 +1200,7 @@ let analyzer = {
|
|
|
return MaxID;
|
|
|
},
|
|
|
templateNewName: function (name) {
|
|
|
- let i = 2;
|
|
|
+ let i = 1;
|
|
|
while (projectObj.project.calcProgram.compiledTemplateMaps[name + i]) {
|
|
|
i++;
|
|
|
};
|
|
@@ -1821,11 +1863,11 @@ class CalcProgram {
|
|
|
leafBills.push(leafBill);
|
|
|
};
|
|
|
|
|
|
- mergeArr(billNodes, leafBills);
|
|
|
+ billNodes.merge(leafBills);
|
|
|
|
|
|
for (let bill of billNodes){
|
|
|
let changeBills = me.calculate(bill, true, false, tender);
|
|
|
- mergeArr(allChangedNodes, changeBills);
|
|
|
+ allChangedNodes.merge(changeBills);
|
|
|
};
|
|
|
|
|
|
me.calcFormulaNodes(allChangedNodes, tender);
|
|
@@ -1867,7 +1909,7 @@ class CalcProgram {
|
|
|
};
|
|
|
|
|
|
let curChangeds = me.calculate(treeNode, true, true, tender);
|
|
|
- mergeArr(changedNodes, curChangeds);
|
|
|
+ changedNodes.merge(curChangeds);
|
|
|
me.saveNodes(changedNodes);
|
|
|
};
|
|
|
};
|
|
@@ -1906,9 +1948,11 @@ class CalcProgram {
|
|
|
|
|
|
// 反向调价
|
|
|
calcTenderReverse(treeNode, tender){
|
|
|
- if (treeNode.data.feesIndex.common.tenderUnitFee != treeNode.data.feesIndex.common.unitFee){
|
|
|
- treeNode.data.feesIndex.common.tenderUnitFee = treeNode.data.feesIndex.common.unitFee;
|
|
|
- treeNode.changed = true;
|
|
|
+ if (tender == tenderTypes.ttReverseRation) {
|
|
|
+ if (treeNode.data.feesIndex.common.tenderUnitFee != treeNode.data.feesIndex.common.unitFee) {
|
|
|
+ treeNode.data.feesIndex.common.tenderUnitFee = treeNode.data.feesIndex.common.unitFee;
|
|
|
+ treeNode.changed = true;
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
if (!treeNode.data.targetTotalFee){
|
|
@@ -1921,9 +1965,12 @@ class CalcProgram {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ if (!treeNode.data.targetUnitFee)
|
|
|
+ treeNode.data.targetUnitFee = (treeNode.data.targetTotalFee / treeNode.data.quantity).toDecimal(decimalObj.decimal('unitPrice', treeNode));
|
|
|
let coe = 1;
|
|
|
if (treeNode.data.feesIndex.common.totalFee != 0)
|
|
|
- coe = (treeNode.data.targetTotalFee / treeNode.data.feesIndex.common.totalFee).toDecimal(2);//(decimalObj.process);
|
|
|
+ // coe = (treeNode.data.targetTotalFee / treeNode.data.feesIndex.common.totalFee).toDecimal(decimalObj.process);
|
|
|
+ coe = (treeNode.data.targetUnitFee / treeNode.data.feesIndex.common.unitFee).toDecimal(decimalObj.process);
|
|
|
|
|
|
if (tender == tenderTypes.ttReverseRation){
|
|
|
treeNode.data.tenderQuantity = (treeNode.data.quantity * coe).toDecimal(decimalObj.decimal("quantity", treeNode));
|