Browse Source

Merge remote-tracking branch 'origin/master'

vian 5 years ago
parent
commit
b76bc1d4fa

+ 2 - 1
modules/all_models/project_glj.js

@@ -130,7 +130,8 @@ let modelSchema = {
     originPlace:String,//产地
     vender:String, //厂家
     qualityGrace:String,//质量等级
-    brand:String//品牌
+    brand:String,//品牌
+    subList:[Schema.Types.Mixed]
 };
 mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false}));
 

+ 2 - 2
modules/main/controllers/ration_controller.js

@@ -29,9 +29,9 @@ let controller = {
         data = JSON.parse(data);
         let result = await ration_facade.addNewRation(data,req.session.sessionCompilation);
         //合并取项目工料机数据的情求,用于刷新项目工料机数据,当有添加、替换项目工料机的情况,才需要刷新
-        if(result.ration_gljs && result.ration_gljs.length > 0 && data.newData){
+       /* if(result.ration_gljs && result.ration_gljs.length > 0 && data.newData){
             result.projectGLJDatas =  await getProjectGLJData(data.newData.projectID);
-        }
+        }*/
         return result;
     },
     addMultiRation: async function (req) {

+ 11 - 6
modules/main/facade/bill_facade.js

@@ -80,10 +80,11 @@ module.exports={
         let [rationsAndRationGLJ,resultMap] = await Promise.all(pasteTasks);
 
         let gljController = new GLJController();
-        let projectGLJ = await gljController.getProjectGLJsByProjectID(data.projectID);
+       // let projectGLJ = await gljController.getProjectGLJsByProjectID(data.projectID);
         resultMap.rations = rationsAndRationGLJ.rations;
         resultMap.ration_gljs = rationsAndRationGLJ.new_ration_gljs;
-        resultMap.gljData = projectGLJ.data;
+        resultMap.projectGLJList = rationsAndRationGLJ.projectGLJList;
+       // resultMap.gljData = projectGLJ.data;
         return resultMap;
     },
     createNewBills:async function(newDatas){
@@ -150,7 +151,7 @@ async function pasteOtherData(data) {
 
 async function pasteRationsAndRationGLJ (rations,ration_gljs,compilation) {
     let projectGljModel = new GLJListModel();
-    let gljMap = {}, new_ration_gljs=[],projectID=null;
+    let gljMap = {}, new_ration_gljs=[],projectID=null,projectGLJList =[];
     if(rations.length > 0) projectID = rations[0].projectID;
     if(projectID==null && ration_gljs.length > 0) projectID = ration_gljs[0].projectID;
     if(projectID == null) return {rations:rations,new_ration_gljs:new_ration_gljs};
@@ -158,22 +159,24 @@ async function pasteRationsAndRationGLJ (rations,ration_gljs,compilation) {
     //先根据定额类型的工料机,插入到项目工料机中
     for(let r of rations){
         if(r.type == rationType.gljRation){
-            await getProjectGLJ(r,rationKeyArray,gljMap,unitFileId,ext);
+            let projectGLJ  = await getProjectGLJ(r,rationKeyArray,gljMap,unitFileId,ext);
+            projectGLJList.push(projectGLJ);
         }
     }
 
     for(let rg of ration_gljs){
-        await getProjectGLJ(rg,gljKeyArray,gljMap,unitFileId,ext);
+        let projectGLJ =  await getProjectGLJ(rg,gljKeyArray,gljMap,unitFileId,ext);
         let temRecord = ration_glj_facade.createNewRecord(rg);
         rg.rcode?temRecord.rcode = rg.rcode:'';
         rg.hasOwnProperty("customQuantity")?temRecord.customQuantity = rg.customQuantity:'';
         new_ration_gljs.push(temRecord);
+        projectGLJList.push(projectGLJ);
     }
 
     rations.length>0?await insertMany(rations,ration_Model):'';
     new_ration_gljs.length>0?await insertMany(new_ration_gljs,ration_glj_Model):'';
 
-    return {rations:rations,new_ration_gljs:new_ration_gljs};
+    return {rations:rations,new_ration_gljs:new_ration_gljs,projectGLJList:projectGLJList};
 
     async function getProjectGLJ (glj,keyArray,gljMap,unitFileId,ext) {
         let keyIndex = projectGljModel.getIndex(glj,keyArray);
@@ -186,6 +189,7 @@ async function pasteRationsAndRationGLJ (rations,ration_gljs,compilation) {
             gljMap[keyIndex] = pgljResult;
         }
         setResult(glj,pgljResult);
+        return pgljResult
     }
 
 
@@ -264,6 +268,7 @@ function generateBillTasks(data) {
 
 async function insertMany(datas,model) {
     let tem = [];
+    console.log(datas);
     while (datas.length>1000){//因为mongoose限制了批量插入的条数为1000.所以超出限制后需要分批插入
         let newList = datas.splice(0,1000);//一次插入1000条
         await model.insertMany(newList);

+ 5 - 3
modules/main/facade/ration_facade.js

@@ -212,7 +212,7 @@ async function replaceRation(nodeInfo,stdRation,defaultLibID,projectID,calQuanti
 
 async function addRationSubList(stdRation,newRation,needInstall,compilation,cleanzmhs=false) {
     let startTime = +new Date();
-    let ration_gljs = await addRationGLJ(stdRation,newRation,compilation);
+    let [ration_gljs,projectGLJList] = await addRationGLJ(stdRation,newRation,compilation);
     let addRationGLJTime = +new Date();
     console.log("添加定额工料机时间-----"+(addRationGLJTime - startTime));
     let ration_coes = await addRationCoe(stdRation,newRation,compilation);
@@ -232,7 +232,7 @@ async function addRationSubList(stdRation,newRation,needInstall,compilation,clea
         let t = await glj_calculate_facade.calculateQuantity({rationID:newRation.ID},true);
         newRation.adjustState = t.adjustState;
     }
-    return {ration:newRation,ration_gljs:ration_gljs,ration_coes:ration_coes,ration_installations:ration_installations,ration_templates:ration_template?[ration_template]:[]};
+    return {ration:newRation,ration_gljs:ration_gljs,ration_coes:ration_coes,ration_installations:ration_installations,ration_templates:ration_template?[ration_template]:[],projectGLJList:projectGLJList};
 }
 
 async function addRationInstallFee(std,newRation) {
@@ -399,6 +399,7 @@ function getExtendData(property,compilation) {
 async function addRationGLJ(std,newRation,compilation) {
     let newRationGLJList = [];
     let rationGLJShowList = [];
+    let projectGLJList = [];
     let unitPriceFileId = 0;
     let property = await projectDao.getProjectProperty(newRation.projectID);
     if(property){
@@ -468,6 +469,7 @@ async function addRationGLJ(std,newRation,compilation) {
                 newGLJ = ration_glj_facade.createNewRecord(info);
                 newRationGLJList.push(newGLJ);
                 rationGLJShowList.push(info);
+                projectGLJList.push(projectGLJ)
             }
             //let InfoFromProjectGLJ = +new Date();
             //console.log("找到项目工料机时间-------------------------------"+(InfoFromProjectGLJ - std_gljTime));
@@ -481,7 +483,7 @@ async function addRationGLJ(std,newRation,compilation) {
     let after = +new Date();
     console.log("实际插入时间为-------------------------------"+(after-before));
     console.log("总操作时间为-------------------------------"+(after-first));
-    return rationGLJShowList;
+    return [rationGLJShowList,projectGLJList]
 }
 
 async function deleRationSubRecode(projectID,rationID,cleanzmhs=false) {//删除挂在定额下的数据,如工程量明细,定额工料机等

+ 0 - 1
web/building_saas/css/style.css

@@ -63,7 +63,6 @@ font-size: 50px;
 border-radius: 0px;
 text-transform: uppercase;
 padding: 12px 30px;
-font-size: 12px;
 }
 .section {
 padding: 100px 0px;

+ 1 - 1
web/building_saas/main/html/main.html

@@ -109,7 +109,7 @@
                     </div>
                 </span>
                       <% } %>
-                    <a href="javascript:void(0)" class="btn btn-light btn-sm" id="insertRation" data-toggle="tooltip" data-placement="bottom" data-original-title="插入定额"><i class="fa fa-sign-in" aria-hidden="true"></i></a>
+                    <!--<a href="javascript:void(0)" class="btn btn-light btn-sm" id="insertRation" data-toggle="tooltip" data-placement="bottom" data-original-title="插入定额"><i class="fa fa-sign-in" aria-hidden="true"></i></a>-->
                     <!--2018-11-15 隐藏删除按钮   <a href="javascript:void(0)" class="btn btn-light btn-sm" id="delete" data-toggle="tooltip" data-placement="bottom" data-original-title="删除"><i class="fa fa-remove" aria-hidden="true"></i></a>-->
                     <a href="javascript:void(0)" class="btn btn-light btn-sm" id="upLevel" data-toggle="tooltip" data-placement="bottom" data-original-title="升级"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
                     <a href="javascript:void(0)"  class="btn btn-light btn-sm" id="downLevel" data-toggle="tooltip" data-placement="bottom" data-original-title="降级"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>

+ 2 - 2
web/building_saas/main/js/controllers/block_controller.js

@@ -362,8 +362,8 @@ let BlockController = {
             }
         }
         //更新项目工料机模块信息-计算消耗量
-        project.projectGLJ.datas = result.gljData;
-        project.projectGLJ.calcQuantity();
+      //  project.projectGLJ.datas = result.gljData;
+      //  project.projectGLJ.calcQuantity();
         for(let r of result.rations){
             if(r.type == rationType.gljRation){//对于工料机类型的定额,要重新设置下市场单价
                 gljOprObj.setGLJPrice(r);

+ 9 - 5
web/building_saas/main/js/models/project_glj.js

@@ -924,18 +924,21 @@ ProjectGLJ.prototype.calcTenderQuantity  = function (){
     gljUtil.calcProjectGLJQuantity(this.datas,rationGLJDatas,rationDatas,billsDatas,getDecimal("glj.quantity"),_,scMathUtil,true);
 };
 
-ProjectGLJ.prototype.loadNewProjectGLJToCaches = function (datas) {
+ProjectGLJ.prototype.loadNewProjectGLJToCaches = function (datas,calquantity = false) {
+    let gljIDMap = {};
     for (let d of datas){
-        this.loadNewProjectGLJToCache(d);
+        this.loadNewProjectGLJToCache(d,gljIDMap);
     }
+    if(calquantity)  this.calcQuantity();
 };
 
-ProjectGLJ.prototype.loadNewProjectGLJToCache = function (data) {//把新插入的项目工料机数据增加至缓存中
+ProjectGLJ.prototype.loadNewProjectGLJToCache = function (data,tIDMap) {//把新插入的项目工料机数据增加至缓存中
     let project_gljs = this.datas.gljList;
     let unitPriceMap = this.datas.unitPriceMap;
     let mixRatioMap = this.datas.mixRatioMap;
     let mixRatioConnectData = this.datas.mixRatioConnectData;
-    let tem =  _.find(project_gljs,{'id':data.id});
+    let IDMap = tIDMap?tIDMap:_.indexBy(project_gljs,'id');
+    let tem =  IDMap[data.id];
     if(tem) return; //判断该工料机是否已经存在,是的话不用再次添加
     //查看是否有组成物,有组成物的话先添加组成物信息
     data.ratio_data=[];
@@ -946,7 +949,7 @@ ProjectGLJ.prototype.loadNewProjectGLJToCache = function (data) {//把新插入
             mixRatioMap[ratio.connect_key]?mixRatioMap[ratio.connect_key].push(ratio):mixRatioMap[ratio.connect_key] = [ratio];
             let rIndex = gljUtil.getIndex(ratio);
             mixRatioConnectData[rIndex]?mixRatioConnectData[rIndex].push(ratio.connect_key):mixRatioConnectData[rIndex] = [ratio.connect_key];
-            this.loadNewProjectGLJToCache(s);
+            this.loadNewProjectGLJToCache(s,IDMap);
         }
         delete data.subList;
     }
@@ -954,6 +957,7 @@ ProjectGLJ.prototype.loadNewProjectGLJToCache = function (data) {//把新插入
     let uIndex = gljUtil.getIndex(data.unit_price);
     if(!unitPriceMap[uIndex])  unitPriceMap[uIndex] = data.unit_price;
     this.datas.gljList.push(data);
+    IDMap[data.id] = data;
 };
 
 class EvaluateList {

+ 35 - 38
web/building_saas/main/js/models/ration.js

@@ -431,23 +431,19 @@ var Ration = {
                        project.ration_glj.removeNodeByRation(recode.ration,projectObj.mainController);
                        project.Ration.deleteSubListOfRation(recode.ration,cleanzmhs);//删除旧定额下的相关记录
                        //添加新的记录
-                       project.Ration.addSubListOfRation(recode);
-
-
+                       project.Ration.addSubListOfRation(recode,false);
                        project.ration_glj.addToMainTree(recode.ration_gljs);
                    }
                 }
-                project.projectGLJ.loadData(function () {
-                    mbzm_obj.nodeChanged = true;//子目模板关联刷新
-                    gljOprObj.showDataIfRationSelect(projectObj.project.mainTree.selected,"-111111111");//这里第二个参数是为了使改前和改后selectedID不一样,删除了的话下方的定额工料机不会刷新
-                    project.calcProgram.calcNodesAndSave(refershNodes, async function () {
-                        await OVER_HEIGHT.reCalcOverHeightFee();
-                        await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(refershNodes);
-                    });
-                    projectObj.mainController.refreshTreeNode(refershNodes, true);
-                    $.bootstrapLoading.end();
+                project.projectGLJ.calcQuantity();
+                mbzm_obj.nodeChanged = true;//子目模板关联刷新
+                gljOprObj.showDataIfRationSelect(projectObj.project.mainTree.selected,"-111111111");//这里第二个参数是为了使改前和改后selectedID不一样,删除了的话下方的定额工料机不会刷新
+                project.calcProgram.calcNodesAndSave(refershNodes, async function () {
+                    await OVER_HEIGHT.reCalcOverHeightFee();
+                    await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(refershNodes);
                 });
-
+                projectObj.mainController.refreshTreeNode(refershNodes, true);
+                $.bootstrapLoading.end();
                 if(data.length < nodeInfo.length && nodeInfo[data.length].newCode!=null){//说明有部分定额编号没找到记录
                     alert('当前库中找不到定额"' + nodeInfo[data.length].newCode + '"');
                 }
@@ -522,7 +518,7 @@ var Ration = {
                     //更新缓存
                     for(let data of rstData){
                         me.datas.push(data.ration);
-                        me.addSubListOfRation(data);
+                        me.addSubListOfRation(data,false);
                         //插入树节点
                         newSource = data.ration;
                         newNode = project.mainTree.insert(billItemID, nextID, newSource.ID);
@@ -533,34 +529,34 @@ var Ration = {
                         newNode.data = newSource;
                         ProjectController.syncDisplayNewNode(sheetController, newNode);
                     }
-                    project.projectGLJ.loadData(function () {
-                        for(let data of rstData){
-                            project.ration_glj.addToMainTree(data.ration_gljs);
-                        }
-                        projectObj.mainController.refreshTreeNode(newNodes, false);
-                        if(project.Bills.isFBFX(newNodes[0])) { //判断是否属于分部分项工程 ,是的话才需要做计取安装费计算
-                            project.installation_fee.calcInstallationFee(function (isChange,rations) {
-                                if(isChange){
-                                    rations = rations.concat(newNodes);
-                                    project.calcProgram.calcNodesAndSave(rations);
-                                    itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(rations);
-                                }else {
-                                    project.calcProgram.calcNodesAndSave(newNodes);
-                                    itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(newNodes);
-                                }
-                            });
-                        }else {
-                            project.calcProgram.calcNodesAndSave(newNodes);
-                            itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(newNodes);
-                        }
-                        updateBillsOprRation();
+                    project.projectGLJ.calcQuantity();
+                    for(let data of rstData){
+                        project.ration_glj.addToMainTree(data.ration_gljs);
+                    }
+                    projectObj.mainController.refreshTreeNode(newNodes, false);
+                    if(project.Bills.isFBFX(newNodes[0])) { //判断是否属于分部分项工程 ,是的话才需要做计取安装费计算
+                        project.installation_fee.calcInstallationFee(function (isChange,rations) {
+                            if(isChange){
+                                rations = rations.concat(newNodes);
+                                project.calcProgram.calcNodesAndSave(rations);
+                                itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(rations);
+                            }else {
+                                project.calcProgram.calcNodesAndSave(newNodes);
+                                itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(newNodes);
+                            }
+                        });
+                    }else {
+                        project.calcProgram.calcNodesAndSave(newNodes);
+                        itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(newNodes);
+                    }
+                    updateBillsOprRation();
 
                         if(callback){
                             callback();
                         }
                         showLoding = false;
                         $.bootstrapLoading.end();
-                    });
+
                 })
             }
         };
@@ -653,7 +649,7 @@ var Ration = {
                         syncNodeOper(data);
                         if(callback) callback(newNode);
                     }else {
-                        if(data.projectGLJDatas) projectObj.project.projectGLJ.refreshByDatas(data.projectGLJDatas);
+                        //if(data.projectGLJDatas) projectObj.project.projectGLJ.refreshByDatas(data.projectGLJDatas);
                         syncNodeOper(data);
                         project.calcProgram.calcAndSave(newNode,async function () {
                             await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes([newNode]);
@@ -760,12 +756,13 @@ var Ration = {
             }
 
         };
-        ration.prototype.addSubListOfRation = function (data) {
+        ration.prototype.addSubListOfRation = function (data,calquantity = true) {
              project.ration_glj.addDatasToList(data.ration_gljs);
              project.ration_coe.addDatasToList(data.ration_coes);
              project.ration_installation.addDatasToList(data.ration_installations);
              project.ration_template.addDatasToList(data.ration_templates);
              project.quantity_detail.addDatasToList(data.quantity_details);
+             if(data.projectGLJList && data.projectGLJList.length > 0)  projectObj.project.projectGLJ.loadNewProjectGLJToCaches(data.projectGLJList,calquantity);
         };
 
         ration.prototype.replaceRation = function (ration, std) {

+ 11 - 12
web/building_saas/main/js/views/mbzm_view.js

@@ -186,7 +186,7 @@ let mbzm_obj={
             if(result.rationResult){
                 for(let rr of result.rationResult){
                     nodeDatas.ration.add.push(rr.ration);//定额datas数据的push在addNodes里面做
-                    projectObj.project.Ration.addSubListOfRation(rr);//添加定额子项缓存
+                    projectObj.project.Ration.addSubListOfRation(rr,false);//添加定额子项缓存
                 }
             }
             //对于新插入的清单:
@@ -203,18 +203,17 @@ let mbzm_obj={
                 }
                 projectObj.mainController.refreshTreeNode(refreshNodes, false);
             }
-            projectObj.project.projectGLJ.loadData(function () {
-                $.bootstrapLoading.end();
-                cbTools.refreshFormulaNodes();
-                //更新计算程序模板,并进行重新计算
-                if(parentsNodes.length > 0) calRations = calRations.concat(parentsNodes);//计算被删除的子目关联定额的父节点
-                projectObj.project.calcProgram.calcNodesAndSave(calRations,async function () {
-                    installationFeeObj.calcInstallationFee();
-                    await OVER_HEIGHT.reCalcOverHeightFee();
-                    await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(calRations);
-                });
-                mbzm_obj.showApplySuccess();
+            projectObj.project.projectGLJ.calcQuantity();
+            $.bootstrapLoading.end();
+            cbTools.refreshFormulaNodes();
+            //更新计算程序模板,并进行重新计算
+            if(parentsNodes.length > 0) calRations = calRations.concat(parentsNodes);//计算被删除的子目关联定额的父节点
+            projectObj.project.calcProgram.calcNodesAndSave(calRations,async function () {
+                installationFeeObj.calcInstallationFee();
+                await OVER_HEIGHT.reCalcOverHeightFee();
+                await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(calRations);
             });
+            mbzm_obj.showApplySuccess();
         })
     },
     showApplySuccess:function () {

+ 6 - 4
web/building_saas/pm/html/project-management.html

@@ -972,12 +972,14 @@
         <div class="modal-content">
             <div class="modal-header">
                 <h5 class="modal-title">欢迎使用大司空云计价</h5>
+                <button type="button" class="close text-danger" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                </button>
             </div>
             <div class="modal-body" id="welcomeBody">
-                <%- context %>
-            </div>
-            <div class="modal-footer text-xs-center">
-                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
+                <div style="max-height:465px">
+                    <%- context %>
+                </div>
             </div>
         </div>
     </div>