Просмотр исходного кода

改bug - 测试记录(序号1)

TonyKang 4 лет назад
Родитель
Сommit
c4c761cde6

+ 2 - 2
modules/main/routes/main_route.js

@@ -42,10 +42,10 @@ module.exports =function (app) {
                 }
 
                 let filter = {compilationId: req.session.sessionCompilation._id};
-                // let featureLibs = await billsUnitPriceFeatureFacade.findByCondition(filter,{feature:1},false);
+
                 let featureLibs = await billsUnitPriceFeatureFacade.findByCondition(filter,{_id:0},false);
+                // console.log(featureLibs);
 
-                console.log(featureLibs);
                 let billsUnitPriceFeature = (featureLibs && featureLibs.length > 0)?featureLibs[featureLibs.length - 1]:null;
         
                 res.render('building_saas/main/html/main.html',

+ 2 - 1
web/building_saas/main/html/main.html

@@ -2144,6 +2144,7 @@
     <script type="text/javascript" src="/web/building_saas/main/js/controllers/material_controller.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/side_tools.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/std_billsGuidance_lib.js"></script>
+    <script type="text/javascript" src="/web/building_saas/main/js/views/std_bills_unit_price_feature.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/std_bills_lib.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/std_ration_lib.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/block_lib.js"></script>
@@ -2186,7 +2187,7 @@
     <script src="/web/building_saas/standard_interface/index.js"></script>
     <script src="/web/building_saas/standard_interface/export/base.js"></script>
     <script src="/web/building_saas/standard_interface/export/view.js"></script>
-
+    
     <!-- endinject -->
 
     <% if (overWriteUrl != undefined) { %>

+ 16 - 0
web/building_saas/main/js/views/project_view.js

@@ -2652,10 +2652,21 @@ $('#property_ok').click(function () {
         properties['property.basicInformation'] = saveData;
     }
     //工程特征
+    let diffBillsPriceFeatureDatas = [];
     if(projFeatureView.toUpdate(projFeatureView.orgDatas, projFeatureView.datas)){
         let saveData = projFeatureView.toSaveDatas(projFeatureView.datas);
         projectObj.project.property.projectFeature = saveData;
         properties['property.projectFeature'] = saveData;
+        //内蒙古养估、广东农村等有些特征修改后,需要刷新指标基价(清单单价)
+        //*
+        if (billsUnitPriceFeature) {
+            for (let idx = 0; idx < projFeatureView.orgDatas.length; idx++) {
+                if (projFeatureView.orgDatas[idx].value !== projFeatureView.datas[idx].value) {
+                    diffBillsPriceFeatureDatas.push(projFeatureView.datas[idx]);
+                }
+            }     
+        }
+        //*/
     }
     // 清单限价
     const maxPriceRate = $('#max-price-rate') && +$('#max-price-rate').val();
@@ -2806,6 +2817,11 @@ $('#property_ok').click(function () {
             }
         });
     }
+
+    if (diffBillsPriceFeatureDatas.length > 0) {
+        //刷新指标基价
+        chkAndResetBills();
+    }
 });
 
 function testShow() {

+ 1 - 98
web/building_saas/main/js/views/std_billsGuidance_lib.js

@@ -220,7 +220,7 @@ const billsGuidance = (function () {
                 return;
             }
             let compareData = compareTree(parent, mainTreeFragment, selTree.roots);
-            _chkBillsUnitPrice(compareData.postData); //设置指标基价(默认单价)
+            chkAndSetBillsUnitPrice(compareData.postData); //设置指标基价(默认单价)
             let sheet = projectObj.mainSpread.getActiveSheet(),
                 row = sheet.getActiveColumnIndex(),
                 col = sheet.getActiveColumnIndex();
@@ -572,103 +572,6 @@ const billsGuidance = (function () {
             }
         }
     }
-
-    function _chkBillsUnitPrice(billsNodes) {
-        if (billsUnitPriceFeature !== null) {
-            for (const node of billsNodes) {
-                if (node.updateType === 'create') {
-                    //只有创建的才设置初始化单价
-                    const _chkKeys = function(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;
-                    };
-                    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 (_chkKeys(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 (_chkKeys(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});
-                }
-            }
-        }
-    }
-
     //项目指引类型
     const itemType = {
         job: 0,

+ 186 - 0
web/building_saas/main/js/views/std_bills_unit_price_feature.js

@@ -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;
+}