Преглед изворни кода

Merge branch 'master' of http://192.168.1.41:3000/SmartCost/YangHuCost

TonyKang пре 5 година
родитељ
комит
14955299a3

+ 13 - 0
config/config.js

@@ -56,6 +56,19 @@ module.exports = {
         },
         importURL:"172.18.111.231:2050"
     },
+    pp_out:{  server: "112.74.42.187",
+      port: "27017",
+      options:{
+          user:'smartcost',
+          pass:'SmartCost3850888',
+          auth: {
+              "authdb": "admin"
+          },
+          connectTimeoutMS: 50000,
+          useMongoClient: true
+      },
+      importURL:"112.74.42.187:2050"
+    },
     prod_s:{  server: "112.74.42.187",
         port: "28066",
         options:{

+ 1 - 0
config/gulpConfig.js

@@ -180,6 +180,7 @@ module.exports = {
         'web/building_saas/complementary_ration_lib/js/main.js',
         'web/building_saas/main/js/views/material_calc_view.js',
         'web/building_saas/main/js/views/electrovalence_view.js',
+        'web/building_saas/main/js/views/divide_view.js',
         'public/web/storageUtil.js'
     ],
     compleGlj_css: [

+ 6 - 6
modules/pm/models/project_model.js

@@ -199,7 +199,7 @@ ProjectsDAO.prototype.updateUserProjects = async function (userId, compilationId
                     }
                     //呈现选项
                     data.updateData.property.displaySetting = displaySetting;
-                    let defaultCalcMode = (data.updateData.property.valuationType == 'bill') ? 2 : 1;
+                    let defaultCalcMode = overWrite && overWrite.defaultCalcMode || ((data.updateData.property.valuationType == 'bill') ? 2 : 1);
                     data.updateData.property.billsCalcMode = defaultCalcMode;
                     data.updateData.property.zanguCalcMode = 0;
                     //计算选项
@@ -826,18 +826,18 @@ ProjectsDAO.prototype.defaultSettings = async function (userID, compilation, pro
         return false;
     }
     let cloneProperty = _.cloneDeep(project.property);
+    let overWrite;
+    if(compilation.overWriteUrl && compilation.overWriteUrl!=""){
+        overWrite = require("../../.."+compilation.overWriteUrl);
+    }
     //关于计算
-    let defaultCalcMode = (project.property.valuationType == 'bill') ? 2 : 1;
+    let defaultCalcMode = overWrite && overWrite.defaultCalcMode || ((project.property.valuationType == 'bill') ? 2 : 1);
     cloneProperty.billsCalcMode = defaultCalcMode;
     cloneProperty.zanguCalcMode = 0;
     cloneProperty.calcOptions = calcOptions;
     //清单工程量精度
     cloneProperty.billsQuantityDecimal = billsQuantityDecimal;
     //小数位数
-    let overWrite;
-    if(compilation.overWriteUrl && compilation.overWriteUrl!=""){
-        overWrite = require("../../.."+compilation.overWriteUrl);
-    }
     cloneProperty.decimal = overWrite && overWrite.defaultDecimal || defaultDecimal;
     //呈现选项
     cloneProperty.displaySetting = displaySetting;

+ 1 - 1
modules/ration_glj/controllers/ration_glj_controller.js

@@ -78,7 +78,7 @@ async function getGLJData(req, res) {
             libData.push({ name: '补充工料机', gljLibId: COMPLEMENTARY_LIB });
             if (gljLibId) { // 替换人材机初始化会触发此条件
                 const orgDefalutLib = libData.find(lib => lib.isDefault);
-                const newDefaultLib = libData.find(lib => lib.gljLibId === +gljLibId);
+                const newDefaultLib = libData.find(lib => lib.gljLibId === gljLibId);
                 if (orgDefalutLib && newDefaultLib) {
                     orgDefalutLib.isDefault = false;
                     newDefaultLib.isDefault = true;

+ 6 - 4
modules/users/facade/online_facade.js

@@ -12,7 +12,7 @@ let logs_model = mongoose.model("online_logs");
 
 async function getOnlineInfo(filter) {
     let datas = [];
-    let logs = await logs_model.find(filter);
+    let logs = await logs_model.find(filter, null, {sort:{_id:-1}});
     let less = 0;
     for(let l of logs){
         let d = getTimeString(l.online_times);
@@ -52,11 +52,13 @@ async function setOnlineTimes(userList,condition){
 
 
 function getTimeString(times) {
-    let s = "",perHour = 1000 * 60 * 60,perMin = 1000 * 60;
-    let hour = parseInt(times/perHour);
+    let s = "",perHour = 1000 * 60 * 60,perMin = 1000 * 60,perDay = 24*perHour;
+    let day = parseInt(times/perDay);
+    let hour = parseInt(parseInt(times % perDay) / perHour);
     let min = parseInt((times % perHour)/perMin);
     let less =  (times % perHour)%perMin;//不够一分钟的时间
+    if(day > 0) s = s+`${day}天`;
     if(hour > 0) s = s+`${hour}小时`;
     if(min > 0)  s= s+`${min}分钟`;
     return {s:s,less:less}
-}
+}

+ 9 - 4
web/building_saas/main/js/models/calc_program.js

@@ -528,13 +528,18 @@ let calcTools = {
             }
             else if (treeNode.data.type == rationType.gljRation){
                 let prc = 0;
-                if (treeNode.data.subType === gljType.EQUIPMENT && calcTools.inBase(baseName, 'SC_SBF'))
-                    prc = gljOprObj.getMarketPrice(treeNode)
+                // if (treeNode.data.subType === gljType.EQUIPMENT && calcTools.inBase(baseName, 'SC_SBF'))
+                //     prc = gljOprObj.getMarketPrice(treeNode)
+                // else
+                //     prc = gljOprObj.getBasePrice(treeNode);
+
+                if (baseName.includes('定额'))
+                    prc = gljOprObj.getBasePrice(treeNode)
                 else
-                    prc = gljOprObj.getBasePrice(treeNode);
+                    prc = treeNode.data.marketUnitFee ? parseFloat(treeNode.data.marketUnitFee).toDecimal(decimalObj.ration.unitPrice) : gljOprObj.getBasePrice(treeNode);
 
                 result = (prc * nodeQ).toDecimal(decimalObj.ration.unitPrice);
-            }
+            };
 
         }
         else if (treeNode.data.subType === gljType.GENERAL_MACHINE && calcTools.inBase(baseName, 'JSRGF')) {

+ 4 - 3
web/building_saas/main/js/models/project_glj.js

@@ -924,7 +924,7 @@ ProjectGLJ.prototype.getHighlandFee = function (feeType) {
     return rate*0.01
 };
 
-ProjectGLJ.prototype.calcEachFreightOrPrice = function (temp,type,priceMap) {//
+ProjectGLJ.prototype.calcEachFreightOrPrice = function (temp,type,priceMap,needUpdate=false) {//
     if(temp){
          if(type == "freight" && temp.conveyance !="自办运输") return null;
         let sum =0;
@@ -934,6 +934,7 @@ ProjectGLJ.prototype.calcEachFreightOrPrice = function (temp,type,priceMap) {//
         let decimal = type == "freight"?getDecimal("glj.unitPrice"):getDecimal("glj.unitPriceHasMix");
         //因为材料计算的数据是保存在单价文件里的,有可能存在共享的情况,这样的话就不能用单价文件里的项目工料机ID来匹配,要用5大项匹配
         let pgljMap = {};
+        if(needUpdate==false && (!temp.rations || temp.rations.length == 0))return null;//没有定额时不计算
         for(let pg of this.datas.gljList){
             pgljMap[gljUtil.getIndex(pg)] = pg
         }
@@ -952,7 +953,7 @@ ProjectGLJ.prototype.calcEachFreightOrPrice = function (temp,type,priceMap) {//
         }
         sum = scMathUtil.roundForObj(sum,decimal)+"";
         if(type == "freight"){
-          let exp = `((${expList.join("+")})+${temp.otherFee})x${temp.weightCoe}`
+          let exp = expList.length == 0?`${temp.otherFee}x${temp.weightCoe}`:`((${expList.join("+")})+${temp.otherFee})x${temp.weightCoe}`
           let ndoc = {};
           if(temp.unitFreight != sum) ndoc['unitFreight'] = sum;
           if(temp.exp != exp) ndoc['exp'] = exp;
@@ -999,7 +1000,7 @@ ProjectGLJ.prototype.calcEachFreightOrPrice = function (temp,type,priceMap) {//
             let hs = scMathUtil.roundForObj(tt*hightFeeRate,processDecimal);//(人工定额消耗量*定额价*定额工程量+机械定额消耗量*定额价*定额工程量)*高原取费类别费率
             exp = expList.join("+");
             if(hightFeeRate!=0) exp += `+${tt}x${hightFeeRate*100}%`;
-            if(assFeeRate!=0) exp += '+'+assList.join("+");
+            if(assFeeRate!=0 && assList.length > 0) exp += '+'+assList.join("+");
             result = scMathUtil.roundForObj(as + result,processDecimal);
             result = scMathUtil.roundForObj(hs + result,processDecimal);
             heightFee = hs;

+ 25 - 2
web/building_saas/main/js/views/fee_rate_view.js

@@ -178,7 +178,7 @@ var feeRateObject={
                     sheet.getCell(row, 0).cellType(treeType);
                     visibleMap[data[row].ID] = treeType.collapsed;
                     feeRateObject.setRowVisible(data,row,visibleMap,sheet);
-                } else if (col === 1 && commonUtil.isDef(data[row].originalRate) && data[row].originalRate !== +val) {
+                } else if (col === 1 && this.rateShouldMark(data[row], val)) {
                     sheet.getCell(row, col).foreColor('red');
                 }
             }
@@ -186,6 +186,29 @@ var feeRateObject={
         sheet.resumeEvent();
         sheet.resumePaint();
     },
+    rateShouldMark: function (rateItem, val) {
+        if (!rateItem) {
+            return false;
+        }
+        if (rateItem.rate === null) {
+            return false;
+        }
+        if (rateItem.sum) {
+            return false;
+        }
+        if (rateItem.subFeeRate) {
+            const selectedSubRate = rateItem.subFeeRate.recodes && rateItem.subFeeRate.recodes[0] ?
+                rateItem.subFeeRate.recodes[0].optionList.find(item => item.selected)
+                : null;
+            if (!selectedSubRate) {
+               return false;
+            }
+            const valInMap = rateItem.subFeeRate.valueMaps.find(item => item.ID === selectedSubRate.name);
+            return !!(valInMap && valInMap.value !== +val);
+        } else {
+            return commonUtil.isDef(rateItem.originalRate) && rateItem.originalRate !== +val;
+        }
+    },
     setRowVisible:function (data,row,visibleMap,sheet) {
         sheet.getRange(row , -1, 1, -1).visible(getVisible(data[row].ParentID));//显示或隐藏
         function getVisible(ParentID) {
@@ -542,7 +565,7 @@ var feeRateObject={
                         let col = _.findIndex(me.mainFeeRateSetting.header,{'dataCode':key});
                         me.mainFeeRateSheet.setValue(row, col, u.doc[key]);
                         if(key == 'rate'){
-                            const foreColor = commonUtil.isDef(rateItem.originalRate) && rateItem.originalRate !== +u.doc[key] ? 'red' : 'black';
+                            const foreColor = feeRateObject.rateShouldMark(rateItem, u.doc[key]) ? 'red' : 'black';
                             me.mainFeeRateSheet.getCell(row, col).foreColor(foreColor);
                             feerateInfo.push({rateID:u.rateID,value:u.doc[key]});
                         }

+ 3 - 3
web/building_saas/main/js/views/material_calc_view.js

@@ -455,7 +455,7 @@ materialCalcObj = {
          };
         return newData;
     },
-    getFreightEXP:function(obj,doc){
+    getFreightEXP:function(obj,doc,needUpdate){
       let item = _.clone(obj);
       if(doc) gljUtil.setProperty(item,doc);
       let material = materialCalcObj.getMaterialSelected();
@@ -465,7 +465,7 @@ materialCalcObj = {
       }
       //(单位运价×(1+运距增加率%)+装卸费单价×装卸次数+其它费用)×单位毛重×加权系数
       if(item.conveyance == "自办运输"){
-        let t = projectObj.project.projectGLJ.calcEachFreightOrPrice(item,"freight",{})
+        let t = projectObj.project.projectGLJ.calcEachFreightOrPrice(item,"freight",{},needUpdate);
         return t.doc.exp;
       }
 
@@ -599,7 +599,7 @@ materialCalcObj = {
                         let t_f = me.getSavedFreight(value, material);
                         if (t_f) doc = t_f;
                     }
-                    doc.exp = this.getFreightEXP(recode,doc);                            
+                    doc.exp = this.getFreightEXP(recode,doc,true);                            
                 }
             }
             if (!_.isEmpty(newData)) addDatas.push(newData);

+ 2 - 0
web/building_saas/main/js/views/project_glj_view.js

@@ -1179,6 +1179,7 @@ projectGljObject={
                         me.deleteMixRatio(row);
                     },
                     visible: function(key, opt){
+                        if(!$('#mixRatio-nav').hasClass('active')) return false;
                         let projectGLJ = projectGljObject.getProjectGLJSelected();
                         return  projectGLJ && !gljUtil.isConcreteType(projectGLJ.type);
                     }
@@ -1195,6 +1196,7 @@ projectGljObject={
                         getGLJData('addMix');
                     },
                     visible: function(key, opt){
+                        if(!$('#mixRatio-nav').hasClass('active')) return false;
                         let projectGLJ = projectGljObject.getProjectGLJSelected();
                         return  projectGLJ && !gljUtil.isConcreteType(projectGLJ.type);
                     }

+ 6 - 1
web/building_saas/main/js/views/project_view.js

@@ -1332,6 +1332,9 @@ var projectObj = {
                         return;
                     }
                     getGLJData('insert');// ProjectController.addRation(project, controller, rationType.volumePrice);
+                  },
+                  visible: function(key, opt){
+                    return false
                   }
                 },
                 "insertLJ": {
@@ -2637,9 +2640,11 @@ $('#property_ok').click(function () {
                 }
                 if(mixDatas.options && mixDatas.options.updateData){
                     let v1 = mixDatas.options.updateData['rationQuanACToBillsQuan'],
-                        v2 = mixDatas.options.updateData['rationQuanACToRationUnit'];
+                        v2 = mixDatas.options.updateData['rationQuanACToRationUnit'],
+                        progressiveType = mixDatas.options.updateData['progressiveType']  ;
                     optionsOprObj.updateOptions(optionsOprObj.options, {type: optionsOprObj.optionsTypes.GENERALOPTS, opt: 'rationQuanACToBillsQuan', value: v1});
                     optionsOprObj.updateOptions(optionsOprObj.options, {type: optionsOprObj.optionsTypes.GENERALOPTS, opt: 'rationQuanACToRationUnit', value: v2});
+                    optionsOprObj.updateOptions(optionsOprObj.options, {type: optionsOprObj.optionsTypes.GENERALOPTS, opt: 'progressiveType', value: progressiveType});
                 }
             }
         });

+ 17 - 13
web/building_saas/pm/js/pm_newMain.js

@@ -2052,10 +2052,12 @@ $(document).ready(function() {
             rename ? projectData['name'] = rename : '';
             projectMap['copy'] = { document: projectData };
             $("#copy-to-dialog").modal('hide');
-            $.bootstrapLoading.progressStart('拷贝项目', true);
-            $("#progress_modal_body").text('正在拷贝项目,请稍候……');
-            await ajaxPost('/pm/api/copyProjects', {projectMap:projectMap,user_id: userID, tenderCount: 1});
-            await importProcessChecking(null, null, (newProjectData) => handleTenderAfterChecking(newProjectData, projectData));
+            const copyRst = await ajaxPost('/pm/api/copyProjects', {projectMap:projectMap,user_id: userID, tenderCount: 1});
+            if (!copyRst.error) {
+                $.bootstrapLoading.progressStart('拷贝项目', true);
+                $("#progress_modal_body").text('正在拷贝项目,请稍候……');
+                await importProcessChecking(null, null, (newProjectData) => handleTenderAfterChecking(newProjectData, projectData));
+            }
         } catch (err) {
             alert(err);
         }
@@ -2093,15 +2095,17 @@ $(document).ready(function() {
             projectData['name'] = name;
             projectMap['copy'] = { document: projectData };
             //$("#save-as-dialog").modal('hide');
-            $.bootstrapLoading.progressStart('拷贝项目', true);
-            $("#progress_modal_body").text('正在拷贝项目,请稍候……');
-            await ajaxPost('/pm/api/copyProjects', {projectMap:projectMap,user_id: userID, tenderCount: 1});
-            await importProcessChecking(null, null, (newProjectData) => {
-                handleTenderAfterChecking(newProjectData, projectData);
-                if (newProjectData) {
-                    $('#save-as-dialog').modal('hide');
-                }
-            });
+            const copyRst = await ajaxPost('/pm/api/copyProjects', {projectMap:projectMap,user_id: userID, tenderCount: 1});
+            if (!copyRst.error) {
+                $.bootstrapLoading.progressStart('拷贝项目', true);
+                $("#progress_modal_body").text('正在拷贝项目,请稍候……');
+                await importProcessChecking(null, null, (newProjectData) => {
+                    handleTenderAfterChecking(newProjectData, projectData);
+                    if (newProjectData) {
+                        $('#save-as-dialog').modal('hide');
+                    }
+                });
+            }
         } catch (err) {
             alert(err);
         }

+ 5 - 1
web/over_write/js/nongcun_2020.js

@@ -129,9 +129,13 @@ if (typeof module !== 'undefined') {
         process: 6
     };
 
+    // 农村公路养护(2020),预算项目中,计算方式应默认为反算。(其他省份保持不变)
+    const defaultCalcMode = 1;
+
     module.exports = {
         progression: [],
         deficiency: {},
-        defaultDecimal
+        defaultDecimal,
+        defaultCalcMode
     };
 }