Browse Source

分享页面汇总信息

zhongzewei 6 years atrás
parent
commit
633309994a

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

@@ -191,7 +191,36 @@ class CompleRatoinDao {
         for(let ration of stdRations){
             ration._doc.type = 'std';
         }
-        stdRations.sort(function (a, b) {
+        function sortByCode(arr) {
+            function recurCompare(a, b, index){
+                if (a[index] && !b[index]) {
+                    return 1;
+                } else if (!a[index] && b[index]) {
+                    return -1;
+                } else if (a[index] && b[index]) {
+                    let aV = a[index],
+                        bV = b[index];
+                    if (!isNaN(aV) && !isNaN(bV)) {
+                        aV = parseFloat(a[index]);
+                        bV = parseFloat(b[index]);
+                    }
+                    if (aV > bV) {
+                        return 1;
+                    } else if (aV < bV) {
+                        return -1;
+                    } else {
+                        return recurCompare(a, b, index + 1);
+                    }
+                }
+                return 0;
+            }
+            arr.sort(function (a, b) {
+                let aArr = a.code.split('-'),
+                    bArr = b.code.split('-');
+                return recurCompare(aArr, bArr, 0);
+            });
+        }
+        /*stdRations.sort(function (a, b) {
             let rst = 0;
             if(a.code > b.code){
                 rst = 1;
@@ -200,7 +229,8 @@ class CompleRatoinDao {
                 rst = -1;
             }
             return rst;
-        });
+        });*/
+        sortByCode(stdRations);
         for(let ration of stdRations){
             let hintsArr = [];
             let stdGljIds = [],

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

@@ -544,15 +544,20 @@ module.exports = {
     },
     receiveProjects: async function(req, res) {
         try {
-            let rst = {grouped: [], ungrouped: []};
+            let rst = {grouped: [], ungrouped: [], summaryInfo: null};
             let userID = req.session.sessionUser.id;
             let receiveProjects = await projectModel.find({
-                $or: [{deleteInfo: null}, {'deleteInfo.deleted': false}], compilation: req.session.sessionCompilation._id, 'shareInfo.userID': userID}, '-_id -property');
+                $or: [{deleteInfo: null}, {'deleteInfo.deleted': false}], compilation: req.session.sessionCompilation._id, 'shareInfo.userID': userID}, '-_id');
             //设置原项目用户信息
             if(receiveProjects.length > 0){
                 let orgUserIDs = [];
                 for(let proj of receiveProjects){
                     orgUserIDs.push(proj.userID);
+                    if (proj.projType === projType.tender) {
+                        //设置工程专业
+                        proj._doc.feeStandardName = proj.property.feeStandardName || '';
+                    }
+                    delete proj._doc.property;
                 }
                 orgUserIDs = Array.from(new Set(orgUserIDs));
                 let userObjIDs = [];
@@ -560,10 +565,24 @@ module.exports = {
                     userObjIDs.push(mongoose.Types.ObjectId(uID));
                 }
                 let orgUsersInfo = await userModel.find({_id: {$in : userObjIDs}});
+                //建设项目
+                let consProjIDs = [];
                 for(let proj of receiveProjects){
                     //获取分享项目子项
                     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 || '';
+                            }
+                            delete projC._doc.property;
+                        }
                     }
                     //设置分组,单位工程及单项工程分到未分组那
                     if (proj.projType === projType.tender || proj.projType === projType.engineering) {
@@ -580,10 +599,14 @@ module.exports = {
                         }
                     }
                 }
+                consProjIDs = Array.from(new Set(consProjIDs));
+                let summaryInfo = await pm_facade.getSummaryInfo(consProjIDs);
+                rst.summaryInfo = summaryInfo;
             }
             callback(req, res, 0, 'success', rst);
         }
         catch (err){
+            console.log(err);
             callback(req, res, 1, err, null);
         }
     },
@@ -593,9 +616,6 @@ module.exports = {
             let compilation = req.session.sessionCompilation._id;
             let query = data.query;
             query.compilation = compilation;
-            console.log(`compilation===============================`);
-            console.log(compilation);
-            console.log(query);
             let options = data.options;
             let projects = await projectModel.find(query, options);
             callback(req, res, 0, 'success', projects);

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

@@ -810,7 +810,7 @@ async function getPosterityProjects(projectIDs) {
     async function getProjects(IDs) {
         if (IDs.length > 0) {
             let newIDs = [];
-            let projs = await projectModel.find({ParentID: {$in: IDs}, $or: notDeleted}, '-_id -property');
+            let projs = await projectModel.find({ParentID: {$in: IDs}, $or: notDeleted}, '-_id');
             for (let proj of projs) {
                 rst.push(proj);
                 newIDs.push(proj.ID);

BIN
public/static/uploadExample.xlsx


+ 3 - 0
web/building_saas/main/js/views/sub_view.js

@@ -62,6 +62,9 @@ let subObj = {
      /*   1、造价书选中行类别是“大项费用”、“分部”、“分项”、“清单”时,显示按钮“工程量明细”、“计算程序”、“特征及内容”,默认打开“计算程序”。
           2、选中行类别是“定额”、“量价”、“人材机”时,显示按钮“人材机”、“子目换算”、“工程量明细”、“计算程序”、“安装增加费”,默认打开“人材机”。
      */
+        if (!node) {
+            return;
+        }
         $('.sub-item').removeClass('active');
         if(node.sourceType == ModuleNames.ration){
             //GLJ_div //ZMHS_div

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

@@ -1143,7 +1143,7 @@ $(document).ready(function() {
     //列宽随着屏幕改变
     $(window).resize(function () {
         sheetCommonObj.setColumnWidthByRate(getWorkBookWidth(), gcTreeObj.workBook, gcTreeObj.setting.header);
-        sheetCommonObj.setColumnWidthByRate(getWorkBookWidth(), pmShare.spreadObj.workBook, pmShare.headers);
+        //sheetCommonObj.setColumnWidthByRate(getWorkBookWidth(), pmShare.spreadObj.workBook, pmShare.headers);
 
     });
 

+ 49 - 9
web/building_saas/pm/js/pm_share.js

@@ -16,6 +16,7 @@ const pmShare = (function () {
     //操作类型
     const oprType = {copy: 'copy', cancel: 'cancel'};
     let tree = null;
+    const treeCol = 0;
     const treeSetting = {
         tree: {
             id: 'ID',
@@ -26,11 +27,20 @@ const pmShare = (function () {
         }
     };
     const headers = [
-        {name: '工程列表', dataCode: 'name', width: 0.55, rateWidth: 0.55, vAlign: 'center', hAlign: 'left'},
-        {name: '由...分享', dataCode: 'from', width: 0.15, rateWidth: 0.15, vAlign: 'center', hAlign: 'left'},
-        {name: '分享给...', dataCode: 'to', width: 0.15, rateWidth: 0.15, vAlign: 'center', hAlign: 'left'},
-        {name: '拷贝工程', dataCode: 'copy', width: 0.075, rateWidth: 0.075, vAlign: 'center', hAlign: 'left'},
-        {name: '清除', dataCode: 'cancel', width: 0.075, rateWidth: 0.075, vAlign: 'center', hAlign: 'left'},
+        {name: '工程列表', dataCode: 'name', width: 300, rateWidth: 0.55, vAlign: 'center', hAlign: 'left'},
+        {name: '由...分享', dataCode: 'from', width: 100, rateWidth: 0.15, vAlign: 'center', hAlign: 'left'},
+        {name: '拷贝工程', dataCode: 'copy', width: 100, rateWidth: 0.075, vAlign: 'center', hAlign: 'left'},
+        {name: '清除', dataCode: 'cancel', width: 100, rateWidth: 0.075, vAlign: 'center', hAlign: 'left'},
+        {name: '工程造价', dataCode: 'engineeringCost', width: 100, vAlign: 'center', hAlign: 'right', formatter: '0.00'},
+        {name: '分部分项合计', dataCode: 'subEngineering', width: 100, vAlign: 'center', hAlign: 'right', formatter: '0.00'},
+        {name: '措施项目合计', dataCode: 'measure', width: 100, vAlign: 'center', hAlign: 'right', formatter: '0.00'},
+        {name: '其他项目合计', dataCode: 'other', width: 100, vAlign: 'center', hAlign: 'right', formatter: '0.00'},
+        {name: '规费', dataCode: 'charge', width: 100, vAlign: 'center', hAlign: 'right', formatter: '0.00'},
+        {name: '税金', dataCode: 'tax', width: 100, vAlign: 'center', hAlign: 'right', formatter: '0.00'},
+        {name: '占造价比例(%)', dataCode: 'rate', width: 100, vAlign: 'center', hAlign: 'right', formatter: '0.00'},
+        {name: '建筑面积', dataCode: 'buildingArea', width: 100, vAlign: 'center', hAlign: 'right', formatter: '0.00'},
+        {name: '单方造价', dataCode: 'perCost', width: 100, vAlign: 'center', hAlign: 'right', formatter: '0.00'},
+        {name: '工程专业', dataCode: 'feeStandardName', width: 100, vAlign: 'center', hAlign: 'left'},
     ];
     const spreadOpts = {
         workBook: {
@@ -107,9 +117,9 @@ const pmShare = (function () {
         let fuc = function () {
             sheet.setColumnCount(headers.length);
             sheet.setRowHeight(0, 40, GC.Spread.Sheets.SheetArea.colHeader);
-            let spreadWidth = getWorkBookWidth();
+            //let spreadWidth = getWorkBookWidth();
             for(let i = 0, len = headers.length; i < len; i++){
-                sheet.setColumnWidth(i, spreadWidth * headers[i].width, GC.Spread.Sheets.SheetArea.colHeader);
+                sheet.setColumnWidth(i, headers[i].width, GC.Spread.Sheets.SheetArea.colHeader);
                 if(headers[i].formatter){
                     sheet.setFormatter(-1, i, headers[i].formatter);
                 }
@@ -559,7 +569,7 @@ const pmShare = (function () {
             sheet.setRowCount(nodes.length);
             for(let i = 0; i < nodes.length; i++){
                 let treeNodeCell = getTreeNodeCell(tree);
-                sheet.getCell(i, 0).cellType(treeNodeCell);
+                sheet.getCell(i, treeCol).cellType(treeNodeCell);
                 for(let j = 0; j < headers.length; j++){
                     sheet.getRange(-1, j, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign[headers[j]['hAlign']]);
                     sheet.getRange(-1, j, -1, 1).vAlign(GC.Spread.Sheets.VerticalAlign[headers[j]['vAlign']]);
@@ -592,7 +602,7 @@ const pmShare = (function () {
                             sheet.getCell(i, j).cellType(getInteractionCell());
                         }
                     }
-                    sheet.setValue(i, j, nodes[i].data[dataCode] ? nodes[i].data[dataCode] : '');
+                    sheet.setValue(i, j, nodes[i].data[dataCode] !== null && typeof nodes[i].data[dataCode] !== 'undefined' ? nodes[i].data[dataCode] : '');
                 }
             }
         };
@@ -640,6 +650,32 @@ const pmShare = (function () {
             }
         }
     }
+    //给项目设置汇总信息
+    //@param {Array}projs {Object}summaryInfo
+    function setSummaryInfo(grouped, summaryInfo) {
+        let allDatas = [];
+        for (let data of grouped) {
+            allDatas.push(data);
+            if (data.children && data.children.length > 0) {
+                allDatas = allDatas.concat(data.children);
+            }
+        }
+        for(let proj of allDatas){
+            let summaryProj = summaryInfo[proj.ID];
+            if(summaryProj){
+                proj.engineeringCost = summaryProj.engineeringCost;
+                proj.subEngineering = summaryProj.subEngineering;
+                proj.measure = summaryProj.measure;
+                proj.safetyConstruction = summaryProj.safetyConstruction;
+                proj.other = summaryProj.other;
+                proj.charge = summaryProj.charge;
+                proj.tax = summaryProj.tax;
+                proj.rate = summaryProj.rate;
+                proj.buildingArea = summaryProj.buildingArea;
+                proj.perCost = summaryProj.perCost;
+            }
+        }
+    }
     //获取可成树的数据
     //@param {Array}datas @return {Array}
     function getTreeDatas(groupedDatas, ungroupedDatas){
@@ -706,7 +742,10 @@ const pmShare = (function () {
             // 排序 --分享的文件按照时间先后顺序排序,分享文件下的子文件,按照原本树结构显示,不需要排序
             sortByDate(rstData.grouped);
             sortByDate(rstData.ungrouped);
+            //设置汇总信息
+            setSummaryInfo(rstData.grouped, rstData.summaryInfo);
             let treeDatas = getTreeDatas(rstData.grouped, rstData.ungrouped);
+            console.log(treeDatas);
             tree = pmTree.createNew(treeSetting, treeDatas);
             console.log(tree);
             tree.selected = tree.items[0];
@@ -715,6 +754,7 @@ const pmShare = (function () {
             let initSel = spreadObj.sheet.getSelections()[0] ? spreadObj.sheet.getSelections()[0] : {row: 0, rowCount: 1};
             initSelection(initSel);
             autoFlashHeight();
+            spreadObj.sheet.frozenColumnCount(4);
             spreadObj.workBook.refresh();
             $.bootstrapLoading.end();
         });