Explorar el Código

Merge branch '1.0.0_online' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost into 1.0.0_online

chenshilong hace 6 años
padre
commit
6c7a21807f

+ 12 - 5
modules/pm/controllers/pm_controller.js

@@ -566,23 +566,29 @@ module.exports = {
                 }
                 let orgUsersInfo = await userModel.find({_id: {$in : userObjIDs}});
                 //建设项目
-                let consProjIDs = [];
+                let consProjIDs = [],
+                    ungroupedTenders = [];
                 for(let proj of receiveProjects){
+                    if (proj.projType === projType.project) {
+                        consProjIDs.push(proj.ID);
+                    }
                     //获取分享项目子项
                     if (proj.projType !== projType.tender) {
                         proj._doc.children = await pm_facade.getPosterityProjects([proj.ID]);
-                        if (proj.projType === projType.project) {
-                            consProjIDs.push(proj.ID);
-                        }
                         for (let projC of proj._doc.children) {
                             if (projC.projType === projType.project) {
                                 consProjIDs.push(projC.ID);
                             } else if (projC.projType === projType.tender) {
                                 //设置工程专业
                                 projC._doc.feeStandardName = projC.property.feeStandardName || '';
+                                if (proj.projType === projType.engineering) {
+                                    ungroupedTenders.push(projC._doc);
+                                }
                             }
                             delete projC._doc.property;
                         }
+                    } else {//未分类的单位工程不进行汇总,只取价格信息
+                        ungroupedTenders.push(proj._doc);
                     }
                     //设置分组,单位工程及单项工程分到未分组那
                     if (proj.projType === projType.tender || proj.projType === projType.engineering) {
@@ -601,7 +607,8 @@ module.exports = {
                 }
                 consProjIDs = Array.from(new Set(consProjIDs));
                 let summaryInfo = await pm_facade.getSummaryInfo(consProjIDs);
-                rst.summaryInfo = summaryInfo;
+                let tendersFeeInfo = await pm_facade.getTendersFeeInfo(ungroupedTenders);
+                rst.summaryInfo = {grouped: summaryInfo, ungrouped: tendersFeeInfo};
             }
             callback(req, res, 0, 'success', rst);
         }

+ 44 - 1
modules/pm/facade/pm_facade.js

@@ -45,6 +45,7 @@ module.exports={
     copyExample: copyExample,
     getSummaryInfo: getSummaryInfo,
     getSummaryInfoByTender: getSummaryInfoByTender,
+    getTendersFeeInfo: getTendersFeeInfo,
     getConstructionProject: getConstructionProject,
     getFullPath: getFullPath,
     getProjectFeature:getProjectFeature,
@@ -630,7 +631,7 @@ async function getSummaryInfoByTender(tenderID, summaryType) {
             if(summaryInfo[t.ID]){
                 summaryInfo[t.ID]['name'] = t.name ? t.name : '';
                 summaryList.push(summaryInfo[t.ID]);
-            }
+            }k
         }
     }
     else {
@@ -646,6 +647,48 @@ async function getSummaryInfoByTender(tenderID, summaryType) {
     return {parent: {name: parentName}, subList: summaryList};
 }
 
+//获取单位工程的各标段费用信息(不进行汇总)
+async function getTendersFeeInfo(tenders) {
+    let IDMapping = {};
+    //固定清单类别与汇总金额字段映射
+    let flagFieldMapping = {};
+    flagFieldMapping[billsFlags.ENGINEERINGCOST] = 'engineeringCost';
+    flagFieldMapping[billsFlags.SUB_ENGINERRING] = 'subEngineering';
+    flagFieldMapping[billsFlags.MEASURE] = 'measure';
+    flagFieldMapping[billsFlags.SAFETY_CONSTRUCTION] = 'safetyConstruction';
+    flagFieldMapping[billsFlags.OTHER] = 'other';
+    flagFieldMapping[billsFlags.CHARGE] = 'charge';
+    flagFieldMapping[billsFlags.TAX] = 'tax';
+    let tenderIDs = [];
+    if(tenders.length > 0){
+        for(let tender of tenders){
+            tenderIDs.push(tender.ID);
+            IDMapping[tender.ID] = {engineeringCost: 0, subEngineering: 0, measure: 0, safetyConstruction: 0, other: 0, charge: 0, tax: 0, rate: 0, buildingArea: '', perCost: ''};
+            IDMapping[tender.ID]['buildingArea'] = '';
+        }
+        //需要获取的清单固定类别综合合价:工程造价、分部分项、措施项目、安全文明施工专项、规费、其他项目、税金
+        let needFlags = [billsFlags.ENGINEERINGCOST, billsFlags.SUB_ENGINERRING, billsFlags.MEASURE,
+            billsFlags.SAFETY_CONSTRUCTION, billsFlags.CHARGE, billsFlags.OTHER, billsFlags.TAX];
+        //获取单位工程汇总金额需要用到的所有清单
+        let allBills = await billsModel.find({projectID: {$in: tenderIDs}, 'flags.flag': {$in: needFlags}, $or: notDeleted},
+            '-_id projectID fees flags');
+        //进行单位工程级别的汇总
+        for(let bills of allBills){
+            let billsFlag = bills.flags[0]['flag'];
+            let costField = flagFieldMapping[billsFlag];
+            IDMapping[bills.projectID][costField] = getCommonTotalFee(bills);
+        }
+        //占造价比例、单方造价
+        for(let tender of tenders){
+            let tenderInfo = IDMapping[tender.ID];
+            tenderInfo.rate = '';
+            //单方造价
+            tenderInfo.perCost = '';
+        }
+    }
+    return IDMapping;
+}
+
 async function getSummaryInfo(projectIDs){
     //ID与汇总信息映射
     let IDMapping = {};

+ 4 - 1
web/building_saas/css/custom.css

@@ -261,8 +261,11 @@ legend.legend{
 .item_spread{
     width: 29.8%;
     float: left;
-    background: #F1F1F1
+    white-space:nowrap;
+    margin-top: -5px;
+    background: #F1F1F1;
 }
+
 input.text-right{
     text-align: right;
 }

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

@@ -322,7 +322,7 @@
                                           <div class="input-group input-group-sm col-12">
                                               <input type="text" class="form-control form-control-sm" placeholder="查找内容" value="">
                                               <div class="input-group-append">
-                                                  <button class="btn btn-secondary btn-sm" type="button"><i class="fa fa-search" aria-hidden="true"></i></button>
+                                                  <button class="btn btn-secondary btn-sm" type="button" id="locate_btn"><i class="fa fa-search" aria-hidden="true"></i></button>
                                               </div>
                                           </div>
                                           <div class="form-group col-12 mb-1">

+ 1 - 0
web/building_saas/main/js/controllers/material_controller.js

@@ -219,6 +219,7 @@ let MaterialController = {
             $('#subSpread').css('width','');
             return;
         }
+        $("#replaceM").removeClass("ovf-hidden");
         $('#subSpread').css('width',MaterialController.subSpreadDivWidth);
         $("#replaceM").html(text);
     },

+ 8 - 8
web/building_saas/main/js/models/calc_base.js

@@ -916,7 +916,7 @@ let baseFigureTemplate = {
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         for(let glj of projGljs){
             if(glj.type === gljType.LABOUR){
-                rst = (rst + parseFloat(glj.supply_quantity * glj.unit_price.base_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
+                rst = (rst + parseFloat(projectGljObject.getSupplyQuantityByGlj(glj) * glj.unit_price.base_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
             }
         }
         return rst;
@@ -926,7 +926,7 @@ let baseFigureTemplate = {
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         for(let glj of projGljs){
             if(baseMaterialTypes.includes(glj.type) && glj.ratio_data.length === 0){
-                rst = (rst + parseFloat(glj.supply_quantity * glj.unit_price.base_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
+                rst = (rst + parseFloat(projectGljObject.getSupplyQuantityByGlj(glj) * glj.unit_price.base_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
             }
         }
         return rst;
@@ -936,7 +936,7 @@ let baseFigureTemplate = {
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         for(let glj of projGljs){
             if(baseMachineTypes.includes(glj.type) && glj.ratio_data.length === 0){
-                rst = (rst + parseFloat(glj.supply_quantity * glj.unit_price.base_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
+                rst = (rst + parseFloat(projectGljObject.getSupplyQuantityByGlj(glj) * glj.unit_price.base_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
             }
         }
         return rst;
@@ -946,7 +946,7 @@ let baseFigureTemplate = {
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         for(let glj of projGljs){
             if(glj.type === gljType.LABOUR){
-                rst = (rst + parseFloat(glj.supply_quantity * glj.unit_price.market_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
+                rst = (rst + parseFloat(projectGljObject.getSupplyQuantityByGlj(glj) * glj.unit_price.market_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
             }
         }
         return rst;
@@ -956,7 +956,7 @@ let baseFigureTemplate = {
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         for(let glj of projGljs){
             if(baseMaterialTypes.includes(glj.type) && glj.ratio_data.length === 0){
-                rst = (rst + parseFloat(glj.supply_quantity * glj.unit_price.market_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
+                rst = (rst + parseFloat(projectGljObject.getSupplyQuantityByGlj(glj) * glj.unit_price.market_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
             }
         }
         return rst;
@@ -966,7 +966,7 @@ let baseFigureTemplate = {
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         for(let glj of projGljs){
             if(baseMachineTypes.includes(glj.type) && glj.ratio_data.length === 0){
-                rst = (rst + parseFloat(glj.supply_quantity * glj.unit_price.market_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
+                rst = (rst + parseFloat(projectGljObject.getSupplyQuantityByGlj(glj) * glj.unit_price.market_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
             }
         }
         return rst;
@@ -976,7 +976,7 @@ let baseFigureTemplate = {
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         for(let glj of projGljs){
             if(glj.type === gljType.MAIN_MATERIAL && glj.ratio_data.length === 0){
-                rst = (rst + parseFloat(glj.supply_quantity * glj.unit_price.base_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
+                rst = (rst + parseFloat(projectGljObject.getSupplyQuantityByGlj(glj) * glj.unit_price.base_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
             }
         }
         return rst;
@@ -986,7 +986,7 @@ let baseFigureTemplate = {
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         for(let glj of projGljs){
             if(glj.type === gljType.EQUIPMENT){
-                rst = (rst + parseFloat(glj.supply_quantity * glj.unit_price.market_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
+                rst = (rst + parseFloat(projectGljObject.getSupplyQuantityByGlj(glj) * glj.unit_price.market_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
             }
         }
         return rst;

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

@@ -761,7 +761,7 @@ let calcTools = {
         // 定额大类
         if (me.isRationCategory(treeNode)) {
             data.isSubcontract = treeNode.data.isSubcontract;
-
+            data.evaluationProject = treeNode.data.evaluationProject;
             //定额类型的工料机做特殊处理
             if(me.isGljRation(treeNode)){
                 data.code = treeNode.data.code;

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

@@ -384,7 +384,7 @@ var quantity_detail = {
                     query.billID = recode.billID;
                     doc.billID=recode.billID;
                 }
-                if(this.checkAndCalcResult(args.editingText,args.row,doc) === false){
+                if(gljUtil.isDef(args.editingText)&&this.checkAndCalcResult(args.editingText,args.row,doc) === false){
                     gljOprObj.showQuantityDetailData();
                     return;
                 }

+ 2 - 3
web/building_saas/main/js/views/glj_view.js

@@ -155,7 +155,7 @@ var gljOprObj = {
         function enterKeyAction(spd,sheeName) {
             let editRow = sheet.getActiveRowIndex(),orgCol = sheet.getActiveColumnIndex();
             let fieldID = me.setting.header[orgCol].dataCode;
-            if(me.setting.navigationRightCol.indexOf(fieldID) != -1){
+            if(sheeName=="ration_glj" && me.setting.navigationRightCol.indexOf(fieldID) != -1){
                 if(sheet.isEditing()) sheet.endEdit();
                 GC.Spread.Sheets.Commands.navigationRight.execute(spd,sheeName);
             }else {
@@ -608,8 +608,6 @@ var gljOprObj = {
         let ration_glj = this.sheetData[selected.row];
         return ration_glj;
     },
-
-
     getUnitPriceCodeMap : function () {//取单价文件中,编码前缀一样的映射表
         let codeMap = {};
         let priceMap = projectObj.project.projectGLJ.datas.unitPriceMap;
@@ -758,6 +756,7 @@ var gljOprObj = {
         return data;
 
     },
+
     getBasePrice:function (treeNode) {//造价书中的工料机修改的节点要用到
         let proGLJ =  projectObj.project.projectGLJ;
         let glj =_.find(proGLJ.datas.gljList, {'id': treeNode.data.projectGLJID});

+ 118 - 19
web/building_saas/main/js/views/locate_view.js

@@ -2,37 +2,136 @@
  * Created by zhang on 2018/11/16.
  */
 let locateObject={
+    bills_setting:{
+        header:[
+            {headerName: "编码", headerWidth: 120, dataCode: "code", dataType: "String"},
+            {headerName: "项目名称", headerWidth: 100, dataCode: "name", dataType: "String"},
+            {headerName: "单位", headerWidth: 50, dataCode: "unit", dataType: "String",hAlign: "center"},
+            {headerName: "工程量", headerWidth: 65, dataCode: "quantity", dataType: "Number", hAlign: "right"},
+            {headerName: "综合单价", headerWidth: 65, dataCode: "unitPrice", dataType: "Number", hAlign: "right"},
+            {headerName: "综合合价", headerWidth: 65, dataCode: "totalPrice", dataType: "Number", hAlign: "right"}
+        ],
+        view: {
+            lockColumns: [0,1,2,3,4],
+            rowHeaderWidth:25
+        }
+    },
+    ration_setting:{
+        header:[
+            {headerName: "定额编码", headerWidth: 100, dataCode: "code", dataType: "String"},
+            {headerName: "定额名称", headerWidth: 180, dataCode: "name", dataType: "String"},
+            {headerName: "单位", headerWidth: 50, dataCode: "unit", dataType: "String",hAlign: "center"},
+            {headerName: "工程量", headerWidth: 65, dataCode: "quantity", dataType: "Number", hAlign: "right",decimalField: "ration.quantity"}
+        ],
+        view: {
+            lockColumns: [0,1,2,3],
+            rowHeaderWidth:25
+        }
+    },
+    ration_glj_setting:{
+        header:[
+            {headerName: "编码", headerWidth: 120, dataCode: "code", dataType: "String"},
+            {headerName: "名称", headerWidth: 80, dataCode: "name", dataType: "String"},
+            {headerName: "规格型号", headerWidth: 80, dataCode: "code", dataType: "String"},
+            {headerName: "单位", headerWidth: 50, dataCode: "unit", dataType: "String",hAlign: "center"},
+            {headerName: "市场价", headerWidth: 65, dataCode: "marketPrice", dataType: "Number", hAlign: "right"}
+        ],
+        view: {
+            lockColumns: [0,1,2,3],
+            rowHeaderWidth:25
+        }
+    },
+    initMainSpread:function(){
+        if(!this.mainSpread){
+            this.mainSpread = SheetDataHelper.createNewSpread($("#locate_result")[0],3);
+            sheetCommonObj.spreadDefaultStyle(this.mainSpread);
+            this.initMainSheet();
+        }else {
+            this.mainSpread.refresh();
+        }
+    },
+    initMainSheet:function () {
+       // this.mainSheet = this.mainSpread .getSheet(0);
+        //this.spread.bind(GC.Spread.Sheets.Events.ButtonClicked, this.onReplaceButtonClick);
+       //初始化清单表格
+        sheetCommonObj.initSheet(this.mainSpread .getSheet(0),this.bills_setting);
+        this.mainSpread .getSheet(0).setRowCount(0);
+        //初始化定额表格
+        sheetCommonObj.initSheet(this.mainSpread .getSheet(1),this.ration_setting);
+        this.mainSpread .getSheet(1).setRowCount(0);
 
-
+        //初始化人材机表格
+        sheetCommonObj.initSheet(this.mainSpread.getSheet(2),this.ration_glj_setting);
+        this.mainSpread .getSheet(2).setRowCount(0);
+    },
+    initSubSpread:function () {
+        if(!this.subSpread){
+            this.subSpread = SheetDataHelper.createNewSpread($("#locate_sub")[0]);
+            sheetCommonObj.spreadDefaultStyle(this.subSpread);
+            this.initSubSheet();
+        }else {
+            this.subSpread.refresh();
+        }
+    },
+    initSubSheet:function () {
+        this.subSheet = this.subSpread .getSheet(0);
+        sheetCommonObj.initSheet( this.subSheet, this.ration_setting);
+        this.subSheet.setRowCount(0);
+        //this.spread.bind(GC.Spread.Sheets.Events.ButtonClicked, this.onReplaceButtonClick);
+        this.subSheet.name('locate_sub');
+    },
+    showMainData:function () {
+        let datas = [];
+        //sheetCommonObj.showData(this.mainSheet,this.mainSettiong,datas);
+        this.mainSpread.getActiveSheet().setRowCount(datas.length);
+    },
     init:function () {
-        let tab_content = $('#locate').parent();
-        $('#locate_result').height(tab_content.height()*0.6);
-        $('#locate_sub').height(tab_content.height()*0.4);
-
+        let me = this;
+        let options = $("input[name='content_type']:checked").val();
+        let callback = function () {
+            let mainHeight = $(window).height()-$(".header").height()-$(".toolsbar").height()-$("#searchPanel").height();
+            let subHeight = 0;
+            if(options == "ration_glj"){
+                subHeight = mainHeight*0.4;
+                mainHeight = mainHeight*0.6;
+            }
+            console.log(mainHeight);
+            $('#locate_result').height(mainHeight);
+            $('#locate_sub').height(subHeight - 7);
+            me.initMainSpread();
+            me.initSubSpread();
+            me.showMainData();
+        };
+        options == "bills"?$("#outstandingOptions").show(0,callback):$("#outstandingOptions").hide(0,callback);
 
     },
+    findRecodes:function () {
 
+    },
     onshow:function () {
-
         locateObject.init();
-        console.log('#locate is now visible');
-        console.log($("#locate").is(':visible'))
     }
-
 }
 
 
+$("#locate_btn").click(function () {
+    locateObject.findRecodes();
+});
 
-
-/*
-$("input[name='install_setting_radios']").each(function(){
+$("input[name='content_type']").each(function(){
     $(this).click(function(){
-        var settingVal = $(this).val();
-        let installSetting = projectInfoObj.projectInfo.property.installSetting;
-        if(installSetting==settingVal){
-            return;
+        let optins = $(this).val();
+        switch (optins){
+            case "bills":
+                locateObject.mainSpread.setActiveSheetIndex(0);
+                break;
+            case "ration":
+                locateObject.mainSpread.setActiveSheetIndex(1);
+                break;
+            case "ration_glj":
+                locateObject.mainSpread.setActiveSheetIndex(2);
+                break;
         }
-        projectObj.project.installation_fee.updateInstallSetting(settingVal);
-        installationFeeObj.cleanPositionIfNeed(settingVal);
+        locateObject.init();
     });
-});*/
+});

+ 18 - 0
web/building_saas/main/js/views/project_glj_view.js

@@ -928,6 +928,24 @@ projectGljObject={
         supplyQuantity = parseFloat(supplyQuantity);
         return supplyQuantity;
     },
+    getSupplyQuantityByGlj:function (glj) {
+        //{"自行采购":0,"部分甲供":1,"完全甲供":2,"甲定乙供":3};
+        let supply_quantity = glj.supply_quantity;
+        switch (glj.supply){
+            case 0:
+                supply_quantity = 0;
+                break;
+            case 1:
+                break;
+            case 2:
+                supply_quantity = glj.quantity;
+                break;
+            case 3:
+                supply_quantity = 0;
+                break;
+        }
+        return supply_quantity
+    },
     checkData : function(col,setting, value) {
         let result = true;
         let validator = setting.header[col].validator !== undefined ? setting.header[col].validator : null;

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

@@ -183,6 +183,7 @@ var projectObj = {
     },
     checkFormulaValidField: function (editingText, colSetting) {
         let value = Number(editingText);
+        if(isNaN(value)) return value;
         if (!value) {
             try {
                 let exp = new Expression('');

+ 7 - 3
web/building_saas/pm/js/pm_share.js

@@ -653,6 +653,9 @@ const pmShare = (function () {
     //给项目设置汇总信息
     //@param {Array}projs {Object}summaryInfo
     function setSummaryInfo(grouped, summaryInfo) {
+        if (!summaryInfo) {
+            return;
+        }
         let allDatas = [];
         for (let data of grouped) {
             allDatas.push(data);
@@ -743,11 +746,12 @@ const pmShare = (function () {
             sortByDate(rstData.grouped);
             sortByDate(rstData.ungrouped);
             //设置汇总信息
-            setSummaryInfo(rstData.grouped, rstData.summaryInfo);
+            if (rstData.summaryInfo) {
+                setSummaryInfo(rstData.grouped, rstData.summaryInfo.grouped);
+                setSummaryInfo(rstData.ungrouped, rstData.summaryInfo.ungrouped);
+            }
             let treeDatas = getTreeDatas(rstData.grouped, rstData.ungrouped);
-            console.log(treeDatas);
             tree = pmTree.createNew(treeSetting, treeDatas);
-            console.log(tree);
             tree.selected = tree.items[0];
             showTreeData(tree.items, headers);
             //初始选择