|
|
@@ -9,15 +9,15 @@
|
|
|
function _chkIfEquals(orgStr, targetStr) {
|
|
|
//㎡ ㎥ 立方
|
|
|
let rst = false;
|
|
|
- if (orgStr !== null && targetStr !== null) {
|
|
|
+ if (typeof(orgStr) == 'string' && typeof(targetStr) == 'string') {
|
|
|
let regExp1 = new RegExp('㎡', "gm");
|
|
|
- let regExp2 = new RegExp('㎥', "gm");
|
|
|
- let orgS = orgStr.replace(regExp1, 'm2');
|
|
|
- let targetS = targetStr.replace(regExp2, 'm3');
|
|
|
+ let regExp2 = new RegExp('(', "gm");
|
|
|
+ let regExp3 = new RegExp(')', "gm");
|
|
|
+ let orgS = orgStr.replace(regExp1, 'm2').replace(regExp2, '(').replace(regExp3, ')');
|
|
|
+ let targetS = targetStr.replace(regExp1, 'm2').replace(regExp2, '(').replace(regExp3, ')');
|
|
|
rst = (orgS === targetS);
|
|
|
}
|
|
|
return rst;
|
|
|
- //
|
|
|
}
|
|
|
|
|
|
function chkAndSetBillsUnitPrice(billsNodes) {
|
|
|
@@ -25,70 +25,15 @@ function chkAndSetBillsUnitPrice(billsNodes) {
|
|
|
if (billsUnitPriceFeature !== null) {
|
|
|
for (const node of billsNodes) {
|
|
|
if (node.updateType === 'create') {
|
|
|
- //只有创建的才设置初始化单价
|
|
|
- let isMatch = true;
|
|
|
- // 1. 基本数量
|
|
|
- // 先判断此bills是否有配置
|
|
|
- let basicValue = 0;
|
|
|
- for (const bm of billsUnitPriceFeature.feature.basicMappings) {
|
|
|
- isMatch = true;
|
|
|
- if (bm.parentBasicKeys.length === billsUnitPriceFeature.feature.basicKeyOptions.length) {
|
|
|
- for (let kIdx = 0; kIdx < bm.parentBasicKeys.length; kIdx++) {
|
|
|
- if (bm.parentBasicKeys[kIdx] !== 'ALL' && !_chkIfEquals(node.updateData[billsUnitPriceFeature.feature.basicKeyOptions[kIdx].key], bm.parentBasicKeys[kIdx]) ) {
|
|
|
- isMatch = false;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- isMatch = false;
|
|
|
- break;
|
|
|
- }
|
|
|
- if (isMatch) {
|
|
|
- //再根据相关项目属性指定基数
|
|
|
- for (const bms of bm.subs) {
|
|
|
- if (chkUnitPriceFeatureKeys(bms.keys)) {
|
|
|
- basicValue = bms.basicValue;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- // 2. 相关系数(允许多个)
|
|
|
- let factors = [];
|
|
|
- for (const fm of billsUnitPriceFeature.feature.factorMappings) {
|
|
|
- isMatch = true;
|
|
|
- if (fm.basicFactorKeys.length === billsUnitPriceFeature.feature.basicKeyOptions.length) {
|
|
|
- for (let kIdx = 0; kIdx < fm.basicFactorKeys.length; kIdx++) {
|
|
|
- if (fm.basicFactorKeys[kIdx] !== 'ALL' && !_chkIfEquals(node.updateData[billsUnitPriceFeature.feature.basicKeyOptions[kIdx].key], fm.basicFactorKeys[kIdx]) ) {
|
|
|
- isMatch = false;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- isMatch = false;
|
|
|
- break;
|
|
|
- }
|
|
|
- if (isMatch) {
|
|
|
- for (const fms of fm.subs) {
|
|
|
- if (chkUnitPriceFeatureKeys(fms.keys)) {
|
|
|
- factors.push(fms.basicValue);
|
|
|
- }
|
|
|
- }
|
|
|
- // 允许多个,不break;
|
|
|
- }
|
|
|
- }
|
|
|
- //3. 装配(指标基价 即 默认的清单单价)
|
|
|
- let unitFeeVal = basicValue;
|
|
|
- for (const factor of factors) {
|
|
|
- unitFeeVal = unitFeeVal * parseFloat(factor);
|
|
|
- }
|
|
|
// 暂时未设小数位数 scMathUtil.roundTo(unitFeeVal,2);
|
|
|
- node.updateData.calcFlag = 2; //当用户输入单价
|
|
|
- if (!node.updateData.hasOwnProperty('fees')) {
|
|
|
- node.updateData.fees = [];
|
|
|
+ let unitFeeVal = _commonChkAndSetPrice(node.updateData, true);
|
|
|
+ if (unitFeeVal !== 0) {
|
|
|
+ node.updateData.calcFlag = 2; //当用户输入单价
|
|
|
+ if (!node.updateData.hasOwnProperty('fees')) {
|
|
|
+ node.updateData.fees = [];
|
|
|
+ }
|
|
|
+ node.updateData.fees.push({fieldName: 'common', unitFee: unitFeeVal, totalFee: 0, tenderUnitFee: unitFeeVal, tenderTotalFee: 0});
|
|
|
}
|
|
|
- node.updateData.fees.push({fieldName: 'common', unitFee: unitFeeVal, totalFee: 0, tenderUnitFee: unitFeeVal, tenderTotalFee: 0});
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -98,38 +43,86 @@ function chkAndResetBills() {
|
|
|
//用户调整了工程特征后调用
|
|
|
for (let key in projectObj.project.mainTree.nodes) {
|
|
|
const node = projectObj.project.mainTree.nodes[key];
|
|
|
- // 1. 基本数量
|
|
|
- // 先判断此bills是否有配置
|
|
|
- let isMatch = true;
|
|
|
- let basicValue = 0;
|
|
|
- for (const bm of billsUnitPriceFeature.feature.basicMappings) {
|
|
|
- // node.data[bm]
|
|
|
- isMatch = true;
|
|
|
+ let unitFeeVal = _commonChkAndSetPrice(node.data, true);
|
|
|
+ if (unitFeeVal !== 0) {
|
|
|
+ // 暂时未设小数位数 scMathUtil.roundTo(unitFeeVal,2);
|
|
|
+ if (!node.data.hasOwnProperty('fees')) {
|
|
|
+ node.data.fees = [];
|
|
|
+ }
|
|
|
+ for (let idx = node.data.fees.length - 1; idx >= 0; idx--) {
|
|
|
+ if (node.data.fees[idx].fieldName === 'common') {
|
|
|
+ node.data.fees[idx].unitFee = unitFeeVal;
|
|
|
+ node.data.fees[idx].tenderUnitFee = unitFeeVal;
|
|
|
+ node.data.feesIndex.common.unitFee = unitFeeVal;
|
|
|
+ node.data.feesIndex.common.tenderUnitFee = unitFeeVal;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 调整了后需要重新计算
|
|
|
+ $.bootstrapLoading.start();
|
|
|
+ projectObj.project.calcProgram.calcAllNodesAndSave(calcAllType.catAll, function () {
|
|
|
+ projectObj.project.projectGLJ.loadData(function () {
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ });
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+function chkAndAddEstUnitPrice(orgBills) {
|
|
|
+ //只显示基本价格,无系数!
|
|
|
+ if (billsUnitPriceFeature !== null) {
|
|
|
+ for (const node of orgBills) {
|
|
|
+ let unitFeeVal = _commonChkAndSetPrice(node, false);
|
|
|
+ if (!isNaN(parseFloat(unitFeeVal))) {
|
|
|
+ unitFeeVal = unitFeeVal.toFixed(2);
|
|
|
+ if (unitFeeVal === '0.00') unitFeeVal = '';
|
|
|
+ }
|
|
|
+ // 暂时未设小数位数 scMathUtil.roundTo(unitFeeVal,2);
|
|
|
+ node.baseEstUnitPrice = unitFeeVal;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function _commonChkAndSetPrice(curItem, isNeedFactor) {
|
|
|
+ let rst = 0;
|
|
|
+ let isMatch = true;
|
|
|
+ // 1. 基本数量
|
|
|
+ // 先判断此bills是否有配置
|
|
|
+ let basicValue = 0;
|
|
|
+ for (const bm of billsUnitPriceFeature.feature.basicMappings) {
|
|
|
+ isMatch = true;
|
|
|
+ if (bm.parentBasicKeys.length === billsUnitPriceFeature.feature.basicKeyOptions.length) {
|
|
|
for (let kIdx = 0; kIdx < bm.parentBasicKeys.length; kIdx++) {
|
|
|
- if (bm.parentBasicKeys[kIdx] !== 'ALL' && !_chkIfEquals(node.data[billsUnitPriceFeature.feature.basicKeyOptions[kIdx].key], bm.parentBasicKeys[kIdx])) {
|
|
|
+ if (bm.parentBasicKeys[kIdx] !== 'ALL' && !_chkIfEquals(curItem[billsUnitPriceFeature.feature.basicKeyOptions[kIdx].key], bm.parentBasicKeys[kIdx]) ) {
|
|
|
isMatch = false;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if (isMatch) {
|
|
|
- //再根据相关项目属性指定基数
|
|
|
- for (const bms of bm.subs) {
|
|
|
- if (chkUnitPriceFeatureKeys(bms.keys)) {
|
|
|
- basicValue = bms.basicValue;
|
|
|
- break;
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ isMatch = false;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (isMatch) {
|
|
|
+ //再根据相关项目属性指定基数
|
|
|
+ for (const bms of bm.subs) {
|
|
|
+ if (_chkUnitPriceFeatureKeys(bms.keys)) {
|
|
|
+ basicValue = bms.basicValue;
|
|
|
+ break;
|
|
|
}
|
|
|
- break;
|
|
|
}
|
|
|
+ break;
|
|
|
}
|
|
|
- if (!isMatch) continue; //未匹配上,下一轮,无需继续
|
|
|
- // 2. 相关系数(允许多个)
|
|
|
- let factors = [];
|
|
|
+ }
|
|
|
+ let factors = [];
|
|
|
+ if (!isMatch || !isNeedFactor) {
|
|
|
+ rst = basicValue;
|
|
|
+ } else {
|
|
|
for (const fm of billsUnitPriceFeature.feature.factorMappings) {
|
|
|
isMatch = true;
|
|
|
if (fm.basicFactorKeys.length === billsUnitPriceFeature.feature.basicKeyOptions.length) {
|
|
|
for (let kIdx = 0; kIdx < fm.basicFactorKeys.length; kIdx++) {
|
|
|
- if (fm.basicFactorKeys[kIdx] !== 'ALL' && !_chkIfEquals(node.data[billsUnitPriceFeature.feature.basicKeyOptions[kIdx].key], fm.basicFactorKeys[kIdx])) {
|
|
|
+ if (fm.basicFactorKeys[kIdx] !== 'ALL' && !_chkIfEquals(curItem[billsUnitPriceFeature.feature.basicKeyOptions[kIdx].key], fm.basicFactorKeys[kIdx])) {
|
|
|
isMatch = false;
|
|
|
break;
|
|
|
}
|
|
|
@@ -140,7 +133,7 @@ function chkAndResetBills() {
|
|
|
}
|
|
|
if (isMatch) {
|
|
|
for (const fms of fm.subs) {
|
|
|
- if (chkUnitPriceFeatureKeys(fms.keys)) {
|
|
|
+ if (_chkUnitPriceFeatureKeys(fms.keys)) {
|
|
|
factors.push(fms.basicValue);
|
|
|
}
|
|
|
}
|
|
|
@@ -152,101 +145,12 @@ function chkAndResetBills() {
|
|
|
for (const factor of factors) {
|
|
|
unitFeeVal = unitFeeVal * parseFloat(factor);
|
|
|
}
|
|
|
- // 暂时未设小数位数 scMathUtil.roundTo(unitFeeVal,2);
|
|
|
- if (!node.data.hasOwnProperty('fees')) {
|
|
|
- node.data.fees = [];
|
|
|
- }
|
|
|
- for (let idx = node.data.fees.length - 1; idx >= 0; idx--) {
|
|
|
- if (node.data.fees[idx].fieldName === 'common') {
|
|
|
- node.data.fees[idx].unitFee = unitFeeVal;
|
|
|
- node.data.fees[idx].tenderUnitFee = unitFeeVal;
|
|
|
- node.data.feesIndex.common.unitFee = unitFeeVal;
|
|
|
- node.data.feesIndex.common.tenderUnitFee = unitFeeVal;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // 调整了后需要重新计算
|
|
|
- $.bootstrapLoading.start();
|
|
|
- projectObj.project.calcProgram.calcAllNodesAndSave(calcAllType.catAll, function () {
|
|
|
- projectObj.project.projectGLJ.loadData(function () {
|
|
|
- $.bootstrapLoading.end();
|
|
|
- });
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
-function chkAndAddEstUnitPrice(orgBills) {
|
|
|
- if (billsUnitPriceFeature !== null) {
|
|
|
- for (const node of orgBills) {
|
|
|
- //只有创建的才设置初始化单价
|
|
|
- let isMatch = true;
|
|
|
- // 1. 基本数量
|
|
|
- // 先判断此bills是否有配置
|
|
|
- let basicValue = 0;
|
|
|
- for (const bm of billsUnitPriceFeature.feature.basicMappings) {
|
|
|
- isMatch = true;
|
|
|
- if (bm.parentBasicKeys.length === billsUnitPriceFeature.feature.basicKeyOptions.length) {
|
|
|
- for (let kIdx = 0; kIdx < bm.parentBasicKeys.length; kIdx++) {
|
|
|
- if (bm.parentBasicKeys[kIdx] !== 'ALL' && !_chkIfEquals(node[billsUnitPriceFeature.feature.basicKeyOptions[kIdx].key], bm.parentBasicKeys[kIdx])) {
|
|
|
- isMatch = false;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- isMatch = false;
|
|
|
- break;
|
|
|
- }
|
|
|
- if (isMatch) {
|
|
|
- //再根据相关项目属性指定基数
|
|
|
- for (const bms of bm.subs) {
|
|
|
- if (chkUnitPriceFeatureKeys(bms.keys)) {
|
|
|
- basicValue = bms.basicValue;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- // 2. 相关系数(允许多个)
|
|
|
- let factors = [];
|
|
|
- for (const fm of billsUnitPriceFeature.feature.factorMappings) {
|
|
|
- isMatch = true;
|
|
|
- if (fm.basicFactorKeys.length === billsUnitPriceFeature.feature.basicKeyOptions.length) {
|
|
|
- for (let kIdx = 0; kIdx < fm.basicFactorKeys.length; kIdx++) {
|
|
|
- if (fm.basicFactorKeys[kIdx] !== 'ALL' && !_chkIfEquals(node[billsUnitPriceFeature.feature.basicKeyOptions[kIdx].key], fm.basicFactorKeys[kIdx])) {
|
|
|
- isMatch = false;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- isMatch = false;
|
|
|
- break;
|
|
|
- }
|
|
|
- if (isMatch) {
|
|
|
- for (const fms of fm.subs) {
|
|
|
- if (chkUnitPriceFeatureKeys(fms.keys)) {
|
|
|
- factors.push(fms.basicValue);
|
|
|
- }
|
|
|
- }
|
|
|
- // 允许多个,不break;
|
|
|
- }
|
|
|
- }
|
|
|
- //3. 装配(指标基价 即 默认的清单单价)
|
|
|
- let unitFeeVal = basicValue;
|
|
|
- for (const factor of factors) {
|
|
|
- unitFeeVal = unitFeeVal * parseFloat(factor);
|
|
|
- }
|
|
|
- if (!isNaN(parseFloat(unitFeeVal))) {
|
|
|
- unitFeeVal = unitFeeVal.toFixed(2);
|
|
|
- if (unitFeeVal === '0.00') unitFeeVal = '';
|
|
|
- }
|
|
|
- // 暂时未设小数位数 scMathUtil.roundTo(unitFeeVal,2);
|
|
|
- node.baseEstUnitPrice = unitFeeVal;
|
|
|
- }
|
|
|
+ rst = unitFeeVal;
|
|
|
}
|
|
|
+ return rst;
|
|
|
}
|
|
|
|
|
|
-function chkUnitPriceFeatureKeys(keys) {
|
|
|
+function _chkUnitPriceFeatureKeys(keys) {
|
|
|
let rst = false;
|
|
|
for (const subKey of keys) {
|
|
|
let isPrjFeatureMatch = false;
|