Преглед изворни кода

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

zhongzewei пре 6 година
родитељ
комит
2bd3cc307d

+ 1 - 1
config/gulpConfig.js

@@ -146,7 +146,7 @@ module.exports = {
         'web/building_saas/main/js/views/zlfb_view.js',
         'web/building_saas/main/js/views/installation_fee_view.js',
         'web/building_saas/main/js/views/material_adjust_view.js',
-        'web/building_saas/main/js/views/index_view.js.js',
+        'web/building_saas/main/js/views/index_view.js',
         'web/building_saas/main/js/views/project_glj_view.js',
         'web/building_saas/main/js/views/importBills.js',
         'public/web/rpt_tpl_def.js',

+ 5 - 0
public/web/sheet/sheet_common.js

@@ -133,6 +133,11 @@ var sheetCommonObj = {
             }
 
             for (let row = 0; row < data.length; row++) {
+                if(data[row].cellType === 'comboBox'){
+                    let options = data[row].options ? data[row].options.split("@") : [];
+                    this.setComboBox(row,col,sheet,options);
+                }
+
                 let val = data[row][setting.header[col].dataCode];
                 if(val&&setting.header[col].dataType === "Number"){
                     if(setting.header[col].hasOwnProperty('decimalField')){

+ 147 - 6
web/building_saas/main/js/models/exportSEIInterface.js

@@ -81,10 +81,10 @@ let exportUtil = {
         coe = coe?coe:1;
         return scMathUtil.roundForObj(total*coe,decimal);
     },
-    calUnitWidthCoe:function (total) {
+    calUnitWidthCoe:function (total,noNeedCoe) {
         let areas = exportUtil.getBuildArea(projectObj.project.property.engineerFeatures);
         let f = _.find(projectObj.project.property.engineerFeatures,{index:true});
-        return f?exportUtil.calcUnitB(total,areas,f.coe):exportUtil.calcUnitB(total,areas);
+        return f && noNeedCoe!==true?exportUtil.calcUnitB(total,areas,f.coe):exportUtil.calcUnitB(total,areas);
     },
     getIndexBills:function (bills) {
         let parentMap = {},datas = [],totalCost = 0;
@@ -224,6 +224,7 @@ async function exportSEI(projectID) {
     async function setTenderData(tender,project) {
         let projectData = await ajaxPost("/project/loadSEIProjectData",{projectID:tender.ID});
         tender.children.push(setEngineerInfo(tender));//设置工程信息
+        tender.children.push(setEngineerFeature(tender));//设置工程特征
         tender.children.push(setEngineerIndex(tender,projectData));
         tender.children.push(await setGLJSummy(tender,projectData));
        //
@@ -236,10 +237,106 @@ async function exportSEI(projectID) {
             attrs:[],
             children:[],
         };
-
+        let indexName = tender.property.indexName?tender.property.indexName:"建筑工程";
         index.children.push(exportUtil.setEngineerPriceIndex(tender,projectData));
+        index.children.push(setEngineerEcoIndex(tender,projectData,indexName));
+        index.children.push(setMainMaterialIndex(tender,projectData,indexName));
+        index.children.push(setQuantityIndex(tender,projectData,indexName));
 
         return index;
+
+        function setMainMaterialIndex(tender,projectData,indexName){
+            let mainIndex = {
+                name:`${indexName}工料指标`,
+                attrs:[],
+                children:[]
+            };
+            if(projectData) gljUtil.calcProjectGLJQuantity(projectData.projectGLJs,projectData.ration_gljs,projectData.rations,projectData.bills,getDecimal("glj.quantity"),_,scMathUtil);
+            let materials = indexObj.getMainMaterialDatas(tender.property.materials,projectData.projectGLJs,tender.property.calcOptions,tender.property.decimal,false,_,scMathUtil);
+            for(let m of materials){
+                mainIndex.children.push(getMaterial(m))
+            }
+            let index = {
+                name:"主要工料价格及消耗量指标",
+                attrs:[],
+                children:[mainIndex]
+            };
+            return index;
+
+            function getMaterial(m) {
+                let material = {
+                    name:m.name,
+                    attrs:[
+                        {name:"综合单价",value:scMathUtil.roundToString(m.unitPrice,2)},
+                        {name:"数量",value:scMathUtil.roundToString(m.quantity,2)},
+                        {name:"单方指标",value:scMathUtil.roundToString(m.unitIndex,3)},
+                        {name:"单位",value:m.unit}
+                    ]
+                };
+                return material;
+            }
+
+        }
+
+        function setQuantityIndex(tender,projectData,indexName) {
+            let quantityIndex = {
+                name:`${indexName}量指标`,
+                attrs:[],
+                children:[]
+            };
+            let quantities = indexObj.getQuantityDatas(tender.property.mainQuantities,projectData.bills);
+            for(let q of quantities){
+                quantityIndex.children.push(getQuantity(q));
+            }
+
+            let index = {
+                name:`主要工程量指标`,
+                attrs:[],
+                children:[quantityIndex]
+            };
+            return index;
+
+            function getQuantity(q) {
+                let quantity = {
+                    name:q.name,
+                    attrs:[
+                        {name:"工程量指标",value:scMathUtil.roundToString(q.quantity,3)},
+                        {name:"单位",value:q.unit}
+                    ]
+                };
+                return quantity;
+            }
+        }
+
+        function setEngineerEcoIndex(tender,projectData,indexName) {
+            let ecoIndex = {
+                name:`${indexName}经济指标`,
+                attrs:[],
+                children:[]
+            };
+            let economicDatas = indexObj.getEconomicDatas(tender.property.economics,projectData.bills);
+            for(let e of economicDatas){
+                ecoIndex.children.push(getEco(e))
+            }
+            let index = {
+                name:`工程经济指标`,
+                attrs:[],
+                children:[ecoIndex]
+            };
+            return index;
+
+            function getEco(e) {
+                let eco = {
+                  name:e.name,
+                  attrs:[
+                      {name:"综合合价",value:scMathUtil.roundToString(e.cost,2)},
+                      {name:"单方指标",value:scMathUtil.roundToString(e.unitCost,2)},
+                      {name:"占造价比例",value:scMathUtil.roundToString(e.per,2)}
+                  ]
+                };
+                return eco;
+            }
+        }
     }
 
     async function setGLJSummy(tender,projectData) {
@@ -313,6 +410,52 @@ async function exportSEI(projectID) {
         return info;
     }
 
+    function setEngineerFeature(tender) {
+        let fea = {
+            name:"工程特征",
+            attrs:[],
+            children:[]
+        };
+        fea.children.push(setIndexName(tender));
+        return fea;
+
+        function setIndexName(tender) {
+            let indexName = {
+                name:tender.property.indexName?tender.property.indexName:"建筑工程",
+                attrs:[],
+                children:[]
+            };
+            setFeatures(tender,indexName.children);
+            return indexName
+        }
+        function setFeatures(tender,arr) {
+            let features = tender.property.engineerFeatures?tender.property.engineerFeatures:[];
+            let parentMap = _.groupBy(features,"ParentID");
+            let rootNodes = parentMap["-1"]?parentMap["-1"]:parentMap[null];
+            for(let r of rootNodes){
+                arr.push(getFeatrue(r,parentMap))
+            }
+        }
+
+        function getFeatrue(node,parentMap){
+            if(parentMap[node.ID]){//如果有子节点,那么它就是一个节点
+                let tem = {
+                    name:node.name.replace("*",""),
+                    attrs:[],
+                    children:[]
+                };
+                for(let s of parentMap[node.ID]){
+                    let f = getFeatrue(s,parentMap);
+                    f.children?tem.children.push(f):tem.attrs.push(f);//如果有children这个属性,则返回的是一个节点,如果没有,则返回的是一个属性
+                }
+                return tem;
+            }else {//如果没有子节点,那么它就是父节点的一个属性
+                return {name:node.name.replace("*",""),value:node.value};
+            }
+        }
+    }
+
+
     function getBaseInfo(project){
         let basicInformation = {items:[]};
         let tem = null;
@@ -421,9 +564,7 @@ async function exportSEI(projectID) {
 
 $(function () {
    $("#SEIMenu").click(async function () {
-
-
-       await exportSEI(projectObj.project.property.rootProjectID)
+       await exportSEI(projectObj.project.property.rootProjectID);
        $("#exportMenu").removeClass("show");
    })
 

+ 22 - 17
web/building_saas/main/js/views/index_view.js

@@ -128,7 +128,7 @@ let indexObj= {
         sheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.oEngineerFeatureValueChange);
         sheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onEngineerFeatureRangeChange); //
         sheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onSelectionChange);
-
+        sheet.setRowCount(this.engineerFeatureDatas.length);
         function getDatas() {
             let datas = [];
             if(projectObj.project.property.engineerFeatures){
@@ -138,6 +138,8 @@ let indexObj= {
                         name:f.name,
                         value:f.value,
                         ParentID:f.ParentID,
+                        cellType:f.cellType,
+                        options:f.options,
                         required:f.required,
                         collapsed:false
                     };
@@ -232,8 +234,6 @@ let indexObj= {
     showEngineerFeature:function () {
         this.spread.setActiveSheetIndex(1);
         let sheet = this.spread.getActiveSheet();
-        sheet.setRowCount(0);
-        sheet.setRowCount(this.engineerFeatureDatas.length);
         refreshValue();
         sheetCommonObj.showTreeData(sheet, this.engineerFeatureSetting,this.engineerFeatureDatas);
         function refreshValue() {
@@ -266,8 +266,9 @@ let indexObj= {
     },
     showMainMaterial:function(){
         this.spread.setActiveSheetIndex(3);
+        let property = projectObj.project.property;
         let sheet = this.spread.getActiveSheet();
-        let mainDatas = this.getMainMaterialDatas();
+        let mainDatas = this.getMainMaterialDatas(property.materials,projectObj.project.projectGLJ.datas,property.calcOptions,property.decimal,false,_,scMathUtil);
         sheetCommonObj.showData(sheet, this.mainMaterialSetting,mainDatas);
         sheet.setRowCount(mainDatas.length);
     },
@@ -336,18 +337,16 @@ let indexObj= {
                 cost = scMathUtil.roundForObj(cost + i.totalFee,getDecimal("process"));
             }
             data.cost = scMathUtil.roundForObj(cost,priceDe);
-            data.unitCost = exportUtil.calUnitWidthCoe(data.cost);
+            data.unitCost = exportUtil.calUnitWidthCoe(data.cost,true);//noNeedCoe = true 这里不需要乘以系数
             data.per = engineerCost?scMathUtil.roundForObj(data.cost/engineerCost * 100,2):0;
         }
 
         return datas;
     },
 
-    getMainMaterialDatas:function () {
+    getMainMaterialDatas:function (materials,projectGLJData,calcOptions,decimalObj,isRadio,_,scMathUtil) {
         let datas = [];
-        let materials = projectObj.project.property.materials;
-        let gljList = projectObj.project.projectGLJ.datas.gljList;
-        let materialGroup = _.groupBy(gljList,'materialIndexType');
+        let materialGroup = _.groupBy(projectGLJData.gljList,'materialIndexType');
         if(!materials) return datas;
         for(let m of materials){
             let tem = {
@@ -361,17 +360,15 @@ let indexObj= {
             datas.push(tem);
         }
 
-
         function setMainMaterial(gljs,data) {
             let quantity = 0 ,unitPrice=0;
             for(let g of gljs){
                 if(!g.quantity || g.quantity=="") continue;
-                let tem = {};
-                gljOprObj.setGLJPrice(tem,g);
+                let marketPrice = gljUtil.getMarketPrice(g,projectGLJData,calcOptions,decimalObj,false,_,scMathUtil); // gljOprObj.setGLJPrice(tem,g);
                 let materialIndexCoe = g.materialIndexCoe?scMathUtil.roundForObj(g.materialIndexCoe,getDecimal("process")):1;
                 let t_quantity = scMathUtil.roundForObj(g.quantity * materialIndexCoe,getDecimal("process"));
                 quantity = scMathUtil.roundForObj(t_quantity + quantity,getDecimal("process"));
-                let temPrice = scMathUtil.roundForObj(g.quantity * tem.marketPrice,getDecimal("process"));
+                let temPrice = scMathUtil.roundForObj(g.quantity * marketPrice,getDecimal("process"));
                 unitPrice = scMathUtil.roundForObj(temPrice + unitPrice,getDecimal("process"));
             }
             data.quantity = scMathUtil.roundForObj(quantity,2);
@@ -510,15 +507,23 @@ let indexObj= {
     },
     onEngineerInfoValueChange:function (sender,info) {
         let value = info.newValue;
-        info.sheet.tag(value);
-        var date = info.sheet.tag();
-        // formatDate(new Date(v), 'yyyy-MM-dd');
-        //v = formatDate(new Date(v), 'yyyy-MM-dd');
+        value = indexObj.valueChecking(indexObj.engineerInfoDatas[info.row],value,info.sheet);
         let infos = projectObj.project.property.engineerInfos;
         let data = indexObj.getNewPropertyData([{row:info.row,value:value}],infos);
         if(!data) return indexObj.showDatas();
         indexObj.updateProjectProperty(data,"engineerInfos");
     },
+    valueChecking:function (recode,value,sheet) {
+        if(recode && recode.cellType == "date"){//日期类型要做个转换
+            sheet.tag(value);
+            let data = sheet.tag();
+            value =  formatDate(new Date(data), 'yyyy-MM-dd');
+        }
+         //to do other checking
+        return value
+    },
+
+
     oEngineerFeatureValueChange:function(sender,info){
         let value = info.newValue;
         let features = projectObj.project.property.engineerFeatures;