Browse Source

Merge branch 'master' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost

chenshilong 7 years ago
parent
commit
04808a8dd5

+ 2 - 1
modules/common/base/base_controller.js

@@ -60,11 +60,12 @@ class BaseController {
         // 获取当前用户消息数量
         let userMessageModel = new UserMessageModel();
         // 消息处理
+        console.log(`sessionUser`);
+        console.log(sessionUser);
         await userMessageModel.initMessage(sessionUser.id);
         // 获取未读数据
         let messageUnreadCount = await userMessageModel.count({user_id: sessionUser.id, is_read: 0, is_delete: 0});
         response.locals.unreadCount = messageUnreadCount;
-
         next();
     }
 }

+ 2 - 0
modules/complementary_ration_lib/models/compleRationModel.js

@@ -141,6 +141,7 @@ class CompleRatoinDao {
     //造价书定额库
     async getRationGljItemsBySection(userId, sectionId, callback){
         try{
+            const perHintHeight = 17.2;
             let stdRations = await stdRationModel.find({sectionId: sectionId, $or: [{isDeleted: null}, {isDeleted: false}]});
             for(let ration of stdRations){
                 ration._doc.type = 'std';
@@ -176,6 +177,7 @@ class CompleRatoinDao {
                     }
                 }
                 ration._doc.hint = hint;
+                ration._doc.hintHeight = ration.rationGljList.length * perHintHeight;//控制定额库悬浮提示位置
             }
             callback(0, rations);
         }

+ 28 - 8
modules/main/controllers/bills_controller.js

@@ -200,7 +200,7 @@ module.exports = {
                 if (sheet[0] === undefined || sheet[0].data === undefined) {
                     throw 'excel没有对应数据';
                 }
-                //导入的数据是否含有固定行(分部分项、施工技术措施项目、施工组织措施项目)
+                //导入的数据是否含有固定行(分部分项、施工技术措施项目、施工组织措施项目,通过文件名判断)
                 let flag = getImportFlag(file.originalFilename);
                 if(!flag){
                     throw 'excel数据错误';
@@ -232,6 +232,8 @@ module.exports = {
                     await billsData.model.create(insertFixedBill);
                     fixedBill = insertFixedBill;
                 }
+                console.log(`fixedBill--------------`);
+                console.log(fixedBill);
                 //匹配的清单库
                 const billsLibId = fields.billsLibId !== undefined && fields.billsLibId.length > 0 && fields.billsLibId[0]? parseInt(fields.billsLibId[0]) : null;
                 let stdBills = [], stdJobs = [], stdCharacters = [];
@@ -241,7 +243,7 @@ module.exports = {
                     stdCharacters = await stdBillCharacterModel.find({billsLibId: billsLibId, deleted: false});
                 }
                 //将excel数据转换成清单树结构数据
-                let insertDatas = parseToBillData(getValidImportData(sheet[0].data), getColMapping(sheet[0].data), fixedBill, projectID, {stdBills: stdBills, stdJobs: stdJobs, stdCharacters: stdCharacters});
+                let insertDatas = parseToBillData(getValidImportData(sheet[0].data, fixedBill), getColMapping(sheet[0].data), fixedBill, projectID, {stdBills: stdBills, stdJobs: stdJobs, stdCharacters: stdCharacters});
                 //删除相关数据
                 let deleteDatas = await billsData.deepDeleteBill([fixedBill], req.session.sessionUser.id);
                 //新增清单数据
@@ -305,8 +307,10 @@ function rowExistData(rowData){
     }
     return false;
 }
-//提取excel表数据中的有效数据(去表头表尾,提取其中的excel数据)
-function getValidImportData(sheetData){
+//提取excel表数据中的有效数据(去表头表尾,提取其中的excel数据)(根据fixedBill获取栏头占行数)
+function getValidImportData(sheetData, fixedBill){
+    console.log(`sheetData`);
+    console.log(sheetData);
     let withingD = false;
     let validData = [];
     for(let r = 0; r < sheetData.length; r++){
@@ -317,7 +321,9 @@ function getValidImportData(sheetData){
             //表头
             if(rData[0] === '序号'){
                 withingD = true;
-                r++;
+                if(fixedBill.name !== '施工组织措施项目'){
+                    r++;
+                }
                 continue;
             }
             //表尾
@@ -325,10 +331,16 @@ function getValidImportData(sheetData){
                 withingD = false;
             }
         }
+        /*console.log(`rData`);
+        console.log(rData);
+        console.log(withingD);
+        console.log(rowExistData(rData));*/
         if(withingD && rowExistData(rData)){
             validData.push(rData);
         }
     }
+    /*console.log(`validData`);
+    console.log(validData);*/
     return validData;
 }
 
@@ -358,7 +370,7 @@ function parseToBillData(validData, colMapping, fixedBill, projectID, stdData){
     }
     //续数据,上一行数据是有效节点且无序号
     function isExtend(preData, rData){
-        return preData && (isRoot(preData) || isLeaf(preData)) && (rData[colMapping.serialNo] === undefined || rData[colMapping.serialNo] === '');
+        return preData && (isRoot(preData) || isLeaf(preData)) &&  !isRoot(rData) && (rData[colMapping.serialNo] === undefined || rData[colMapping.serialNo] === '');
     }
     function getBillType(rData, flag){
         if(flag === fixedFlag.CONSTRUCTION_TECH || flag === fixedFlag.CONSTRUCTION_ORGANIZATION){
@@ -371,12 +383,14 @@ function parseToBillData(validData, colMapping, fixedBill, projectID, stdData){
     }
     //excel数据与标准库数据匹配,根据清单前九位编码匹配,匹配成功则获取标准清单对应的工程专业、特征及内容
     function matchStdBill(excelBill, stdData){
+        let isMatch = false;
         let regExp = /^\d{12}$/g;
         if(regExp.test(excelBill.code)){
             let nineCode = excelBill.code.substr(0, 9);
             for(let stdBill of stdData.stdBills){
                 //set programID
                 if(nineCode == stdBill.code){
+                    isMatch = true;
                     excelBill.programID = stdBill.engineering ? stdBill.engineering : null;
                     //set jobContent and itemCharacter
                     let tempJob = [], tempCharacter = [];
@@ -403,6 +417,9 @@ function parseToBillData(validData, colMapping, fixedBill, projectID, stdData){
                 }
             }
         }
+        if(!isMatch && excelBill.type === billType.FX){//分项在标准清单中不匹配,则识别为补项
+                excelBill.type = billType.BX;
+        }
     }
     for(let r = 0; r < validData.length; r++){
         let preData = validData[r-1],
@@ -450,8 +467,9 @@ function parseToBillData(validData, colMapping, fixedBill, projectID, stdData){
                 programID: null,
                 unit: rData[colMapping.unit] ? rData[colMapping.unit] : '',
                 quantity: rData[colMapping.quantity] ? rData[colMapping.quantity] : '',
-                flags: fixedBill.flags[0].flag === fixedFlag.CONSTRUCTION_ORGANIZATION && rData[colMapping.name] === '安全文明施工专项费用' ?
-                    [{fieldName: 'fixed', flag: fixedBill.flags[0].flag}] : [],
+                //安全文明
+                flags: fixedBill.flags[0].flag === fixedFlag.CONSTRUCTION_ORGANIZATION && (rData[colMapping.name] === '安全文明施工专项费用' || rData[colMapping.name] === '安全文明施工费') ?
+                    [{fieldName: 'fixed', flag: fixedFlag.SAFETY_CONSTRUCTION}] : [],
                 fees: [],
                 projectID: projectID,
                 type: getBillType(rData, fixedBill.flags[0].flag)};
@@ -470,6 +488,8 @@ function parseToBillData(validData, colMapping, fixedBill, projectID, stdData){
     for(let i in billIdx){
         rst.push(billIdx[i]);
     }
+    console.log('rst');
+    console.log(rst);
     return rst;
 }
 

+ 2 - 2
modules/main/facade/project_facade.js

@@ -142,8 +142,8 @@ async function updateNodes(datas){
             updateOne:{
                 filter:{
                     //projectID: node.data.projectID, 现在复制项目也重新生成一个新的ID了,所以ID是唯一的
-                    ID: node.data.ID,
-                    deleteInfo: null
+                    ID: node.data.ID
+                    //deleteInfo: null
                 },
                 update :node.data
             }

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

@@ -195,7 +195,6 @@ module.exports = {
         let rationValuation = sessionCompilation.ration_valuation !== undefined ?
             sessionCompilation.ration_valuation : [];
         rationValuation = await engineeringLibModel.getLib(rationValuation);
-
         let renderData = {
             userAccount: request.session.userAccount,
             userID: request.session.sessionUser.id,

+ 13 - 1
public/web/sheet/sheet_data_helper.js

@@ -118,6 +118,7 @@ var SheetDataHelper = {
     loadSheetData: function (setting, sheet, datas) {
         SheetDataHelper.protectdSheet(sheet);
 
+
         let TipCellType = function () {};
         TipCellType.prototype = new GC.Spread.Sheets.CellTypes.Text();
         TipCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
@@ -135,6 +136,9 @@ var SheetDataHelper = {
         TipCellType.prototype.processMouseEnter = function (hitinfo) {
             let text = hitinfo.sheet.getText(hitinfo.row, hitinfo.col);
             let tag = hitinfo.sheet.getTag(hitinfo.row, hitinfo.col);
+            let hintHeight = datas[hitinfo.row] ?
+                                datas[hitinfo.row].hintHeight ? datas[hitinfo.row].hintHeight : null
+                            : null; //定额库定额悬浮提示位置相关
             if(tag !== undefined && tag){
                 text = tag;
             }
@@ -154,8 +158,15 @@ var SheetDataHelper = {
                         document.body.insertBefore(div, null);
                     }
                     this._toolTipElement = div;
-                    $(this._toolTipElement).html(text).css("top", setting.pos.y + hitinfo.y + 15).css("left", setting.pos.x + hitinfo.x + 15);
+                    $(this._toolTipElement).html(text);
+                    if(hintHeight){
+                        $(this._toolTipElement).css("top", setting.pos.y  + hitinfo.y - hintHeight).css("left", setting.pos.x + hitinfo.x + 15);
+                    }
+                    else{
+                        $(this._toolTipElement).css("top", setting.pos.y + hitinfo.y +15).css("left", setting.pos.x + hitinfo.x + 15);
+                    }
                     $(this._toolTipElement).show("fast");
+                    TREE_SHEET_HELPER.tipDiv = 'show';//做个标记
                 }
             }
         };
@@ -164,6 +175,7 @@ var SheetDataHelper = {
                 $(this._toolTipElement).hide();
                 this._toolTipElement = null;
             }
+            TREE_SHEET_HELPER.tipDivCheck();//延时检查:当tips正在show的时候,就调用了hide方法,会导致tips一直存在,所以设置一个超时处理
         }
 
         sheet.suspendPaint();

+ 3 - 1
web/building_saas/main/js/controllers/project_controller.js

@@ -30,8 +30,10 @@ ProjectController = {
             });
             for(let newNode of newNodes){
                 sc.sheet.addRows(newNode.serialNo(), 1);
-               // TREE_SHEET_HELPER.refreshTreeNodeData(sc.setting, sc.sheet, [newNode], false);
+            }
+            for(let newNode of newNodes){
                 sc.setTreeSelected(newNode);
+                TREE_SHEET_HELPER.refreshTreeNodeData(sc.setting, sc.sheet, [newNode], false);
                 sc.sheet.setSelection(newNode.serialNo(), sels[0].col, 1, 1);
                 sc.sheet.showRow(newNode.serialNo(), GC.Spread.Sheets.VerticalPosition.center);
             }

+ 10 - 2
web/building_saas/main/js/models/installation_fee.js

@@ -297,6 +297,7 @@ var installation_fee = {
                 CommonAjax.post("/project/calcInstallationFee",updateData,function (data) {
                     //提交后台成功后所做的操作,删除要先删除定额,再删除清单,添加要先添加清单再添加定额
                     project.ration_glj.addDatasToList(data.add);//添加插入的定额
+                    let calRations = [];
                     for(let ur of data.update){
                         let glj = project.ration_glj.getDataByID(ur.ID);
                         glj.quantity = ur.quantity;
@@ -306,15 +307,19 @@ var installation_fee = {
                     //对树节点的操作并删除、添加清单、删除添加定额、删除对应的定额工料机缓存
                     TREE_SHEET_HELPER.massOperationSheet(projectObj.mainController.sheet, function () {
                         deleteOldNodes(deleteRationNodes,deleteBillsNodes);
-                        addNewNodes(updateData);
+                        calRations =  addNewNodes(updateData);
                     });
+                    for(let u of updateData.ration.update){
+                        let unode =   projectObj.project.mainTree.findNode(u.ID);
+                         unode?calRations.push(unode):'';
+                    }
                     setTreeSelection(selectedNode);
                     let endTime =  +new Date();
                     console.log(`计算安装增加费时间——${endTime - startTime}`);
                     projectObj.project.projectGLJ.loadData(function () {
                         cbTools.refreshFormulaNodes();
                         if(callback){
-                            callback(true);
+                            callback(true,calRations);
                         }
                         $.bootstrapLoading.end();
                     });
@@ -326,6 +331,7 @@ var installation_fee = {
                 let controller = projectObj.mainController;
                 let Bill = project.Bills;
                 let newAddNode = [];
+                let newRationNodes = [];
                 for(let nb of updateData.bills.add){
                     let newSource = Bill.tree.insertByData(nb, nb.ParentID, -1, true);
                     let newNode = project.mainTree.insert(nb.ParentID, -1, newSource.data.ID);
@@ -345,9 +351,11 @@ var installation_fee = {
                     controller.sheet.addRows(newNode.serialNo(), 1);
                     controller.sheet.showRow(newNode.serialNo(), GC.Spread.Sheets.VerticalPosition.center);
                     newAddNode.push(newNode);
+                    newRationNodes.push(newNode);
                     project.Ration.datas.push(nr);
                 }
                 TREE_SHEET_HELPER.refreshTreeNodeData(controller.setting, controller.sheet, newAddNode, false);
+                return newRationNodes;
             }
 
             function deleteOldNodes(deleteRationNodes,deleteBillsNodes) {

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

@@ -755,7 +755,7 @@ ProjectGLJ.prototype.getQuantityPerGLJ = function (ration_glj_list,rations,ratio
         if(ra.type == rationType.gljRation&&ra.projectGLJID===pglj.id){
             let r_quantity = scMathUtil.roundForObj(ra.quantity,q_decimal);
             r_quantity = r_quantity?r_quantity:0;
-            quantitySum== scMathUtil.roundForObj(quantitySum+r_quantity,q_decimal);
+            quantitySum = scMathUtil.roundForObj(quantitySum+r_quantity,q_decimal);
             if(_.includes(billIDs,ra.billsItemID)){//计算分部分项
                 sum = scMathUtil.roundForObj(sum+r_quantity,q_decimal);
             }

+ 8 - 9
web/building_saas/main/js/models/quantity_detail.js

@@ -612,22 +612,22 @@ var quantity_detail = {
                 });*/
                 project.calcProgram.calcRationsAndSave(needUpdateChildren, function () {
                     if(project.Bills.isFBFX(node)) { //判断是否属于分部分项工程 ,是的话才需要做计取安装费计算
-                        project.installation_fee.calcInstallationFee(function (isChange) {
+                        project.installation_fee.calcInstallationFee(function (isChange,rations) {
                             if(isChange){
-                                project.calcProgram.calcAllNodesAndSave(calcAllType.catAll,function () {
-                                    project.projectGLJ.loadData();
+                                project.calcProgram.calcRationsAndSave(rations,function () {
+                                    project.projectGLJ.calcQuantity();
                                 });
                             }
                         });
                     }else {
-                        project.projectGLJ.loadData();
+                        project.projectGLJ.calcQuantity();
                     }
                 });
 
             }else {
                 node.changed = true;
                 project.calcProgram.calcAndSave(node, function () {
-                    project.projectGLJ.loadData();
+                    project.projectGLJ.calcQuantity();
                 });
             }
             if(gljNodes.length>0){
@@ -648,14 +648,13 @@ var quantity_detail = {
             }
             node.changed = true;
             project.calcProgram.calcAndSave(node, function () {
+                project.projectGLJ.calcQuantity();
                 if(project.Bills.isFBFX(node)) { //判断是否属于分部分项工程 ,是的话才需要做计取安装费计算
-                    project.installation_fee.calcInstallationFee(function (isChange) {
+                    project.installation_fee.calcInstallationFee(function (isChange,rations) {
                         if(isChange){
-                            project.calcProgram.calcAllNodesAndSave();
+                            project.calcProgram.calcRationsAndSave(rations);
                         }
                     });
-                }else {
-                    project.projectGLJ.loadData();
                 }
             });
             projectObj.mainController.refreshTreeNode(node.children);//刷新子工料机总消耗量

+ 7 - 6
web/building_saas/main/js/models/ration.js

@@ -412,7 +412,7 @@ var Ration = {
                    }
                 }
                 project.projectGLJ.loadData(function () {
-                    gljOprObj.showDataIfRationSelect(projectObj.project.mainTree.selected,'11111');
+                    gljOprObj.showDataIfRationSelect(projectObj.project.mainTree.selected);
                     project.calcProgram.calcRationsAndSave(refershNodes);
                     projectObj.mainController.refreshTreeNode(refershNodes, true);
                     $.bootstrapLoading.end();
@@ -487,12 +487,13 @@ var Ration = {
                         project.ration_glj.addToMainTree(data.ration_gljs);
                         projectObj.mainController.refreshTreeNode([newNode], false);
                         if(project.Bills.isFBFX(newNode)) { //判断是否属于分部分项工程 ,是的话才需要做计取安装费计算
-                            let changeNodes = project.calcProgram.calculate(newNode);//先计算不保存,如果计算安装增加费后不用自动计算,则单独调用保存的方法
-                            project.installation_fee.calcInstallationFee(function (isChange) {
+                           // let changeNodes = project.calcProgram.calculate(newNode);//先计算不保存,如果计算安装增加费后不用自动计算,则单独调用保存的方法
+                            project.installation_fee.calcInstallationFee(function (isChange,rations) {
                                 if(isChange){
-                                   project.calcProgram.calcAllNodesAndSave();
+                                    rations.push(newNode);
+                                    project.calcProgram.calcRationsAndSave(rations);
                                 }else {
-                                    project.calcProgram.saveNodes(changeNodes);
+                                    project.calcProgram.calcRationsAndSave([newNode]);
                                 }
                             });
                         }else {
@@ -580,7 +581,7 @@ var Ration = {
           //  node.data.quantity = projectObj.project.quantity_detail.autoTransformQuantity(node.data.quantity,node);//按单位做转换
             node.changed = true;
             project.calcProgram.calcAndSave(node, function () {
-                project.projectGLJ.loadData();
+                project.projectGLJ.calcQuantity();
             });
             projectObj.mainController.refreshTreeNode(node.children);//刷新子工料机树节点总消耗量
         };

+ 10 - 8
web/building_saas/main/js/views/installation_fee_view.js

@@ -795,9 +795,9 @@ let installationFeeObj={
                 $("#modify_feeRule").modal('hide');
                 installation_fee.updateFeeRule(updateMap,modifyRule.libID,modifyRule.ID,function () {
                     me.refreshRationInstallationRow(me.rationInstallSheet.getSelections()[0].row);
-                    installation_fee.calcInstallationFee(function (isChange) {
+                    installation_fee.calcInstallationFee(function (isChange,rations) {
                         if(isChange){
-                            projectObj.project.calcProgram.calcAllNodesAndSave();
+                            projectObj.project.calcProgram.calcRationsAndSave(rations);
                         }
                     });
                 });
@@ -833,8 +833,10 @@ let installationFeeObj={
         }
         installation_fee.updateFeeRule({position:recode.code,billID:recode.ID},rationInstall.libID,rationInstall.ruleId,function (){
             me.refreshRationInstallationRow(riselection.row);
-            installation_fee.calcInstallationFee(function () {
-                projectObj.project.calcProgram.calcAllNodesAndSave();
+            installation_fee.calcInstallationFee(function (isChange,rations) {
+                if(isChange){
+                    projectObj.project.calcProgram.calcRationsAndSave(rations);
+                }
             });
         });
     },
@@ -1241,9 +1243,9 @@ let installationFeeObj={
             }
         }
         $('#calc_installation_fee').modal('hide');
-        install_fee.calcInstallationFee(function (isChange) {
+        install_fee.calcInstallationFee(function (isChange,rations) {
             if(isChange){
-                projectObj.project.calcProgram.calcAllNodesAndSave();
+                projectObj.project.calcProgram.calcRationsAndSave(rations);
             }
             installationFeeObj.showRationInstallationData(projectObj.project.mainTree.selected);
         });
@@ -1292,9 +1294,9 @@ let installationFeeObj={
         let IDList = _.map(riList,'ID');
         ration_installation.applyRuleByIDs(selectRecord.projectID,IDList,selectRecord.ruleId,function () {
             //计算安装增加费
-            projectObj.project.installation_fee.calcInstallationFee(function (isChange) {
+            projectObj.project.installation_fee.calcInstallationFee(function (isChange,rations) {
                 if(isChange){
-                    projectObj.project.calcProgram.calcAllNodesAndSave();
+                    projectObj.project.calcProgram.calcRationsAndSave(rations);
                 }
             });
         })

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

@@ -124,7 +124,7 @@
 
                         <legend>单价文件</legend>
                         <table class="table table-bordered table-hover table-sm" id="summary-project-unit-price-table">
-                            <thead><th></th><th>名称</th><th width="50">使用</th></thead>
+                            <thead><th style="width: 25px;"></th><th style="width: 330px;">名称</th><th style="width:40px;">使用</th></thead>
                             <tbody>
                             <tr><td>1</td><td>A单价文件</td></tr>
                             <tr><td>2</td><td>B单价文件</td></tr>
@@ -135,7 +135,7 @@
 
                         <legend>费率文件</legend>
                         <table class="table table-bordered table-hover table-sm" id="summary-project-fee-table">
-                            <thead><th></th><th>名称</th><th width="50">使用</th></thead>
+                            <thead><th style="width: 25px;"></th><th style="width: 330px;">名称</th><th style="width:40px;">使用</th></thead>
                             <tbody>
                             <tr><td>1</td><td>A费率文件</td></tr>
                             <tr><td>2</td><td>B费率文件</td></tr>

+ 0 - 1
web/building_saas/pm/js/pm_newMain.js

@@ -107,7 +107,6 @@ const projTreeObj = {
                 allowResizeRows: true,
                 allowResizeColumns: true
             };
-            sheet.setColumnCount(headers.length);
             sheet.setRowHeight(0, 40, GC.Spread.Sheets.SheetArea.colHeader);
             for(let i = 0, len = headers.length; i < len; i++){
                 sheet.setValue(0, i, headers[i].name, GC.Spread.Sheets.SheetArea.colHeader);