Explorar el Código

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

TonyKang hace 5 años
padre
commit
6734aee138

+ 8 - 2
modules/all_models/user.js

@@ -38,10 +38,16 @@ const userdList = mongoose.Schema({
 
 // 表结构
 let schema = {
-    ssoId: Number,
+    ssoId: {
+        type: Number,
+        unique: true
+    },
     username: String,
     email: String,
-    mobile: String,
+    mobile: {
+        type: String,
+        // unique: true
+    },
     qq: {
         type: String,
         default: ''

+ 7 - 7
modules/users/models/user_model.js

@@ -165,23 +165,23 @@ class UserModel extends BaseModel {
      * @return {Promise}
      */
     async markUser(userData, request = null) {
-        let userDataFromDb2 = await this.findDataBySsoId(userData.ssoId);
-        let userDataFromDb = await this.findDataByName(userData.username);  //后面新增的账号可淘汰这方法,当前使用是为了兼容旧的账号
+        let userDataFromDb = await this.findDataBySsoId(userData.ssoId);
+        // let userDataFromDb = await this.findDataByName(userData.username);  //后面新增的账号可淘汰这方法,当前使用是为了兼容旧的账号
         let result = false;
         userData.latest_login = new Date().getTime();
-        if (userDataFromDb === null && userDataFromDb2 === null) {
+        if (userDataFromDb === null) {
             // 不存在用户则入库
             this.setScene();//恢复场景,用户有可能公司real_name等信息为空,不能设置为必填
             result = await this.addUser(userData);
             userDataFromDb = result;
         } else {
             // 存在则新增登录信息并更新账号信息
-            // let condition = {ssoId: sessionUser.ssoId};
-            let condition = { username: userData.username };
+            let condition = {ssoId: userData.ssoId};
+            // let condition = { username: userData.username };
             let UpdateData = {
                 email: userData.email,
                 mobile: userData.mobile,
-                ssoId: userData.ssoId,
+                // ssoId: userData.ssoId,
                 qq: userData.qq,
                 latest_login: userData.latest_login,
                 isUserActive: userData.isUserActive,
@@ -387,7 +387,7 @@ class UserModel extends BaseModel {
 
     async getContacts(userID) {
         const user = await this.model.findOne({ _id: mongoose.Types.ObjectId(userID) }, 'contacts').lean();
-        if (!user) {
+        if (!user || !user.contacts || !user.contacts.length) {
             return [];
         }
         const userIDList = user.contacts.map(item => mongoose.Types.ObjectId(item.userID));

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

@@ -508,7 +508,7 @@ ProjectGLJ.prototype.freightCalc= function (glj,grossWeightCoe_n,dataMap,tfreigh
         loadingTimes = scMathUtil.roundForObj(loadingTimes,unitPirce);
         let s = scMathUtil.roundForObj(unitLoadingFee*loadingTimes,process);//装卸费单价×装卸次数
         t = scMathUtil.roundForObj(t + s,process);//单位运价×km运距×(1+运距增加率%)+装卸费单价×装卸次数
-        if(calcType == "内蒙古") t = scMathUtil.roundForObj(t/1.09,process);  //内蒙古要除以税率1.09;
+        if(gljUtil.isDef(materialType)&&materialType != "") t = scMathUtil.roundForObj(t/1.09,process);  //内蒙古要除以税率1.09; 当材料类型有值时,说明是内蒙古计算
         otherFee = scMathUtil.roundForObj(otherFee,unitPirce);
         t = scMathUtil.roundForObj(t+otherFee,process);//单位运价×km运距×(1+运距增加率%)+装卸费单价×装卸次数+其它费用
         t = scMathUtil.roundForObj(t*grossWeightCoe_n,process); //(单位运价×km运距×(1+运距增加率%)+装卸费单价×装卸次数+其它费用)×单位毛重”。 单位毛重:毛重系数
@@ -524,7 +524,7 @@ ProjectGLJ.prototype.freightCalc= function (glj,grossWeightCoe_n,dataMap,tfreigh
 
 
     function getPrice(unitFreight,kmDistance,conveyance,calcType,materialType,process){
-        if(calcType =="内蒙古") return materialCalcObj.calNeiMengTotalFreight(kmDistance,materialType);
+        if(gljUtil.isDef(materialType)&&materialType != "") return materialCalcObj.calNeiMengTotalFreight(kmDistance,materialType);
         //如果运输方式为自办运输,则直接返回单位运价即可;
         let price = conveyance == "自办运输" ? scMathUtil.roundForObj(unitFreight,process):scMathUtil.roundForObj(unitFreight * kmDistance,process);//单位运价×km运距
         return price
@@ -562,8 +562,8 @@ ProjectGLJ.prototype.priceCalc = function (glj,dataMap,tpriceList) {
     supplyLocation = supplyList.join(',');
     if(priceList.length == 0){//如果原价计算表没有数据,则读取输入的或单价文件的值
         let doc = dataMap['material']&&dataMap['material']['update']?dataMap['material']['update']:{};
-        original_price = doc['originalPrice']?doc['originalPrice']:glj.unit_price.originalPrice;
-        supplyLocation = doc['supplyLocation']?doc['supplyLocation']:glj.unit_price.supplyLocation;
+        original_price = doc['originalPrice']!==undefined?doc['originalPrice']:glj.unit_price.originalPrice;
+        supplyLocation = doc['supplyLocation']!==undefined?doc['supplyLocation']:glj.unit_price.supplyLocation;
     }
     return [scMathUtil.roundForObj(original_price,unitPriceHasMix),supplyLocation];
 };

+ 1 - 1
web/building_saas/main/js/models/ration.js

@@ -514,11 +514,11 @@ var Ration = {
                         newSource = data.ration;
                         newNode = project.mainTree.insert(billItemID, nextID, newSource.ID);
                         newNodes.push(newNode);
-                        nextID = project.mainTree.selected.getNextSiblingID();
                         newNode.source = newSource;
                         newNode.sourceType = project.Ration.getSourceType();
                         newNode.data = newSource;
                         ProjectController.syncDisplayNewNode(sheetController, newNode);
+                        nextID = project.mainTree.selected.getNextSiblingID();
                     }
                     project.projectGLJ.calcQuantity();
                     for(let data of rstData){

+ 1 - 1
web/building_saas/main/js/views/electrovalence_view.js

@@ -113,7 +113,7 @@ let electrovalenceObj = {
             let et = scMathUtil.roundForObj(d.electPrice * d.coe,getDecimal("process"));
             total = scMathUtil.roundForObj(et + total,getDecimal("process"));
         }
-        this.total = scMathUtil.roundForObj(total,getDecimal("glj.unitPrice"));
+        this.total = scMathUtil.roundForObj(total,getDecimal("glj.unitPriceHasMix"));
         $("#electrovalenceLabel").text(`综合电价:${this.total}`);
         return this.total;
     },

+ 8 - 1
web/building_saas/main/js/views/glj_view.js

@@ -718,12 +718,19 @@ var gljOprObj = {
                     ration_gljs[i].shortName =projectObj.project.projectGLJ.getShortNameByID(ration_gljs[i].type);
                     ration_gljs[i].isAdd = glj.unit_price.is_add;
                     ration_gljs[i]=this.setGLJPrice(ration_gljs[i],glj,false);//设置工料机价格
-                    delete ration_gljs[i].subList; //置空,再设置
                     let connect_index = this.getIndex(glj, gljKeyArray);
                     if (needRatio==true&&mixRatioMap.hasOwnProperty(connect_index)) {
                         let mixRatios = this.getMixRationShowDatas(mixRatioMap[connect_index], projectGljs);
                         ration_gljs[i].subList = mixRatios;
                     }
+                    if(needRatio == false){//不需要组成物的情况,目前应该是复制整块那里用到,这里加上毛重系数等信息,一起复制
+                      ration_gljs[i].grossWeightCoe = glj.unit_price.grossWeightCoe;
+                      ration_gljs[i].purchaseStorageRate = glj.unit_price.purchaseStorageRate;
+                      ration_gljs[i].offSiteTransportLossRate = glj.unit_price.offSiteTransportLossRate;
+                      ration_gljs[i].handlingLossRate = glj.unit_price.handlingLossRate
+                    }
+
+                    
                     if(ration) gljOprObj.getTotalQuantity(ration_gljs[i], ration);
                 }else {
                     //计算程序中量价也会放到这里进来,量价是没有对应的项目工料机的

+ 1 - 5
web/building_saas/main/js/views/main_tree_col.js

@@ -262,11 +262,7 @@ let MainTreeCol = {
             return false;
         },
         forUnit:function (node) {
-            if(MainTreeCol.readOnly.bills(node)&&(node.data.type==billType.DXFY||node.data.type==billType.FB)){//在大项费用、分部行,计量单位只读。
-                return true;
-            }else {
-                return calcTools.isRationItem(node);
-            }
+          return calcTools.isRationItem(node);
         },
         forContentCharacter: function (node) {
             return !MainTreeCol.readOnly.bills(node) || (node.data.type !== billType.BILL && node.data.type !== billType.FX);

+ 46 - 15
web/building_saas/main/js/views/material_calc_view.js

@@ -113,6 +113,7 @@ materialCalcObj = {
         this.materialSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onMaterialValueChange);
         this.materialSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onMaterialSelectionChange);
         this.materialSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onMaterialEditStarting);
+        this.materialSheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onMaterialRangeChange);
         this.materialSheet.name('material_calc');
         if(projectReadOnly){
             disableSpread(this.materialSpread);
@@ -369,7 +370,7 @@ materialCalcObj = {
                 }
                 if(dataCode == "unitFreight"){
                     if(freigth.rations && freigth.rations.length > 0) args.cancel = true;
-                    if(gljUtil.isDef(freigth.materialType) && freigth.materialType != "") args.cancel = true;//当材料类型有值时,说明是内蒙古计算,运费是过运距算出来的,不能编辑
+                    if(gljUtil.isDef(freigth.materialType) && freigth.materialType != "") args.cancel = true;//当材料类型有值时,说明是内蒙古计算,运费是过运距算出来的,不能编辑
                 }
             }
         }
@@ -404,21 +405,34 @@ materialCalcObj = {
 
     onMaterialValueChange:function (sender,args) {
         let me = materialCalcObj;
-        let dataCode = me.materialSetting.header[args.col].dataCode;
-        let value = args.newValue;
-        if (value&&!sheetCommonObj.checkData(args.col,me.materialSetting,value)) {
-            alert('输入的数据类型不对,请重新输入!');
-            me.showDatas();
-            return;
-        }
-        if(dataCode != 'supplyLocation'){
-            value = value?scMathUtil.roundForObj(value,getDecimal("glj.unitPrice"))+'':'0'//4舍五入加默认为0
+        let dataMap = {};
+        dataMap[args.row]={};
+        dataMap[args.row][args.col] = args.newValue;
+        me.updateMaterialCalcs(dataMap);
+    },
+    updateMaterialCalcs:function(dataMap){
+        let me = materialCalcObj;
+        let updateDatas = [];
+        for(let row in dataMap) {
+          let t = dataMap[row];
+          let doc = {};
+          let recode = me.materialDatas[row];
+          for (let col in t) {
+            let value = t[col];
+            let dataCode = me.materialSetting.header[col].dataCode;
+            if (value&&!sheetCommonObj.checkData(col,me.materialSetting,value)) {
+                alert('输入的数据类型不对,请重新输入!');
+                return me.showDatas();
+            }
+            if(dataCode != 'supplyLocation'){
+                value = value?scMathUtil.roundForObj(value,getDecimal("glj.unitPrice"))+'':'0'//4舍五入加默认为0
+            }
+            if(recode[dataCode] == value) continue;
+            doc[dataCode] = value;
+          }
+          if (!_.isEmpty(doc)) updateDatas.push({id:recode.id,doc:doc});
         }
-        let recode = me.materialDatas[args.row];
-        if(recode[dataCode] == value) return;
-        let doc = {};
-        doc[dataCode] = value;
-        projectObj.project.projectGLJ.updateMaterialCalc([{id:recode.id,doc:doc}]);
+        if(updateDatas.length > 0) projectObj.project.projectGLJ.updateMaterialCalc(updateDatas);
     },
     getDefualtCalcType:function () {
       return "全国";
@@ -473,6 +487,23 @@ materialCalcObj = {
         }
         return t;
     },
+    onMaterialRangeChange:function(sender,args){
+      let me = materialCalcObj;
+      let dataMap={};
+      for(let c of args.changedCells){
+        let info = {row:c.row,col:c.col,cancel:false};
+        me.onMaterialEditStarting(sender,info);
+        if(info.cancel) return me.showDatas();
+        let value=  args.sheet.getCell(c.row, c.col).text();
+        if(dataMap[c.row]){
+            dataMap[c.row][c.col]=value;
+        }else{
+            dataMap[c.row] ={};
+            dataMap[c.row][c.col] = value;
+        }
+      }
+      me.updateMaterialCalcs(dataMap);
+    },
     onFreightPriceRangeChange:function (sender,args) {
         let me = materialCalcObj;
         let dataMap={};

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

@@ -1151,6 +1151,19 @@ var projectObj = {
         me.mainSpreadEnterCell({type: 'EnterCell'}, {sheet: sheet, sheetName: sheet.name(), cancel: false, row: newRow, col: newCol});
 
     },
+    isInsertEquipmentVisable:function(selected){
+      //浙江不管是预算或者工程量清单,都是隐藏,overwrite文件重写   
+      if(this.project.property.valuationType =='bill' ){//属于预算项目的情况下,在固定清单可见
+        //属于的固定清单
+        let belongFlag = cbTools.getBelongFlag(selected);
+        if (belongFlag && belongFlag === fixedFlag.EQUIPMENT_ACQUISITION_FEE) {
+            return true;
+        }
+        return false; 
+      } 
+      return true
+    },
+
     loadMainSpreadContextMenu: function () {
         var project = this.project, spread = this.mainSpread, controller = this.mainController;
         let insertBillsName = project.projectInfo.property && project.projectInfo.property.valuationType == "bill"?"插入项目节":"插入清单";//右键“插入清单”改文字为“插入项目节”,工程量清单中保持不变。
@@ -1363,12 +1376,7 @@ var projectObj = {
                     },
                     visible: function(key, opt){//2018-11-08  新需求,这个按钮先隐藏,有需要再放开
                         let selected = project.mainTree.selected;
-                        //属于的固定清单
-                        let belongFlag = cbTools.getBelongFlag(selected);
-                        if (belongFlag && belongFlag === fixedFlag.EQUIPMENT_ACQUISITION_FEE) {
-                            return true;
-                        }
-                        return false;
+                        return projectObj.isInsertEquipmentVisable(selected);
                     }
                 },
                 "spr2": '--------',

+ 1 - 1
web/building_saas/pm/html/project-management.html

@@ -349,7 +349,7 @@
                             </select>
                         </div>
                     </div>
-                    <div class="form-group row">
+                    <div class="form-group row" id="tender-engineering-group">
                         <label for="staticEmail" class="col-auto col-form-label col-form-label-sm">养护类别</label>
                         <div class="col">
                             <select class="form-control  form-control-sm" id="tender-engineering">

+ 13 - 5
web/over_write/js/anhui_2019.js

@@ -54,13 +54,13 @@ function overwriteRationCalcBases() {
         { type: 'marketMaterial', name: '材料费' },
         { type: 'marketMachine', name: '施工机械使用费' },
         { type: 'marketMachineLabour', name: '施工机械人工费' },
-        // {type: 'marketEquipment', name: '设备购置费'},
+        {type: 'marketEquipment', name: '设备购置费'},
         { type: 'marketDirect', name: '直接费' },
 
         { type: 'labour', name: '定额人工费' },
         { type: 'material', name: '定额材料费' },
         { type: 'machine', name: '定额施工机械使用费' },
-        // {type: 'equipment', name: '定额设备购置费'},
+        {type: 'equipment', name: '定额设备费'},
         { type: 'direct', name: '定额直接费' },
 
         { type: 'measure', name: '措施费' },
@@ -68,8 +68,8 @@ function overwriteRationCalcBases() {
         { type: 'force', name: '规费' },
         { type: 'profit', name: '利润' },
         { type: 'tax', name: '税金' },
-        { type: 'common', name: '建装工程费' },
-        { type: 'rationCommon', name: '定额建装工程费' }//,
+        { type: 'common', name: '建安费' },
+        { type: 'rationCommon', name: '定额建安费' }//,
         // {type: 'safeProduce', name: '安全生产费'}
     ];
 })();
@@ -252,7 +252,7 @@ if (typeof baseFigureTemplate !== 'undefined' && baseFigureTemplate.budget) {
         // 养护项目信息化费 算法:以{定额建筑安装工程费}为基数,采用累进办法计算。(不足20000元时按20000元计算)
         YHXMXXHF(tender) {
             const baseFee = this['DEJZAZGCF'](tender);
-            const fee = cbTools.getProgressiveFee(baseFee, '信息化费');
+            const fee = cbTools.getProgressiveFee(baseFee, '养护项目信息化费');
             return fee > 0 && fee < 20000 ? 20000 : fee;
         },
         // 工程监理费 算法:以{定额建筑安装工程费(不含专项管理费) }为基数,采用累进办法计算。(不足20000元时按20000元计算)
@@ -294,4 +294,12 @@ if (typeof baseFigureTemplate !== 'undefined' && baseFigureTemplate.budget) {
         }
 
     };
+}
+
+// 安徽养护在新建分段的时候需要隐藏养护类别和费用标准
+if (typeof $ !== 'undefined') { // 后端也有引用这个文件,后端引用时$没有定义会报错
+    $(document).ready(function() {
+        $('#tender-engineering-group').hide();
+        $('#tender-feeStandard-group').hide();
+    });
 }

+ 8 - 0
web/over_write/js/zhejiang_2005.js

@@ -221,6 +221,14 @@ if(typeof materialCalcObj !== 'undefined'){
     }
 }
 
+if(typeof projectObj !== 'undefined'){
+  projectObj.isInsertEquipmentVisable = function(selected){
+    return false;   //浙江不管是预算或者工程量清单,都是隐藏   
+  }
+
+}
+
+
 
 if(typeof module !== 'undefined'){
     let _= require('lodash');

+ 5 - 1
web/users/js/login.js

@@ -266,7 +266,7 @@ $(document).ready(function () {
 });
 
 function login(captchaObj) {
-
+    $('#login').attr('disabled', true);
     let geetest_challenge = $('input[name="geetest_challenge"]').val();
     let geetest_validate = $('input[name="geetest_validate"]').val();
     let geetest_seccode = $('input[name="geetest_seccode"]').val();
@@ -315,19 +315,23 @@ function login(captchaObj) {
                 // captchaObj.reset();
                 $('#check_ssoId').val(response.ssoId);
                 $('#phone').modal('show');
+                $('#login').removeAttr('disabled');
             } else if(response.error === 3) {
                 // captchaObj.reset();
                 $('#phonepass').modal('show');
                 $('#mobileLogin').val(response.data);
+                $('#login').removeAttr('disabled');
             } else {
                 // $('#phonepass').modal('hide');
                 let msg = response.msg !== undefined ? response.msg : '未知错误';
                 showError(msg, $("input"));
+                $('#login').removeAttr('disabled');
                 // captchaObj.reset();
             }
         },
         error: function (result) {
             showError('内部程序错误', null);
+            $('#login').removeAttr('disabled');
         }
     });
 }