zhangweicheng 6 vuotta sitten
vanhempi
commit
f5be2d5275
1 muutettua tiedostoa jossa 9 lisäystä ja 11 poistoa
  1. 9 11
      modules/main/facade/project_facade.js

+ 9 - 11
modules/main/facade/project_facade.js

@@ -285,6 +285,7 @@ async function getBudgetSummayDatas(projectIDs){
     try {
         let projects = [];
         let names = [];
+        let prjTypeNames = [];
         let decimal = null;
         for(let ID of projectIDs){
             projects.push(await getBillsByProjectID(ID)) ;
@@ -294,11 +295,13 @@ async function getBudgetSummayDatas(projectIDs){
         }
         let mp = projects[0];
         names.push(mp.name);
+        prjTypeNames.push(mp.prjTypeName);
         for(let i = 1;i<projects.length;i++){
             names.push(projects[i].name);
+            prjTypeNames.push(projects[i].prjTypeName);
             decimal = await mergeProject(mp.roots,projects[i].roots)
         }
-        let SummaryAuditDetail = getReportData(names,mp.roots,decimal);
+        let SummaryAuditDetail = getReportData(names,mp.roots,prjTypeNames,decimal);
         let parentProject = await projectsModel.findOne({ID:mp.ParentID});
         let result = {
             prj: {},
@@ -317,14 +320,15 @@ async function getBudgetSummayDatas(projectIDs){
 }
 
 
-function getReportData(nameList,items,decimal) {
+function getReportData(nameList,items,prjTypeNames,decimal) {
     let datas = [],totalItem = null;
     setChildrenDatas(items,datas);
     for(let d of datas){
-        if(d.billsTtlPrice){
+        if(d.billsTtlPrice&&totalItem.billsTtlPrice){
             d['各项费用比例'] = scMathUtil.roundForObj(d.billsTtlPrice/totalItem.billsTtlPrice * 100,2)
         }
         d['prjNames'] = nameList;
+        d['prjTypeNames'] = prjTypeNames;
     }
     return datas;
 
@@ -344,7 +348,6 @@ function getReportData(nameList,items,decimal) {
             billsTtlAmt:bills.quantity,
             billsPrices:[],
             billsAmounts:[],
-            prjTypeNames:[],
             '技术经济指标':[],
             billsMemos:bills.remark
         };
@@ -363,8 +366,6 @@ function getReportData(nameList,items,decimal) {
                 tem.billsAmounts.push(0);
                 tem['技术经济指标'].push(0);
             }
-            let pt =  bills.prjType[n]?bills.prjType[n]:'';
-            tem.prjTypeNames.push(pt);
         }
         tem.billsTtlPrice = scMathUtil.roundForObj(total,decimal.bills.totalPrice);
         tem['技术经济综合指标'] = tem.billsTtlAmt?scMathUtil.roundForObj(tem.billsTtlPrice/tem.billsTtlAmt,2):0;
@@ -399,7 +400,6 @@ async function mergeItem(a,b,decimal,project) {
     for(let name in b.prices){
         a.prices[name] = b.prices[name];
         a.quantityMap[name] = b.quantityMap[name];
-        a.prjType[name] = b.prjType[name];
     }
     for(let name in a.quantityMap){
         a.quantityMap[name] = a.quantityMap[name]?scMathUtil.roundForObj(a.quantityMap[name],bqDecimal):0;
@@ -498,12 +498,10 @@ async function getBillsByProjectID(projectID){
        let commonFee =_.find(b._doc.fees,{"fieldName":"common"});
        let prices = {};
        let quantityMap={};
-       let prjType = {};
        if(commonFee&&commonFee.totalFee) prices[projectName] =  commonFee.totalFee;
        quantityMap[projectName] = b.quantity;
-       prjType[projectName] = engineering;
        let flagIndex = _.find(b._doc.flags,{'fieldName':'fixed'});
-       let doc = {ID:b.ID,name:b.name,code:b.code,unit:b.unit,projectID:b.projectID, ParentID:b.ParentID,NextSiblingID:b.NextSiblingID,quantity:b.quantity,prices:prices,quantityMap:quantityMap,prjType:prjType,flag:flagIndex?flagIndex.flag:-99,remark:b.remark};//选取有用字段
+       let doc = {ID:b.ID,name:b.name,code:b.code,unit:b.unit,projectID:b.projectID, ParentID:b.ParentID,NextSiblingID:b.NextSiblingID,quantity:b.quantity,prices:prices,quantityMap:quantityMap,flag:flagIndex?flagIndex.flag:-99,remark:b.remark};//选取有用字段
        if(b.ParentID == -1) roots.push(doc);
        parentMap[b.ParentID]?parentMap[b.ParentID].push(doc):parentMap[b.ParentID]=[doc];
    }//设置子节点
@@ -511,7 +509,7 @@ async function getBillsByProjectID(projectID){
         setChildren(r,parentMap,1);
    }
     roots = sortChildren(roots);
-    return {name:projectName,roots:roots,author:author,auditor:auditor,compilationScope:compilationScope,ParentID:project.ParentID}
+    return {name:projectName,roots:roots,author:author,auditor:auditor,compilationScope:compilationScope,ParentID:project.ParentID,prjTypeName:engineering}
 }
 
 function setChildren(bill,parentMap,level) {