|
|
@@ -6,6 +6,20 @@
|
|
|
* @version
|
|
|
*/
|
|
|
|
|
|
+function _chkIfEquals(orgStr, targetStr) {
|
|
|
+ //㎡ ㎥ 立方
|
|
|
+ let rst = false;
|
|
|
+ if (orgStr !== null && targetStr !== null) {
|
|
|
+ let regExp1 = new RegExp('㎡', "gm");
|
|
|
+ let regExp2 = new RegExp('㎥', "gm");
|
|
|
+ let orgS = orgStr.replace(regExp1, 'm2');
|
|
|
+ let targetS = targetStr.replace(regExp2, 'm3');
|
|
|
+ rst = (orgS === targetS);
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ //
|
|
|
+}
|
|
|
+
|
|
|
function chkAndSetBillsUnitPrice(billsNodes) {
|
|
|
// 此方法在用户选择清单时调用(有指标基价/清单单价设置)
|
|
|
if (billsUnitPriceFeature !== null) {
|
|
|
@@ -20,7 +34,7 @@ function chkAndSetBillsUnitPrice(billsNodes) {
|
|
|
isMatch = true;
|
|
|
if (bm.parentBasicKeys.length === billsUnitPriceFeature.feature.basicKeyOptions.length) {
|
|
|
for (let kIdx = 0; kIdx < bm.parentBasicKeys.length; kIdx++) {
|
|
|
- if (bm.parentBasicKeys[kIdx] !== 'ALL' && node.updateData[billsUnitPriceFeature.feature.basicKeyOptions[kIdx].key] !== bm.parentBasicKeys[kIdx]) {
|
|
|
+ if (bm.parentBasicKeys[kIdx] !== 'ALL' && !_chkIfEquals(node.updateData[billsUnitPriceFeature.feature.basicKeyOptions[kIdx].key], bm.parentBasicKeys[kIdx]) ) {
|
|
|
isMatch = false;
|
|
|
break;
|
|
|
}
|
|
|
@@ -46,7 +60,7 @@ function chkAndSetBillsUnitPrice(billsNodes) {
|
|
|
isMatch = true;
|
|
|
if (fm.basicFactorKeys.length === billsUnitPriceFeature.feature.basicKeyOptions.length) {
|
|
|
for (let kIdx = 0; kIdx < fm.basicFactorKeys.length; kIdx++) {
|
|
|
- if (fm.basicFactorKeys[kIdx] !== 'ALL' && node.updateData[billsUnitPriceFeature.feature.basicKeyOptions[kIdx].key] !== fm.basicFactorKeys[kIdx]) {
|
|
|
+ if (fm.basicFactorKeys[kIdx] !== 'ALL' && !_chkIfEquals(node.updateData[billsUnitPriceFeature.feature.basicKeyOptions[kIdx].key], fm.basicFactorKeys[kIdx]) ) {
|
|
|
isMatch = false;
|
|
|
break;
|
|
|
}
|
|
|
@@ -92,7 +106,7 @@ function chkAndResetBills() {
|
|
|
// node.data[bm]
|
|
|
isMatch = true;
|
|
|
for (let kIdx = 0; kIdx < bm.parentBasicKeys.length; kIdx++) {
|
|
|
- if (bm.parentBasicKeys[kIdx] !== 'ALL' && node.data[billsUnitPriceFeature.feature.basicKeyOptions[kIdx].key] !== bm.parentBasicKeys[kIdx]) {
|
|
|
+ if (bm.parentBasicKeys[kIdx] !== 'ALL' && !_chkIfEquals(node.data[billsUnitPriceFeature.feature.basicKeyOptions[kIdx].key], bm.parentBasicKeys[kIdx])) {
|
|
|
isMatch = false;
|
|
|
break;
|
|
|
}
|
|
|
@@ -115,7 +129,7 @@ function chkAndResetBills() {
|
|
|
isMatch = true;
|
|
|
if (fm.basicFactorKeys.length === billsUnitPriceFeature.feature.basicKeyOptions.length) {
|
|
|
for (let kIdx = 0; kIdx < fm.basicFactorKeys.length; kIdx++) {
|
|
|
- if (fm.basicFactorKeys[kIdx] !== 'ALL' && node.data[billsUnitPriceFeature.feature.basicKeyOptions[kIdx].key] !== fm.basicFactorKeys[kIdx]) {
|
|
|
+ if (fm.basicFactorKeys[kIdx] !== 'ALL' && !_chkIfEquals(node.data[billsUnitPriceFeature.feature.basicKeyOptions[kIdx].key], fm.basicFactorKeys[kIdx])) {
|
|
|
isMatch = false;
|
|
|
break;
|
|
|
}
|
|
|
@@ -161,6 +175,77 @@ function chkAndResetBills() {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
function chkUnitPriceFeatureKeys(keys) {
|
|
|
let rst = false;
|
|
|
for (const subKey of keys) {
|