Jelajahi Sumber

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

zeweizhong 6 tahun lalu
induk
melakukan
2be2288f3e

+ 1 - 1
modules/all_models/calc_program_model.js

@@ -37,7 +37,7 @@ let stdCalcPrograms = new Schema({
 
 let projectCalcPrograms = new Schema({
     ID: String,
-    projectID: Number,
+    projectID: {type: Number, index: true},
     name: String,
     libID: Number,
     libName: String,

+ 1 - 1
modules/all_models/ration_glj.js

@@ -9,7 +9,7 @@ var ration_glj = new Schema({
     GLJID:Number,
     repositoryId:Number,
     projectID: {type: Number, index: true},
-    rationID:String,
+    rationID:{type: String, index: true},
     projectGLJID:Number,
     name:String,
     code:String,

+ 52 - 0
modules/users/controllers/cld_controller.js

@@ -161,6 +161,58 @@ class CLDController {
         const compilationList = await compilationModel.getList();
         response.json({error: 0, msg: 'success', data: compilationList});
     }
+
+    /**
+     * 获取个人和已使用编办信息
+     * @param request
+     * @param response
+     * @returns {Promise<void>}
+     */
+    async getUsersInfo(request, response) {
+        let ssoID = request.query.ssoID;
+        try {
+            //获取用户信息
+            if (ssoID === undefined) {
+                throw '传参有误';
+            }
+            let userModel = new UserModel();
+            let userData = await userModel.findDataBySsoId(ssoID);
+            if (userData === null || userData === '') {
+                throw '不存在该建筑用户';
+            }
+            userData = JSON.parse(JSON.stringify(userData));
+
+            userData.company_scale = userData.company_scale === null || userData.company_scale === undefined ? '' : userModel.companyScale[userData.company_scale] + '人';
+            userData.company_type = userData.company_type === null || userData.company_type === undefined ? '' : userModel.companyType[userData.company_type];
+            userData.province = userModel.province[userData.province];
+
+            let date = new Date(userData.create_time);
+            userData.create_time = date.getFullYear() + '年' +
+                (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '月' +
+                (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + '日';
+
+            //获取编办列表
+            let compilationModel = new CompilationModel();
+            let compilationList = JSON.parse(JSON.stringify(await compilationModel.getList()));
+            if (userData.upgrade_list !== undefined) {
+                let userUpgradeList = userData.upgrade_list;
+                for (let i in userUpgradeList) {
+                    let oneCompilationIndex = await compilationList.findIndex(function (item) {
+                        return item._id === userUpgradeList[i].compilationID;
+                    });
+                    if (oneCompilationIndex !== -1) {
+                        // compilationList[oneCompilationIndex].isUpgrade = userUpgradeList[i].isUpgrade;
+                        userData.upgrade_list[i].name = compilationList[oneCompilationIndex].name;
+                        userData.upgrade_list[i].description = compilationList[oneCompilationIndex].description;
+                        userData.upgrade_list[i].categoryID = compilationList[oneCompilationIndex].categoryID;
+                    }
+                }
+            }
+            response.json({error: 0, msg: 'success', data: { userInfo: userData }});
+        } catch (err) {
+            response.json({error: 1, msg: err});
+        }
+    }
 }
 
 export default CLDController;

+ 2 - 0
modules/users/routes/cld_route.js

@@ -24,5 +24,7 @@ module.exports = function (app) {
 
     router.post('/setUserUpgrade', cldController.setUsersUpgrade);
 
+    router.get('/getUsersInfo', cldController.getUsersInfo);
+
     app.use('/cld',router)
 };

+ 13 - 2
web/building_saas/main/js/models/project_glj.js

@@ -677,8 +677,19 @@ ProjectGLJ.prototype.updateUserFreight =async function (data) {
     try {
         $.bootstrapLoading.start();
         let result = await ajaxPost('/glj/updateUserFreight',data);
-       // this.refreshMaterialCalcCache(sumMap);
-        //materialCalcObj.showDatas();
+        if(data.action == "add"){
+            for(let f of data.freights){
+                materialCalcObj.userFreightList.push(f);
+            }
+        }
+        if(data.action == "update"){
+            for(let u of materialCalcObj.userFreightList){
+                if(u.ID == data.ID){
+                    gljUtil.updateProperty(u,data.doc);
+                }
+            }
+        }
+        materialCalcObj.showFreightDatas();
     }catch (e){
         console.log(e)
     }finally {

+ 92 - 21
web/building_saas/main/js/views/material_calc_view.js

@@ -45,8 +45,8 @@ materialCalcObj = {
             {headerName: "运价增\n加率(%)", headerWidth: 60, dataCode: "freightIncreaseRate", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
             {headerName: "加权\n系数", headerWidth: 60, dataCode: "weightCoe", hAlign: "right", dataType: "Number",validator:"number"},
             {headerName: "计算式", headerWidth: 170, dataCode: "exp", hAlign: "left", dataType: "Number",getText:'forExp'},//,decimalField:"glj.unitPrice"
-            {headerName: "计算方式", headerWidth: 80, dataCode: "calcType", dataType: "String",cellType:"comboBox",options:["全国","内蒙古"]},
-            {headerName: "材料类型", headerWidth: 80, dataCode: "materialType", dataType: "String",cellType:"comboBox",options:["地方材料","外购材料","沥青、燃料等"]}
+            {headerName: "计算方式", headerWidth: 80, dataCode: "calcType",visible: false, dataType: "String",cellType:"comboBox",options:["全国","内蒙古"]},
+            {headerName: "材料类型", headerWidth: 80, dataCode: "materialType", visible: false,dataType: "String",cellType:"comboBox",options:["","地方材料","外购材料","沥青、燃料等"]}
         ],
         view: {
             lockColumns: ["exp"],
@@ -55,7 +55,7 @@ materialCalcObj = {
         getText:{
             forExp:function (item) {
                 let material = materialCalcObj.getMaterialSelected();
-                if(item.calcType == "内蒙古"){
+                if(gljUtil.isDef(item.materialType)&&item.materialType != ""){
                   let uString = materialCalcObj.getNeiMengUnitFreightString(item.kmDistance,item.materialType);
                   return `((${uString}x(1+${item.freightIncreaseRate}%)+${item.unitLoadingFee}x${item.loadingTimes})/1.09+${item.otherFee})x${material.grossWeightCoe_n}x${item.weightCoe}`;
                 }
@@ -191,8 +191,6 @@ materialCalcObj = {
         let startCol = _.findIndex(this.freightSetting.header,{'dataCode':'start'});
         let startOptions = this.getUserFreightOptions();
         sheetCommonObj.setComboBox(-1,startCol,this.freightSheet,startOptions,false,true);
-
-
         sel.row =  oldData?_.findIndex(this.freightDatas,{'ID':oldData.ID}):sel.row ;
         this.freightSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
         this.refreshRationView();
@@ -346,10 +344,10 @@ materialCalcObj = {
         }else {
             let freigth = me.freightDatas[args.row];
             let dataCode = me.freightSetting.header[args.col].dataCode;
-            if(dataCode == "calcType" || dataCode=="materialType"){
+            if(dataCode=="materialType"){
                 if(!freigth){
                     args.cancel = true;
-                }else if(dataCode == "materialType" && freigth.calcType !="内蒙古"){//不是内蒙古的情况下,下拉框不可编辑
+                }else if(freigth.conveyance !="汽车"){//只有在汽车的情况下,材料类型列才能编辑
                     args.cancel = true;
                 }
             }
@@ -359,7 +357,7 @@ materialCalcObj = {
                 }
                 if(dataCode == "unitFreight"){
                     if(freigth.rations && freigth.rations.length > 0) args.cancel = true;
-                    if(freigth.calcType == "内蒙古") args.cancel = true;
+                    if(gljUtil.isDef(freigth.materialType) && freigth.materialType != "") args.cancel = true;//当材料类型有值时,说明是内蒙古计算,运费是能过运距算出来的,不能编辑
                 }
             }
         }
@@ -426,10 +424,41 @@ materialCalcObj = {
              freightIncreaseRate:'0',//运价增加率
              weightCoe:'1',//加权系数
              connect_key:gljUtil.getIndex(material),
+             materialType:"",
              unit_price_file_id:material.unit_price.unit_price_file_id
-         }
+         };
         return newData;
     },
+    getSavedFreight:function (start,material) {
+        let t = null;
+        for(let f of this.userFreightList){
+            if(f.freight.start == start){
+                t = newDatas(f.freight,material);
+                break;
+            }
+        }
+        return t;
+        function newDatas(freight,material) {
+            let doc = {};
+            for(let key in freight){
+                doc[key] = freight[key];
+                if(key == "ID") doc[key] = uuid.v1();
+                if(key == "connect_key") doc[key] = gljUtil.getIndex(material);
+                if(key == "unit_price_file_id") doc[key] = material.unit_price.unit_price_file_id;
+            }
+            return doc;
+        }
+    },
+    checkSavedFreight:function (start) {
+        let t = null;
+        for(let f of this.userFreightList){
+            if(f.freight.start == start){
+                t = f;
+                break;
+            }
+        }
+        return t;
+    },
     onFreightValueChange:function (sender,args) {
         let me = materialCalcObj;
         let dataCode = me.freightSetting.header[args.col].dataCode;
@@ -444,10 +473,17 @@ materialCalcObj = {
             value = value?scMathUtil.roundForObj(value,getDecimal("glj.unitPrice"))+'':'0'//4舍五入加默认为0
         }
         if(args.row >= me.freightDatas.length){//新增
-            let newData = me.getNewFreightData(material);
-            newData[dataCode] = value;
-            newData.calcType = me.getDefualtCalcType();
-            if(newData.calcType == "内蒙古") newData.materialType = "地方材料";
+            let newData = {};
+            let tempFreight = null;
+            if(dataCode == "start"){
+                tempFreight = me.getSavedFreight(value,material);
+            }
+            if(tempFreight){
+                newData = tempFreight;
+            }else {
+                newData = me.getNewFreightData(material);
+                newData[dataCode] = value;
+            }
             projectObj.project.projectGLJ.addFreightCalc([newData],material.id);
         }else {//修改
             let recode = me.freightDatas[args.row];
@@ -465,17 +501,24 @@ materialCalcObj = {
                     doc["loadingTimes"] = '0';
                     doc["freightIncreaseRate"] = '0';
                 }
+                if(args.oldValue =="汽车") doc["materialType"] = "";//当运输方式从汽车切换成其它方式时,清空材料类型
+
             }
-            if(dataCode == "calcType"){
+          /*  if(dataCode == "calcType"){
                 if(value == "全国") doc["materialType"] = "";
                 if(value == "内蒙古"){
                     doc["materialType"] = "地方材料";
                     doc["unitFreight"] = me.calcNeiMengUnitFreight(recode.kmDistance,"地方材料");
                 }
-            }
-            if(recode.calcType == "内蒙古"){
-                if(dataCode == "materialType") doc["unitFreight"] = me.calcNeiMengUnitFreight(recode.kmDistance,value);
-                if(dataCode == "kmDistance") doc["unitFreight"] = me.calcNeiMengUnitFreight(value,recode.materialType);
+            }*/
+
+            if(dataCode == "materialType" && value!="") doc["unitFreight"] = me.calcNeiMengUnitFreight(recode.kmDistance,value);
+            if(dataCode == "kmDistance" && gljUtil.isDef(recode.materialType)&&recode.materialType!="") doc["unitFreight"] = me.calcNeiMengUnitFreight(value,recode.materialType);
+
+            if(dataCode == "start"){
+               let t_f = me.getSavedFreight(value,material);
+               if(t_f) doc = t_f;
+
             }
             projectObj.project.projectGLJ.updateFreightCalc([{ID:recode.ID,doc:doc}],material.id);
         }
@@ -640,10 +683,20 @@ materialCalcObj = {
 
     },
     saveFreight:function (row) {
+        let me = this;
         let record = this.freightDatas[row];
         if(record){
-            console.log(record);
-            //to do 检查是否已经存在,存在给出是否覆盖提示
+            let exist = this.checkSavedFreight(record.start);
+            if(exist){//已存在的情况,更新
+                let info =`起讫地点“${record.start}”已存在,是否覆盖?`;
+                //to do 检查是否已经存在,存在给出是否覆盖提示
+                hintBox.infoBox('操作确认', info, 2, function () {
+                    me.updateUserFreight(record,exist)
+                }, function () {
+                    //
+                },['确定','取消'],false);
+                return true;
+            }
             let user_freight = {rootProjectID:projectObj.project.projectInfo.property.rootProjectID};
             let f = {};
             for(let key in record){
@@ -653,9 +706,27 @@ materialCalcObj = {
             user_freight.freight = f;
             projectObj.project.projectGLJ.updateUserFreight({freights:[user_freight],action:"add"});
         }
+    },
+
+    updateUserFreight:function (record,userFreight) {
+        let t  = {};
+        for(let t_key in userFreight){
+            if(t_key == "ID") continue;
+            t[t_key] = userFreight[t_key];
+        }
+
+        t.rootProjectID = projectObj.project.projectInfo.property.rootProjectID;
+        let f = {};
+        for(let key in record){
+            f[key] = record[key];
+            if(key =="ration" || key == "ration_gljs")f[key] = [];//下面的定额和工料机不用保存
+        }
+        t.freight = f;
+        projectObj.project.projectGLJ.updateUserFreight({ID:userFreight.ID,doc:t,action:"update"});
 
     },
 
+
     getSideResize: function () {
         let rg_sideResizeEles = {};
         rg_sideResizeEles.eleObj = {
@@ -685,7 +756,7 @@ materialCalcObj = {
                     name: "内蒙古计算",
                     icon: 'fa-sign-in',
                     visible:function () {
-                        return id == "freightSheet";
+                        return false;//2019-11-17 改成不需要右键插入功能    id == "freightSheet";
                     },
                     disabled: function (){
                        let material = me.getMaterialSelected();

+ 2 - 3
web/over_write/js/neimeng_2019.js

@@ -251,7 +251,6 @@ if (typeof baseFigureTemplate !== 'undefined' && baseFigureTemplate.budget) {
 if(typeof materialCalcObj !== 'undefined' && materialCalcObj.rationSetting){
     let h =_.find(materialCalcObj.rationSetting.header,{"dataCode":"feeType"});
     if(h) h.visible = true;
-    materialCalcObj.getDefualtCalcType = function () {
-        return "内蒙古";
-    }
+    let mt = _.find(materialCalcObj.freightSetting.header,{"dataCode":"materialType"});
+    if(mt) mt.visible = true;
 }