|
@@ -0,0 +1,186 @@
|
|
|
|
|
+/**
|
|
|
|
|
+ *
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author Tony Kang
|
|
|
|
|
+ * @date 2021/10/15
|
|
|
|
|
+ * @version
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+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' && 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' && 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 = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ node.updateData.fees.push({fieldName: 'common', unitFee: unitFeeVal, totalFee: 0, tenderUnitFee: unitFeeVal, tenderTotalFee: 0});
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+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;
|
|
|
|
|
+ for (let kIdx = 0; kIdx < bm.parentBasicKeys.length; kIdx++) {
|
|
|
|
|
+ if (bm.parentBasicKeys[kIdx] !== 'ALL' && node.data[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;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!isMatch) continue; //未匹配上,下一轮,无需继续
|
|
|
|
|
+ // 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' && node.data[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);
|
|
|
|
|
+ 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 chkUnitPriceFeatureKeys(keys) {
|
|
|
|
|
+ let rst = false;
|
|
|
|
|
+ for (const subKey of keys) {
|
|
|
|
|
+ let isPrjFeatureMatch = false;
|
|
|
|
|
+ for (let prjF of projectObj.project.projectInfo.property.projectFeature) {
|
|
|
|
|
+ if (prjF.key === subKey.key) {
|
|
|
|
|
+ if (prjF.value === subKey.value) {
|
|
|
|
|
+ isPrjFeatureMatch = true;
|
|
|
|
|
+ // isKeyMatch = true;
|
|
|
|
|
+ break;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //key相同而value不同,则无需再循环,直接退出
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (isPrjFeatureMatch) {
|
|
|
|
|
+ rst = true;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return rst;
|
|
|
|
|
+}
|