zhangweicheng 6 gadi atpakaļ
vecāks
revīzija
4da0af7e09

+ 62 - 3
modules/main/facade/project_facade.js

@@ -12,7 +12,8 @@ module.exports = {
     markProjectsToChange:markProjectsToChange,
     getSEIProjects:getSEIProjects,
     loadSEIProjectData:loadSEIProjectData,
-    setSEILibData:setSEILibData
+    setSEILibData:setSEILibData,
+    getIndexReportData:getIndexReportData
 };
 
 let mongoose = require('mongoose');
@@ -37,8 +38,8 @@ let engineerFeatureLib = mongoose.model('std_engineer_feature_lib');
 let engineerInfoLib = mongoose.model('std_engineer_info_lib');
 let mainQuantityLib = mongoose.model('std_main_quantity_lib');
 let materialLib = mongoose.model('std_material_lib');
-
-
+import fixedFlag from '../../common/const/bills_fixed';
+const scMathUtil = require('../../../public/scMathUtil').getUtil();
 
 async function calcInstallationFee(data) {
     let result={};
@@ -381,4 +382,62 @@ async function setSEILibData(property){
         let economic = await economicLib.findOne({'ID':property.economicLibID});
         if(economic) property.economics = economic.index;
     }
+}
+
+async function getIndexReportData(projectID) {
+    let project = await projectsModel.findOne({ID:projectID});
+    let bills = await bill_model.getDataSync(projectID);
+    let engineerCostList = getEngineerCostData(project.property,bills);
+    let engineerEcoList = getEconomicDatas(project.property,bills);
+    let mainMaterialList = await getMainMaterialDatas(projectID,project.property);
+    let quantityList = await getQuantityDatas(project.property,bills);
+    let result = {
+        ProjectCostFields:engineerCostList,
+        ProjectEcoFields:engineerEcoList,
+        ProjectLabMaterialFields:mainMaterialList,
+        ProjectQtyFields:quantityList
+    };
+    console.log(JSON.stringify(result));
+    return result
+}
+
+
+function getQuantityDatas(property,bills) {
+     return gljUtil.getQuantityDatas(property.engineerFeatures,property.mainQuantities,bills,fixedFlag,_,scMathUtil,property.decimal)
+}
+
+function getEconomicDatas(property,bills) {
+   return gljUtil.getEconomicDatas(property.engineerFeatures,property.economics,bills,fixedFlag,_,scMathUtil,property.decimal)
+}
+
+
+function getEngineerCostData(property,bills){
+    let datas = [];
+    let priceIndex = gljUtil.getEngineerCostData(property,bills,fixedFlag,scMathUtil);
+    for(let c of priceIndex.children){
+        let tem = {
+            name:c.name,
+            cost:parseFloat(c.attrs[0].value),
+            unitCost:parseFloat(c.attrs[1].value),
+            per:parseFloat(c.attrs[2].value)
+        };
+        datas.push(tem);
+    }
+    return datas;
+}
+
+async function getMainMaterialDatas(projectID,property) {
+    let gljListModel = new GLJListModel();
+    let [gljList, mixRatioConnectData,mixRatioMap,unitPriceMap] = await gljListModel.getListByProjectId(projectID, property.unitPriceFile?property.unitPriceFile.id:null);
+    gljList = JSON.parse(JSON.stringify(gljList));
+    await calcProjectGLJQuantity(projectID,{gljList:gljList,mixRatioMap:mixRatioMap},property);
+    return gljUtil.getMainMaterialDatas(property.engineerFeatures,property.materials,{gljList:gljList},property.calcOptions,property.decimal,false,_,scMathUtil)
+
+}
+
+async function calcProjectGLJQuantity(projectID,projectGLJDatas,property){
+    let q_decimal = property.decimal.glj.quantity;
+    let rationGLJDatas = await ration_glj_model.find({'projectID':projectID});
+    let rationDatas = await ration_model.model.find({'projectID':projectID});
+    gljUtil.calcProjectGLJQuantity(projectGLJDatas,rationGLJDatas,rationDatas,[],q_decimal)
 }

+ 21 - 1
public/gljUtil.js

@@ -17,7 +17,11 @@ module.exports = {
     getBasePrice:getBasePrice,
     getAdjustPrice:getAdjustPrice,
     getGljTypeSeq:getGljTypeSeq,
-    sortRationGLJ:sortRationGLJ
+    sortRationGLJ:sortRationGLJ,
+    getEngineerCostData:getEngineerCostData,
+    getEconomicDatas:getEconomicDatas,
+    getMainMaterialDatas:getMainMaterialDatas,
+    getQuantityDatas:getQuantityDatas
 };
 
 function calcProjectGLJQuantity(projectGLJDatas,rationGLJDatas,rationDatas,billsDatas,q_decimal) {
@@ -50,4 +54,20 @@ function getGljTypeSeq() {
 
 function sortRationGLJ(list,std) {
     return gljNodeUtil.sortRationGLJ(list,std);
+}
+
+function getEngineerCostData(property,bills,fixedFlag,scMathUtil) {
+    return gljNodeUtil.getEngineerCostData(property,bills,fixedFlag,scMathUtil);
+}
+
+function getEconomicDatas(engineerFeatures,economics,bills,fixedFlag,_,scMathUtil,decimal) {
+    return gljNodeUtil.getEconomicDatas(engineerFeatures,economics,bills,fixedFlag,_,scMathUtil,decimal);
+}
+
+function getMainMaterialDatas(engineerFeatures,materials,projectGLJData,calcOptions,decimalObj,isRadio,_,scMathUtil) {
+    return gljNodeUtil.getMainMaterialDatas(engineerFeatures,materials,projectGLJData,calcOptions,decimalObj,isRadio,_,scMathUtil);
+}
+
+function getQuantityDatas(engineerFeatures,mainQuantities,billsList,fixedFlag,_,scMathUtil,decimal) {
+    return gljNodeUtil.getQuantityDatas(engineerFeatures,mainQuantities,billsList,fixedFlag,_,scMathUtil,decimal);
 }

+ 232 - 0
public/web/gljUtil.js

@@ -319,6 +319,238 @@ let gljUtil = {
             return scMathUtil.roundToString(quantity * glj.quantity, gd);
         }
     },
+    getEngineerCostData:function(property,bills,fixedFlag,scMathUtil){
+        let priceIndex = {
+            name:"工程造价指标",
+            attrs:[],
+            children:[],
+        };
+        let fixMap = {};
+        let buildingArea = this.getBuildArea(property.engineerFeatures); //tender.property.projectFeature?getItemValueBykey(tender.property.projectFeature,"buildingArea"):1;//建筑面积
+
+        for(let b of bills){
+            if(b.flags && b.flags.length > 0){
+                let f = _.find(b.flags,{"fieldName":"fixed"});
+                if(f) fixMap[f.flag] = this.getTotalFee(b,scMathUtil,property.decimal);
+            }
+        }
+        //计算其他组织措施费 = 施工组织措施项目下的子项,除了  安全文明施工费、建设工程竣工档案编制费以外的项
+        let CONSTRUCTION_ORGANIZATION = fixMap[fixedFlag.CONSTRUCTION_ORGANIZATION]?fixMap[fixedFlag.CONSTRUCTION_ORGANIZATION]:0;
+        let SAFETY_CONSTRUCTION =  fixMap[fixedFlag.SAFETY_CONSTRUCTION]?fixMap[fixedFlag.SAFETY_CONSTRUCTION]:0;
+        let PROJECT_COMPLETE_ARCH_FEE =  fixMap[fixedFlag.PROJECT_COMPLETE_ARCH_FEE]? fixMap[fixedFlag.PROJECT_COMPLETE_ARCH_FEE]:0;
+        let other_org_fee = CONSTRUCTION_ORGANIZATION - SAFETY_CONSTRUCTION - PROJECT_COMPLETE_ARCH_FEE;
+        other_org_fee = other_org_fee >0 ?other_org_fee:0;
+        let engineerCost = fixMap[fixedFlag.ENGINEERINGCOST]?fixMap[fixedFlag.ENGINEERINGCOST]:1;
+        priceIndex.children.push(this.getEngineerFlag("分部分项工程费",fixMap[fixedFlag.SUB_ENGINERRING],engineerCost,buildingArea,scMathUtil));
+        priceIndex.children.push(this.getEngineerFlag("技术措施费",fixMap[fixedFlag.CONSTRUCTION_TECH],engineerCost,buildingArea,scMathUtil));
+        priceIndex.children.push(this.getEngineerFlag("安全文明施工费",fixMap[fixedFlag.SAFETY_CONSTRUCTION],engineerCost,buildingArea,scMathUtil));
+        priceIndex.children.push(this.getEngineerFlag("建设工程竣工档案编制费",fixMap[fixedFlag.PROJECT_COMPLETE_ARCH_FEE],engineerCost,buildingArea,scMathUtil));
+        priceIndex.children.push(this.getEngineerFlag("其他组织措施费",other_org_fee,engineerCost,buildingArea,scMathUtil));
+        priceIndex.children.push(this.getEngineerFlag("暂列金额",fixMap[fixedFlag.PROVISIONAL],engineerCost,buildingArea,scMathUtil));
+        priceIndex.children.push(this.getEngineerFlag("专业工程暂估价",fixMap[fixedFlag.ENGINEERING_ESITIMATE],engineerCost,buildingArea,scMathUtil));
+        priceIndex.children.push(this.getEngineerFlag("计日工",fixMap[fixedFlag.DAYWORK],engineerCost,buildingArea,scMathUtil));
+        priceIndex.children.push(this.getEngineerFlag("总承包服务费",fixMap[fixedFlag.TURN_KEY_CONTRACT],engineerCost,buildingArea,scMathUtil));
+        priceIndex.children.push(this.getEngineerFlag("索赔与现场签证",fixMap[fixedFlag.CLAIM_VISA],engineerCost,buildingArea,scMathUtil));
+        priceIndex.children.push(this.getEngineerFlag("规费",fixMap[fixedFlag.CHARGE],engineerCost,buildingArea,scMathUtil));
+        priceIndex.children.push(this.getEngineerFlag("税金",fixMap[fixedFlag.TAX],engineerCost,buildingArea,scMathUtil));
+        priceIndex.children.push(this.getEngineerFlag("工程造价",fixMap[fixedFlag.ENGINEERINGCOST],engineerCost,buildingArea,scMathUtil));
+        return priceIndex;
+    },
+    getBuildArea:function (features) {
+        if(features){
+            let areas = [];
+            for(let f of features){
+                if(f.index == true && f.value && f.value !=="" && this.IsNumber(f.value)) areas.push(f.value);
+            }
+            return areas.length==0?1:areas;
+        }
+        return 1
+    },
+    getEngineerFlag: function (name,totalCost,engineerCost,buildingArea,scMathUtil) {
+        totalCost = totalCost?totalCost:0;
+        let flag = {
+            name:name,
+            attrs:[
+                {name: "金额", value: scMathUtil.roundToString(totalCost,3)},
+                {name: "单方造价", value: scMathUtil.roundToString(this.calcUnitB(totalCost,buildingArea,scMathUtil),2)},
+                {name: "占造价比例", value: scMathUtil.roundToString(totalCost/engineerCost * 100,2)},
+            ],
+        };
+        return flag;
+    },
+    getTotalFee:function (b,scMathUtil,decimal) {
+        let total = 0;
+        if(b.fees && b.fees.length > 0){
+            for(let f of b.fees){
+                if(f.fieldName == "common"){
+                    total = scMathUtil.roundForObj(f.totalFee,decimal?decimal.bills.totalPrice:getDecimal("bills.totalPrice"));
+                }
+            }
+        }
+        return total;
+    },
+     IsNumber : function(pstrVal){
+        let dblNo = Number.NaN;
+        dblNo = new Number(pstrVal);
+        if (isNaN(dblNo)) return false;
+        return true;
+     },
+    calcUnitB:function (total,building,scMathUtil,coe,decimal = 3) {
+        if(Array.isArray(building)){
+            for(let b of building){
+                total = scMathUtil.roundForObj(total/b,6);
+            }
+        }else {
+            total = scMathUtil.roundForObj(total/building,6);
+        }
+        coe = gljUtil.isDef(coe)?coe:1;
+        return scMathUtil.roundForObj(total*coe,decimal);
+    },
+    getEconomicDatas:function(engineerFeatures,economics,billsList,fixedFlag,_,scMathUtil,decimal){
+        let datas = [];
+        let [bills,totalFee] = gljUtil.getIndexBills(billsList,fixedFlag,_,scMathUtil,decimal);
+        let billsGroup = _.groupBy(bills,'economicType');
+        if(!economics) return datas;
+        for(let e of economics){
+            let tem = {
+                name:e.name,
+                cost:0,
+                unitCost:0,
+                per:0
+            };
+            if(billsGroup[e.name]) setEconomics(billsGroup[e.name],totalFee,tem);
+            datas.push(tem);
+        }
+        function setEconomics(items,engineerCost,data) {
+            let cost = 0;
+            let priceDe = decimal?decimal.bills.totalPrice:getDecimal("bills.totalPrice");//getDecimal("bills.totalPrice");
+            for(let i of items){
+                i.totalFee =  scMathUtil.roundForObj(i.totalFee,priceDe);
+                cost = scMathUtil.roundForObj(cost + i.totalFee,decimal?decimal.process:getDecimal("process"))//getDecimal("process");
+            }
+            data.cost = scMathUtil.roundForObj(cost,priceDe,_);
+            data.unitCost = gljUtil.calUnitWidthCoe(data.cost,true,engineerFeatures,_,scMathUtil);//noNeedCoe = true 这里不需要乘以系数
+            data.per = engineerCost?scMathUtil.roundForObj(data.cost/engineerCost * 100,2):0;
+        }
+
+        return datas;
+    },
+    calUnitWidthCoe:function (total,noNeedCoe,engineerFeatures,_,scMathUtil) {
+        let areas = gljUtil.getBuildArea(engineerFeatures);
+        let f = _.find(engineerFeatures,{index:true});
+        return f && noNeedCoe!==true?gljUtil.calcUnitB(total,areas,scMathUtil,f.coe):gljUtil.calcUnitB(total,areas,scMathUtil);
+    },
+    getIndexBills:function (bills,fixedFlag,_,scMathUtil,decimal) {
+        let parentMap = {},datas = [],totalCost = 0;
+        let FBFX_b = null,teh_b = null,costNode=null;
+        for(let b of bills) {
+            parentMap[b.ParentID] ? parentMap[b.ParentID].push(b) : parentMap[b.ParentID] = [b];//有添加,无则生成
+            if(b.flags && b.flags.length > 0){
+                let f = _.find(b.flags,{"fieldName":"fixed"});
+                if(!f) continue;
+                if(f.flag == fixedFlag.SUB_ENGINERRING) FBFX_b = b;//过滤出分部分项工程;
+                if(f.flag == fixedFlag.CONSTRUCTION_TECH) teh_b = b;//过滤出技术措施项目;
+                if(f.flag == fixedFlag.ENGINEERINGCOST) costNode = b;//过滤出工程造价项目;
+            }
+        }
+        if(FBFX_b) getChildren(FBFX_b,parentMap,datas);
+        if(teh_b) getChildren(teh_b,parentMap,datas);
+        if(costNode) totalCost = gljUtil.getTotalFee(costNode,scMathUtil,decimal);
+
+        for(let td of datas){
+            if(parentMap[td.ID]){
+                td.economicType = "";
+                td.quantityIndexType = "";
+                td.quantityIndexUnit = "";
+                td.quantityIndexCoe = "";
+            }
+        }
+        return [datas,totalCost];
+
+        function getChildren(d,map,arr) {
+            let tem = {
+                ID:d.ID,
+                ParentID:d.ParentID,
+                code:d.code,
+                name:d.name,
+                unit:d.unit,
+                quantity:d.quantity,
+                totalFee:gljUtil.getTotalFee(d,scMathUtil,decimal),
+                economicType:d.economicType,
+                quantityIndexType:d.quantityIndexType,
+                quantityIndexUnit:d.quantityIndexUnit,
+                quantityIndexCoe:d.quantityIndexCoe,
+            };
+            arr.push(tem);
+            if(map[d.ID]){
+                for(let s of map[d.ID]){
+                    getChildren(s,map,arr)
+                }
+            }
+        }
+    },
+    getMainMaterialDatas:function (engineerFeatures,materials,projectGLJData,calcOptions,decimalObj,isRadio,_,scMathUtil) {
+        let datas = [];
+        let materialGroup = _.groupBy(projectGLJData.gljList,'materialIndexType');
+        if(!materials) return datas;
+        for(let m of materials){
+            let tem = {
+                name:m.name,
+                unit:m.unit,
+                unitPrice:0,
+                quantity:0,
+                unitIndex:0
+            };
+            if(materialGroup[m.name]) setMainMaterial(materialGroup[m.name],tem);
+            datas.push(tem);
+        }
+
+        function setMainMaterial(gljs,data) {
+            let quantity = 0 ,unitPrice=0;
+            for(let g of gljs){
+                if(!g.quantity || g.quantity=="") continue;
+                let marketPrice = gljUtil.getMarketPrice(g,projectGLJData,calcOptions,decimalObj,false,_,scMathUtil); // gljOprObj.setGLJPrice(tem,g);
+                let materialIndexCoe = g.materialIndexCoe?scMathUtil.roundForObj(g.materialIndexCoe,decimalObj.process):0;
+                let t_quantity = scMathUtil.roundForObj(g.quantity * materialIndexCoe,decimalObj.process);
+                quantity = scMathUtil.roundForObj(t_quantity + quantity,decimalObj.process);
+                let temPrice = scMathUtil.roundForObj(g.quantity * marketPrice,decimalObj.process);
+                unitPrice = scMathUtil.roundForObj(temPrice + unitPrice,decimalObj.process);
+            }
+            data.quantity = scMathUtil.roundForObj(quantity,2);
+            if(data.quantity) data.unitPrice = scMathUtil.roundForObj(unitPrice/data.quantity,2);
+            data.unitIndex = gljUtil.calUnitWidthCoe(data.quantity,false,engineerFeatures,_,scMathUtil);
+        }
+
+        return datas;
+    },
+    getQuantityDatas:function (engineerFeatures,mainQuantities,billsList,fixedFlag,_,scMathUtil,decimal) {//主要工程量指标
+        let datas = [];
+        let [bills,totalFee] = gljUtil.getIndexBills(billsList,fixedFlag,_,scMathUtil,decimal);//bills,fixedFlag,_,scMathUtil
+        let billsGroup = _.groupBy(bills,'quantityIndexType');
+        if(!mainQuantities) return datas;
+        for(let m of mainQuantities){
+            let tem = {
+                name : m.name,
+                quantityIndexUnit:m.unit,
+                quantity:0
+            };
+            if(billsGroup[m.name]) setQuantities(billsGroup[m.name],tem);
+
+            datas.push(tem);
+        }
+
+        function setQuantities(items,data) {
+            let quantity = 0;
+            for (let i of items){
+                let coe = i.quantityIndexCoe && i.quantityIndexCoe!=""?parseFloat(i.quantityIndexCoe):0;
+                i.quantity = scMathUtil.roundForObj(parseFloat(i.quantity)*coe,decimal.process);
+                quantity = scMathUtil.roundForObj(quantity +  i.quantity,decimal.process);
+            }
+            data.quantity = gljUtil.calUnitWidthCoe(quantity,false,engineerFeatures,_,scMathUtil);
+        }
+
+        return datas;
+    },
     fixedFlag : {
         // 分部分项工程
         SUB_ENGINERRING: 1,

+ 8 - 119
web/building_saas/main/js/models/exportSEIInterface.js

@@ -4,136 +4,25 @@
 
 let exportUtil = {
     setEngineerPriceIndex:function (tender,projectData) {
-        let priceIndex = {
-            name:"工程造价指标",
-            attrs:[],
-            children:[],
-        };
-        let fixMap = {};
-        let buildingArea = this.getBuildArea(tender.property.engineerFeatures); //tender.property.projectFeature?getItemValueBykey(tender.property.projectFeature,"buildingArea"):1;//建筑面积
-
-        for(let b of projectData.bills){
-            if(b.flags && b.flags.length > 0){
-                let f = _.find(b.flags,{"fieldName":"fixed"});
-                if(f) fixMap[f.flag] = this.getTotalFee(b);
-            }
-        }
-        //计算其他组织措施费 = 施工组织措施项目下的子项,除了  安全文明施工费、建设工程竣工档案编制费以外的项
-        let CONSTRUCTION_ORGANIZATION = fixMap[fixedFlag.CONSTRUCTION_ORGANIZATION]?fixMap[fixedFlag.CONSTRUCTION_ORGANIZATION]:0;
-        let SAFETY_CONSTRUCTION =  fixMap[fixedFlag.SAFETY_CONSTRUCTION]?fixMap[fixedFlag.SAFETY_CONSTRUCTION]:0;
-        let PROJECT_COMPLETE_ARCH_FEE =  fixMap[fixedFlag.PROJECT_COMPLETE_ARCH_FEE]? fixMap[fixedFlag.PROJECT_COMPLETE_ARCH_FEE]:0;
-        let other_org_fee = CONSTRUCTION_ORGANIZATION - SAFETY_CONSTRUCTION - PROJECT_COMPLETE_ARCH_FEE;
-        other_org_fee = other_org_fee >0 ?other_org_fee:0;
-        let engineerCost = fixMap[fixedFlag.ENGINEERINGCOST]?fixMap[fixedFlag.ENGINEERINGCOST]:1;
-        priceIndex.children.push(this.getFlag("分部分项工程费",fixMap[fixedFlag.SUB_ENGINERRING],engineerCost,buildingArea));
-        priceIndex.children.push(this.getFlag("技术措施费",fixMap[fixedFlag.CONSTRUCTION_TECH],engineerCost,buildingArea));
-        priceIndex.children.push(this.getFlag("安全文明施工费",fixMap[fixedFlag.SAFETY_CONSTRUCTION],engineerCost,buildingArea));
-        priceIndex.children.push(this.getFlag("建设工程竣工档案编制费",fixMap[fixedFlag.PROJECT_COMPLETE_ARCH_FEE],engineerCost,buildingArea));
-        priceIndex.children.push(this.getFlag("其他组织措施费",other_org_fee,engineerCost,buildingArea));
-        priceIndex.children.push(this.getFlag("暂列金额",fixMap[fixedFlag.PROVISIONAL],engineerCost,buildingArea));
-        priceIndex.children.push(this.getFlag("专业工程暂估价",fixMap[fixedFlag.ENGINEERING_ESITIMATE],engineerCost,buildingArea));
-        priceIndex.children.push(this.getFlag("计日工",fixMap[fixedFlag.DAYWORK],engineerCost,buildingArea));
-        priceIndex.children.push(this.getFlag("总承包服务费",fixMap[fixedFlag.TURN_KEY_CONTRACT],engineerCost,buildingArea));
-        priceIndex.children.push(this.getFlag("索赔与现场签证",fixMap[fixedFlag.CLAIM_VISA],engineerCost,buildingArea));
-        priceIndex.children.push(this.getFlag("规费",fixMap[fixedFlag.CHARGE],engineerCost,buildingArea));
-        priceIndex.children.push(this.getFlag("税金",fixMap[fixedFlag.TAX],engineerCost,buildingArea));
-        priceIndex.children.push(this.getFlag("工程造价",fixMap[fixedFlag.ENGINEERINGCOST],engineerCost,buildingArea));
-        return priceIndex;
+       return gljUtil.getEngineerCostData(tender.property,projectData.bills,fixedFlag,scMathUtil);
     },
     getTotalFee:function (b) {
-        let total = 0;
-        if(b.fees && b.fees.length > 0){
-            let common = _.find(b.fees,{"fieldName":"common"});
-            if(common) total = scMathUtil.roundForObj(common.totalFee,getDecimal("bills.totalPrice"))
-        }
-        return total;
+        return gljUtil.getTotalFee(b,scMathUtil);
     },
     getFlag: function (name,totalCost,engineerCost,buildingArea) {
-        totalCost = totalCost?totalCost:0;
-        let flag = {
-            name:name,
-            attrs:[
-                {name: "金额", value: scMathUtil.roundToString(totalCost,3)},
-                {name: "单方造价", value: scMathUtil.roundToString(exportUtil.calcUnitB(totalCost,buildingArea),2)},
-                {name: "占造价比例", value: scMathUtil.roundToString(totalCost/engineerCost * 100,2)},
-            ],
-        };
-        return flag;
+        return gljUtil.getEngineerFlag(name,totalCost,engineerCost,buildingArea);
     },
     getBuildArea:function (features) {
-        if(features){
-            let areas = [];
-            for(let f of features){
-                if(f.index == true && f.value && f.value !=="" && IsNumber(f.value)) areas.push(f.value);
-            }
-            return _.isEmpty(areas)?1:areas;
-        }
-        return 1
+        return gljUtil.getBuildArea(features)
     },
-    calcUnitB:function (total,building,coe,decimal = 3) {
-        if(Array.isArray(building)){
-            for(let b of building){
-                total = scMathUtil.roundForObj(total/b,6);
-            }
-        }else {
-            total = scMathUtil.roundForObj(total/building,6);
-        }
-        coe = gljUtil.isDef(coe)?coe:1;
-        return scMathUtil.roundForObj(total*coe,decimal);
+    calcUnitB:function (total,building,scMathUtil,coe,decimal = 3) {
+        return gljUtil.calcUnitB(total,building,scMathUtil,coe,decimal)
     },
     calUnitWidthCoe:function (total,noNeedCoe) {
-        let areas = exportUtil.getBuildArea(projectObj.project.property.engineerFeatures);
-        let f = _.find(projectObj.project.property.engineerFeatures,{index:true});
-        return f && noNeedCoe!==true?exportUtil.calcUnitB(total,areas,f.coe):exportUtil.calcUnitB(total,areas);
+        return gljUtil.calUnitWidthCoe(total,noNeedCoe,projectObj.project.property.engineerFeatures,_,scMathUtil);
     },
     getIndexBills:function (bills) {
-        let parentMap = {},datas = [],totalCost = 0;
-        let FBFX_b = null,teh_b = null,costNode=null;
-        for(let b of bills) {
-            parentMap[b.ParentID] ? parentMap[b.ParentID].push(b) : parentMap[b.ParentID] = [b];//有添加,无则生成
-            if(b.flags && b.flags.length > 0){
-                let f = _.find(b.flags,{"fieldName":"fixed"});
-                if(!f) continue;
-                if(f.flag == fixedFlag.SUB_ENGINERRING) FBFX_b = b;//过滤出分部分项工程;
-                if(f.flag == fixedFlag.CONSTRUCTION_TECH) teh_b = b;//过滤出技术措施项目;
-                if(f.flag == fixedFlag.ENGINEERINGCOST) costNode = b;//过滤出工程造价项目;
-            }
-        }
-        if(FBFX_b) getChildren(FBFX_b,parentMap,datas);
-        if(teh_b) getChildren(teh_b,parentMap,datas);
-        if(costNode) totalCost = exportUtil.getTotalFee(costNode);
-
-        for(let td of datas){
-            if(parentMap[td.ID]){
-                td.economicType = "";
-                td.quantityIndexType = "";
-                td.quantityIndexUnit = "";
-                td.quantityIndexCoe = "";
-            }
-        }
-        return [datas,totalCost];
-
-        function getChildren(d,map,arr) {
-            let tem = {
-                ID:d.ID,
-                ParentID:d.ParentID,
-                code:d.code,
-                name:d.name,
-                unit:d.unit,
-                quantity:d.quantity,
-                totalFee:exportUtil.getTotalFee(d),
-                economicType:d.economicType,
-                quantityIndexType:d.quantityIndexType,
-                quantityIndexUnit:d.quantityIndexUnit,
-                quantityIndexCoe:d.quantityIndexCoe,
-            };
-            arr.push(tem);
-            if(map[d.ID]){
-                for(let s of map[d.ID]){
-                    getChildren(s,map,arr)
-                }
-            }
-        }
+        return gljUtil.getIndexBills(bills,fixedFlag,_,scMathUtil);
     }
 };
 

+ 6 - 62
web/building_saas/main/js/views/index_view.js

@@ -259,7 +259,7 @@ let indexObj= {
                     cost:parseFloat(c.attrs[0].value),
                     unitCost:parseFloat(c.attrs[1].value),
                     per:parseFloat(c.attrs[2].value)
-                }
+                };
                 datas.push(tem);
             }
             return datas;
@@ -288,7 +288,8 @@ let indexObj= {
         sheet.setRowCount(quantityDatas.length);
     },
     getQuantityDatas:function (mainQuantities,billsList) {
-        let datas = [];
+        return gljUtil.getQuantityDatas(projectObj.project.property.engineerFeatures,mainQuantities,billsList,fixedFlag,_,scMathUtil,projectObj.project.property.decimal)
+       /* let datas = [];
         let [bills,totalFee] = exportUtil.getIndexBills(billsList);
         let billsGroup = _.groupBy(bills,'quantityIndexType');
         if(!mainQuantities) return datas;
@@ -313,71 +314,14 @@ let indexObj= {
             data.quantity = exportUtil.calUnitWidthCoe(quantity);
         }     
         
-        return datas;
+        return datas;*/
     },
     getEconomicDatas:function (economics,billsList) {
-        let datas = [];
-        let [bills,totalFee] = exportUtil.getIndexBills(billsList);
-        let billsGroup = _.groupBy(bills,'economicType');
-        if(!economics) return datas;
-        for(let e of economics){
-            let tem = {
-                name:e.name,
-                cost:0,
-                unitCost:0,
-                per:0
-            };
-            if(billsGroup[e.name]) setEconomics(billsGroup[e.name],totalFee,tem);
-            datas.push(tem);
-        }
-        function setEconomics(items,engineerCost,data) {
-            let cost = 0;
-            let priceDe = getDecimal("bills.totalPrice");
-            for(let i of items){
-                i.totalFee =  scMathUtil.roundForObj(i.totalFee,priceDe);
-                cost = scMathUtil.roundForObj(cost + i.totalFee,getDecimal("process"));
-            }
-            data.cost = scMathUtil.roundForObj(cost,priceDe);
-            data.unitCost = exportUtil.calUnitWidthCoe(data.cost,true);//noNeedCoe = true 这里不需要乘以系数
-            data.per = engineerCost?scMathUtil.roundForObj(data.cost/engineerCost * 100,2):0;
-        }
-
-        return datas;
+        return gljUtil.getEconomicDatas(projectObj.project.property.engineerFeatures,economics,billsList,fixedFlag,_,scMathUtil);
     },
 
     getMainMaterialDatas:function (materials,projectGLJData,calcOptions,decimalObj,isRadio,_,scMathUtil) {
-        let datas = [];
-        let materialGroup = _.groupBy(projectGLJData.gljList,'materialIndexType');
-        if(!materials) return datas;
-        for(let m of materials){
-            let tem = {
-                name:m.name,
-                unit:m.unit,
-                unitPrice:0,
-                quantity:0,
-                unitIndex:0
-            };
-            if(materialGroup[m.name]) setMainMaterial(materialGroup[m.name],tem);
-            datas.push(tem);
-        }
-
-        function setMainMaterial(gljs,data) {
-            let quantity = 0 ,unitPrice=0;
-            for(let g of gljs){
-                if(!g.quantity || g.quantity=="") continue;
-                let marketPrice = gljUtil.getMarketPrice(g,projectGLJData,calcOptions,decimalObj,false,_,scMathUtil); // gljOprObj.setGLJPrice(tem,g);
-                let materialIndexCoe = g.materialIndexCoe?scMathUtil.roundForObj(g.materialIndexCoe,getDecimal("process")):0;
-                let t_quantity = scMathUtil.roundForObj(g.quantity * materialIndexCoe,getDecimal("process"));
-                quantity = scMathUtil.roundForObj(t_quantity + quantity,getDecimal("process"));
-                let temPrice = scMathUtil.roundForObj(g.quantity * marketPrice,getDecimal("process"));
-                unitPrice = scMathUtil.roundForObj(temPrice + unitPrice,getDecimal("process"));
-            }
-            data.quantity = scMathUtil.roundForObj(quantity,2);
-            if(data.quantity) data.unitPrice = scMathUtil.roundForObj(unitPrice/data.quantity,2);
-            data.unitIndex = exportUtil.calUnitWidthCoe(data.quantity);
-        }
-
-        return datas;
+        return gljUtil.getMainMaterialDatas(projectObj.project.property.engineerFeatures,materials,projectGLJData,calcOptions,decimalObj,isRadio,_,scMathUtil);
     },
     showEcoQuantity:function () {
         let parentMap = {};

+ 2 - 2
web/building_saas/main/js/views/project_view.js

@@ -1322,7 +1322,7 @@ var projectObj = {
                         return !project.Ration.canAdd(project.mainTree.selected);
                     },
                     callback: function (key, opt) {
-                        project.Ration.addNewRation(null,rationType.ration,projectObj.selectColAndFocus,true);
+                        project.Ration.addNewRation(null,rationType.ration,projectObj.selectColAndFocus,false);
                        // ProjectController.addRation(project, controller, rationType.ration);
                     }/*,
                     visible: function(key, opt){
@@ -1953,7 +1953,7 @@ var projectObj = {
         TREE_SHEET_HELPER.massOperationSheet(sheet, function () {
             for(let node of nodes){
                 if(node && node.serialNo()!= -1){
-                    sheet.getRange(node.serialNo(), -1, 1, -1).backColor(me.getNodeColorStyle(sheet, node,tree).backColor);
+                    sheet.getRange(node.serialNo(), -1, 1, -1).backColor(me.getNodeColorStyle(sheet, node,tree)?me.getNodeColorStyle(sheet, node,tree).backColor:null);
                 }
             }
         });

+ 1 - 1
web/building_saas/main/js/views/zmhs_view.js

@@ -263,7 +263,7 @@ let zmhs_obj = {
         $('#assSpread').is(':visible')&&this.assSpread?this.assSpread.refresh():'';
     },
     showDatas:function () {
-        if($('#itemCharacterText').is(':visible'))MaterialController.showItemCharacterText()
+        if($('#itemCharacterText').is(':visible'))MaterialController.showItemCharacterText();
         if($('#coeSpread').is(':visible')) this.showCoeData();
         if($('#cusSpread').is(':visible')) this.showCusData();
         if($('#assSpread').is(':visible')) this.showAssData();