浏览代码

Merge remote-tracking branch 'origin/master'

vian 5 年之前
父节点
当前提交
620eec4df0

+ 4 - 0
modules/import/controllers/import_controller.js

@@ -13,6 +13,10 @@ let controller = {
         let data = req.body;
         return await pm_facade.downLoadProjectFile(data);
     },
+    importChongqingProject:async function(req){
+        let data = req.body;
+        return await pm_facade.importChongqingProject(data);
+    },
     exportProject:async function(req){
         let result={
             error:0

+ 1 - 0
modules/import/routes/import_route.js

@@ -12,6 +12,7 @@ module.exports = function (app) {
     importRouter.post('/importInterface',importController.action);
     importRouter.post('/getDataForInterface',importController.action);
     importRouter.post('/loadSEIProjectData',importController.action);
+    importRouter.post('/importChongqingProject',importController.action);
     importRouter.get('/test',function (req,res) {
         res.json("hello word");
     })

+ 8 - 1
modules/main/facade/project_facade.js

@@ -295,7 +295,14 @@ async function updateNodes(datas){
                                 if(pn.data['property.areaSetting']) areaSetting = pn.data['property.areaSetting'];
                             }
                         }
-                        let t = await glj_calculate_facade.calculateQuantity({rationID:node.data.ID},true,false,node.data.areaIncreaseFee,areaSetting);
+                        let t = await glj_calculate_facade.calculateQuantity({rationID:node.data.ID},null,false,node.data.areaIncreaseFee,areaSetting);
+                        if(t.glj_result && t.glj_result.length > 0){//这里要更新工料机的消耗量,修改数据库的操作已经在上一步中完成了,现在只需刷新前端即可
+                           for(let gr of t.glj_result){
+                               let tdata = gr.doc;
+                               tdata.ID = gr.query.ID;
+                               datas.push({type:projectConsts.RATION_GLJ,data:tdata});
+                           }
+                        }
                         node.data.adjustState = t.adjustState;
                     }
                     if(node.action == "delete") deleteRationIDs.push(node.data.ID);

+ 15 - 0
modules/pm/controllers/pm_controller.js

@@ -813,6 +813,21 @@ module.exports = {
         }
         res.json(result);
     },
+    importChongqingProject:async function(req,res){
+        let data = JSON.parse(req.body.data);
+        let result={
+            error:0
+        };
+        try {
+            data.session = req.session;
+            result = await redirectToImportServer(data,"importChongqingProject",req);
+        }catch (err){
+            console.log(err);
+            result.error=1;
+            result.message = err.message;
+        }
+        res.json(result);
+    },
     importProcessChecking:async function (req,res) {
         let result={
             error:0

+ 34 - 0
modules/pm/facade/pm_facade.js

@@ -42,6 +42,7 @@ module.exports={
     initOverHeightItems: initOverHeightItems,
     uploadToken:uploadToken,
     downLoadProjectFile:downLoadProjectFile,
+    importChongqingProject:importChongqingProject,
     importProcessChecking:importProcessChecking,
     importInterface,
     isTenderOverrun,
@@ -1267,6 +1268,39 @@ async function isFirst(userId, compilationId) {
     return first;
 }
 
+async function importChongqingProject(data) {
+
+    let log_data = {
+        key:data.key,
+        userID:data.user_id,
+        status:"start",
+        create_time:+new Date()
+    };
+    await importLogsModel.create(log_data);
+    doImport(data.user_id,data.session.sessionCompilation._id,[13945,13952,13955],data.key);
+
+     return "start importing";
+
+    async function doImport(user_id,compilationId,projectIDs,key) {
+        let doc = {status:"finish"};
+        try {
+           let r = await copyExample(user_id,compilationId,projectIDs);
+           if(r == false){
+               doc.errorMsg = "导入失败,请检查项目是否存在!";
+               doc.status = "error";
+           }
+        }catch (error){
+            console.log(error);
+            doc.errorMsg = "导入失败,请检查项目是否存在!";
+            doc.status = "error";
+        }finally {
+            await importLogsModel.update({key:key},doc);
+        }
+    }
+}
+
+
+
 //用户第一次进入费用定额的数据准备
 async function prepareInitialData(userId, compilation, example) {
     let first = await isFirst(userId, compilation);

+ 1 - 0
modules/pm/routes/pm_route.js

@@ -65,6 +65,7 @@ module.exports = function (app) {
     pmRouter.post('/changeFile', pmController.changeFile);
     pmRouter.post('/exportProject', pmController.exportProject);
     pmRouter.post('/importProject', pmController.importProject);
+    pmRouter.post('/importChongqingProject', pmController.importChongqingProject);
     pmRouter.post('/importProcessChecking', pmController.importProcessChecking);
     pmRouter.post('/getBasicInfo', pmController.getBasicInfo);
     pmRouter.post('/getProjectFeature', pmController.getProjectFeature);

+ 27 - 6
modules/ration_glj/facade/glj_calculate_facade.js

@@ -41,6 +41,11 @@ let coeTypeMap = {
     "设备":5
 };
 
+let areaIncreaseMap = {
+    1:"labour",
+    2:"material",
+    3:"machine"
+};
 
 async function calculateQuantity(query,noNeedCal,refreshRationName = false,areaIncreaseFee,areaSetting){
     try {
@@ -58,6 +63,10 @@ async function calculateQuantity(query,noNeedCal,refreshRationName = false,areaI
              return null;
          }
         if(areaIncreaseFee !== null && areaIncreaseFee !== undefined) impactRation.areaIncreaseFee = areaIncreaseFee;
+        if(impactRation.areaIncreaseFee == true && !areaSetting){
+            let project =  await project_model.findOne({ID:impactRation.projectID},'property.areaSetting');
+            areaSetting = project.property.areaSetting;
+        }
          if(impactRation._doc.hasOwnProperty("rationAssList")&&impactRation.rationAssList.length>0){
              let temTimes = [];
              let thirdRationCodes=[];
@@ -85,7 +94,7 @@ async function calculateQuantity(query,noNeedCal,refreshRationName = false,areaI
          }
          gljList = sortRationGLJ(gljList);
          for(let i =0;i<gljList.length;i++ ){
-             let r = await calculateQuantityPerGLJ(gljList[i],gljList,coeList,assList,adjustState,noNeedCal);
+             let r = await calculateQuantityPerGLJ(gljList[i],gljList,coeList,assList,adjustState,noNeedCal,impactRation.areaIncreaseFee,areaSetting);
              if(quantityUpdateCheck(gljList[i],r) == true) result.glj_result.push(r);
          }
 
@@ -114,10 +123,6 @@ async function calculateQuantity(query,noNeedCal,refreshRationName = false,areaI
 }
 
 async function setAreaAdjustState(projectID,adjustState,areaSetting){
-    if(!areaSetting){
-        let project =  await project_model.findOne({ID:projectID},'property.areaSetting');
-        areaSetting = project.property.areaSetting;
-    }
     if(areaSetting){
         let stringArr = [];
         let labour = getStr(areaSetting.labour);
@@ -207,7 +212,7 @@ function sortRationGLJ(list) {
     return list;
 }
 
-async function calculateQuantityPerGLJ(glj,gljList,coeList,assList,adjustState,noNeedCal) {
+async function calculateQuantityPerGLJ(glj,gljList,coeList,assList,adjustState,noNeedCal,areaIncreaseFee,areaSetting) {
     let decimalObject =await decimal_facade.getProjectDecimal(glj.projectID);
     let decimal = (decimalObject&&decimalObject.glj&&decimalObject.glj.quantity)?decimalObject.glj.quantity:3;
     let quantity =  scMathUtil.roundTo(parseFloat(glj.quantity),-decimal);
@@ -235,6 +240,9 @@ async function calculateQuantityPerGLJ(glj,gljList,coeList,assList,adjustState,n
                 quantity = scMathUtil.roundToString(quantity,decimal);
                 quantity = calculateQuantityByCustomerCoes(quantity,customerCoe,glj,decimal);
             }
+            //计算面积增加费
+            if(areaIncreaseFee == true) quantity = calclateAreaIncrease(quantity,glj,areaSetting,decimal);
+
             result.doc.quantity =scMathUtil.roundToString(quantity,decimal);
             //2019-01-03 需求修改中间过程的价格不参与计算
             //glj.quantity = quantity;//这里保存中间过程计算出来的消耗量,后面处理“+*”操作符时要用到
@@ -246,6 +254,19 @@ async function calculateQuantityPerGLJ(glj,gljList,coeList,assList,adjustState,n
     }
 }
 
+function calclateAreaIncrease(quantity,glj,areaSetting,decimal){
+    if(areaSetting){
+        let atype = areaIncreaseMap[getRootGLJType(glj.type).ID];
+        if(atype && areaSetting[atype]){
+            quantity =  scMathUtil.roundForObj(quantity,decimal);
+            quantity = scMathUtil.roundToString(quantity * (1 + areaSetting[atype]/100 ),decimal)
+        }
+    }
+    return quantity
+}
+
+
+
 async function calculateAss(quantity,assList,glj) {
     for(let i=0;i<assList.length;i++){
         if(assList[i].assRation){

+ 1 - 1
public/web/tree_sheet/tree_sheet_helper.js

@@ -183,7 +183,7 @@ var TREE_SHEET_HELPER = {
                     cell.value(getFieldText2());
                 }
                 if (colSetting.data.cellType && Object.prototype.toString.apply(colSetting.data.cellType) !== "[object String]") {
-                    cell.cellType(colSetting.data.cellType(node,setting));
+                    cell.cellType(colSetting.data.cellType(node,setting,colSetting.data.field));
                 }
                 //树节点显示列
                 if(iCol == setting.treeCol) cell.cellType(TREE_SHEET_HELPER.getTreeNodeCellType(setting, sheet, node.tree,node));

+ 2 - 2
web/building_saas/main/js/models/calc_program.js

@@ -409,7 +409,7 @@ let calcTools = {
                         if (priceType == priceTypes.ptBasePrice){ price = me.uiGLJPrice(glj["basePrice"], glj);}
                         else if (priceType == priceTypes.ptAdjustPrice){price = aprice;}
                         else if (priceType == priceTypes.ptMarketPrice){price = mprice;}
-                        if (projectObj.project.property.areaSetting && treeNode.data.areaIncreaseFee){
+                        /*if (projectObj.project.property.areaSetting && treeNode.data.areaIncreaseFee){
                             let p;
                             if ([gljType.LABOUR].includes(glj.type))
                                 p = projectObj.project.property.areaSetting.labour
@@ -418,7 +418,7 @@ let calcTools = {
                             else if ([gljType.GENERAL_MACHINE].includes(glj.type))
                                 p = projectObj.project.property.areaSetting.machine;
                             qty = qty * (1 + p * 0.01).toDecimal(decimalObj.process);
-                        }
+                        }*/
 
                         temp = (qty * price).toDecimal(decimalObj.process);
                         result = (result + temp).toDecimal(decimalObj.process);

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

@@ -939,7 +939,7 @@ ProjectGLJ.prototype.loadNewProjectGLJToCache = function (data,tIDMap) {//把新
     let unitPriceMap = this.datas.unitPriceMap;
     let mixRatioMap = this.datas.mixRatioMap;
     let mixRatioConnectData = this.datas.mixRatioConnectData;
-    let IDMap = tIDMap?tIDMap:_.indexBy(project_gljs,'id');
+    let IDMap = !_.isEmpty(tIDMap)?tIDMap:_.indexBy(project_gljs,'id');
     let tem =  IDMap[data.id];
     if(tem) return; //判断该工料机是否已经存在,是的话不用再次添加
     //查看是否有组成物,有组成物的话先添加组成物信息

+ 13 - 8
web/building_saas/main/js/views/area_increase_fee_view.js

@@ -22,12 +22,7 @@ let areaIncreaseFeeObj = {
         setData(data.data,newval,fieldName);
         datas.push(data);
         setChildren(node,newval,datas);//同步设置所有子项
-        let nodes = await projectObj.project.syncUpdateNodesAndRefresh(datas);
-        projectObj.project.calcProgram.calcNodesAndSave(nodes,async function () {
-            await OVER_HEIGHT.reCalcOverHeightFee();
-            await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(nodes);
-        });
-
+        this.updateAndRefresh(datas);
 
         function setChildren(pnode,newValue,datas) {//同步设置所有子项
             if(pnode.children.length > 0 && (pnode.children[0].sourceType == ModuleNames.bills || pnode.children[0].sourceType == ModuleNames.ration)){//设置子项
@@ -36,6 +31,7 @@ let areaIncreaseFeeObj = {
                         type:c.sourceType,
                         data:{ID:c.data.ID}
                     };
+                    if(c.data.calcBase&&c.data.calcBase!="") continue;
                     setData(data.data,newval,fieldName);
                     datas.push(data);
                     setChildren(c,newValue,datas)
@@ -47,6 +43,16 @@ let areaIncreaseFeeObj = {
             if(fieldName == "outPutMaxPrice") data.maxPrice = null;
         }
     },
+    updateAndRefresh:async function(datas){
+        let nodes = await projectObj.project.syncUpdateNodesAndRefresh(datas);
+        projectObj.project.calcProgram.calcNodesAndSave(nodes,async function () {
+            await OVER_HEIGHT.reCalcOverHeightFee();
+            await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(nodes);
+        });
+        projectObj.project.projectGLJ.calcQuantity();
+        gljOprObj.refreshView();
+    },
+
     confirmAreaIncreaseFeeSetting:async function () {
         let labour = $("#areaIncreaseFee_labour").val();
         let material = $("#areaIncreaseFee_material").val();
@@ -75,8 +81,7 @@ let areaIncreaseFeeObj = {
         if(needUpdate){
             let datas = this.getAreaIncreaseDatas();
             datas.push(tem);
-            let nodes = await projectObj.project.syncUpdateNodesAndRefresh(datas);
-            projectObj.project.calcProgram.calcNodesAndSave(nodes);
+           this.updateAndRefresh(datas);
         }
 
         function settingNumCheck(value,type) {

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

@@ -251,7 +251,7 @@ var gljOprObj = {
         let selected = projectObj.project.mainTree.selected;
         if($.bootstrapLoading.isLoading())  args.cancel = true;
         if(selected){
-            if(me.isInstallationNode(selected)==true || OVER_HEIGHT.isOverHeight(selected)){
+            if(me.isInstallationNode(selected)==true || me.isItemIncreaseNode(selected)==true|| OVER_HEIGHT.isOverHeight(selected)){
                 args.cancel = true;
             }else {
                 if(args.sheetName == 'quantity_detail'){//工程量明细表
@@ -277,6 +277,12 @@ var gljOprObj = {
         }
         return false
     },
+    isItemIncreaseNode:function(node){//子目增加费节点
+        if(node.sourceType == ModuleNames.ration&&node.data.type == rationType.itemIncrease){//是定额安装费类型时只读,原先是补项的时候也是控制只读的||(node.sourceType == ModuleNames.bills&&node.data.type==billType.BX)){//是定额安装费类型或者补项
+            return true;
+        }
+        return false
+    },
     onEditEnded: function (sender, args) {
         var me = gljOprObj;
         if (args.sheetName == 'ration_glj') {

+ 9 - 6
web/building_saas/main/js/views/item_increase_fee_view.js

@@ -101,6 +101,7 @@ let itemIncreaseFeeObj = {
                 row:row
             };
             if(selectedItem && selectedItem.scope&&selectedItem.scope[tem.ID]) tem.selected = 1;
+            if(node.data.calcBase&&node.data.calcBase!="") delete tem.selected;//有基数计算的不可选
             this.scopeDatas.push(tem);
         }
         this.scopeSheet.setRowCount(this.scopeDatas.length);
@@ -119,11 +120,13 @@ let itemIncreaseFeeObj = {
         args.sheet.resumeEvent();
         args.sheet.resumePaint();
         function cascadeSelected(parent,val) {
-            args.sheet.getCell(parent.row, args.col).value(val);
-            parent.selected = val;
-            if(dataMap[parent.ID]){
-                for(let c of dataMap[parent.ID]){
-                    cascadeSelected(c,val);
+            if(gljUtil.isDef(parent.selected)){
+                args.sheet.getCell(parent.row, args.col).value(val);
+                parent.selected = val;
+                if(dataMap[parent.ID]){
+                    for(let c of dataMap[parent.ID]){
+                        cascadeSelected(c,val);
+                    }
                 }
             }
         }
@@ -382,7 +385,7 @@ let itemIncreaseFeeObj = {
                 total = scMathUtil.roundForObj(total,td);
                 if(s.coe){
                     let t = scMathUtil.roundForObj(total * s.coe/100,process);
-                    total =  scMathUtil.roundForObj(total + t,gd);
+                    total =  t;//scMathUtil.roundForObj(total + t,gd);
                 }
                 let seq = i+1;
                 let code = "ZMZJF_"+seq;

+ 7 - 2
web/building_saas/main/js/views/main_tree_col.js

@@ -418,9 +418,14 @@ let MainTreeCol = {
         mainBills:function (node) {
             if(MainTreeCol.mainBillsEnable(node)) return sheetCommonObj.getCheckBox(true);
         },
-        mainNodeCheckBox:function (node) {//分部分项、措施项目下的清单、定额
+        mainNodeCheckBox:function (node,setting,field) {//分部分项、措施项目下的清单、定额
             let Bills = projectObj.project.Bills;
-            if((Bills.isFBFX(node)||Bills.isMeasure(node)) && node.sourceType != ModuleNames.ration_glj) return sheetCommonObj.getCheckBox(false);
+            if((Bills.isFBFX(node)||Bills.isMeasure(node)) && node.sourceType != ModuleNames.ration_glj){
+                //有基数计算时面积增加费不可勾选
+                if(field == 'areaIncreaseFee' && node.data.calcBase && node.data.calcBase!="") return;
+                return sheetCommonObj.getCheckBox(false);
+            }
+
         },
         outPutMaxPrice:function (node) {
             if(MainTreeCol.mainBillsEnable(node)) {

+ 45 - 22
web/building_saas/pm/js/pm_newMain.js

@@ -4829,34 +4829,14 @@ $("#confirm-import").click(function() {
 
     async function  startImportProject(key) {
         try {
-            console.log("start Import");
             let result = await ajaxPost("/pm/api/importProject",{key:key,updateData:projTreeObj.getImportProjectDate()});
-            setTimeout(importProcessChecking,2000);
+            importProcessChecking(key);
         }catch (error){
             alert(error);
-            $.bootstrapLoading.end();
         }finally {
             STATE.importing = false;
         }
     }
-
-    async function importProcessChecking() {
-        let result = await ajaxPost("/pm/api/importProcessChecking",{key:key,user_id:userID});
-        if(result.error == 1){
-            let message = result.msg?result.msg:result.message;
-            setTimeout(function () {
-                $.bootstrapLoading.progressEnd();//不做这个的话太快,页面不会自动关闭
-            },500);
-            alert(message)
-        }else if(result.error == 0){
-            if(result.status == "processing"){
-                setTimeout(importProcessChecking,2000);
-            }else if(result.status == "complete"){
-                $.bootstrapLoading.progressEnd();
-                refreshAllPage();
-            }
-        }
-    }
 });
 
 $("#import_project_data").change(function(){
@@ -5040,6 +5020,49 @@ function refreshProjSummary(project, summaryInfo) {
     projTreeObj.refreshNodeData(refreshNodes);
 }
 
+
+
 $(function () {
     if(isShow)  $('#welcomePage').modal('show');//是否显示欢迎页
-});
+    $('#importChongqing').click(async function () {
+        if (STATE.importing) {
+            return;
+        }
+        STATE.importing = true;
+        $('#welcomePage').modal('hide');
+        try {
+            let key = uuid.v1();
+            $.bootstrapLoading.progressStart("欢迎使用大司空云计价",true);
+            $("#progress_modal_body").text("正在导入测评项目,请稍候……");
+            let result = await ajaxPost("/pm/api/importChongqingProject",{user_id: userID,key:key});
+            importProcessChecking(key);
+        }catch (error){
+            alert(error);
+        }finally {
+            STATE.importing = false;
+        }
+    })
+});
+
+async function importProcessChecking(key) {
+    setTimeout(checking,2000)
+    async function checking() {
+        let result = await ajaxPost("/pm/api/importProcessChecking",{key:key,user_id:userID});
+        if(result.error == 1){
+            let message = result.msg?result.msg:result.message;
+            setTimeout(function () {
+                $.bootstrapLoading.progressEnd();//不做这个的话太快,页面不会自动关闭
+            },500);
+            alert(message)
+        }else if(result.error == 0){
+            if(result.status == "processing"){
+                setTimeout(checking,2000);
+            }else if(result.status == "complete"){
+                $.bootstrapLoading.progressEnd();
+                refreshAllPage();
+            }
+        }
+    }
+
+
+}

+ 2 - 0
web/over_write/js/guangdong_2018.js

@@ -83,8 +83,10 @@ function overwriteRationCalcBases (){
         {type: 'mainMaterial', name: '主材费'},
         {type: 'equipment', name: '设备费'},
         {type: 'direct', name: '直接费'},
+        {type: 'measure', name: '措施项目费'},
         {type: 'manage', name: '管理费'},
         {type: 'profit', name: '利润'},
+        {type: 'tax', name: '税金'},
         {type: 'common', name: '工程造价'}
     ];
 })();