瀏覽代碼

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

vian 5 年之前
父節點
當前提交
53da0ab5d5

+ 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: ''

+ 6 - 6
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,

+ 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){

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

@@ -718,7 +718,6 @@ 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);

+ 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": '--------',

+ 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');
         }
     });
 }