ソースを参照

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

chenshilong 7 年 前
コミット
ddbf5c0f22

+ 5 - 0
modules/all_models/engineering_lib.js

@@ -52,6 +52,11 @@ let modelSchema = {
         type: Schema.Types.Mixed,
         default: []
     },
+    //工程特征库
+    feature_lib:{
+        type: Schema.Types.Mixed,
+        default: []
+    },
     //设置人材机显示列
     glj_col:{
         showAdjustPrice:Boolean//是否显示调整价列

+ 22 - 0
modules/all_models/project_feature_lib.js

@@ -0,0 +1,22 @@
+/**
+ * Created by zhang on 2018/9/3.
+ */
+
+//工程特征库
+const mongoose = require('mongoose');
+const Schema = mongoose.Schema;
+const oprSchema = require('../all_schemas/opr_schema');
+const project_feature_lib = new Schema({
+        ID:{type:String,index:true},
+        creator: String,
+        createDate: Number,
+        recentOpr: [oprSchema],
+        name: String,
+        feature:{
+            type: [Schema.Types.Mixed],
+            default: []
+        }
+    }, {versionKey: false}
+);
+
+mongoose.model("std_project_feature_lib", project_feature_lib,"std_project_feature_lib");

+ 9 - 1
modules/all_models/std_glj.js

@@ -8,7 +8,11 @@ const Schema = mongoose.Schema;
 const std_gljComponent = new Schema(
     {
         ID: Number,
-        consumeAmt: Number
+        consumeAmt: Number,
+        consumeAmtProperties: {
+            type: Schema.Types.Mixed,
+            default: {}
+        }
     },
     {_id: false},
     {versionKey: false}
@@ -22,6 +26,10 @@ const std_glj = new Schema({
     name: String,
     specs: String,
     basePrice: Number,
+    basePriceProperties: {
+        type: Schema.Types.Mixed,
+        default: {}
+    },
     gljClass: Number,
     gljType: Number,
     model: Number,// 机型

+ 15 - 12
modules/main/facade/ration_facade.js

@@ -40,7 +40,7 @@ async function addNewRation(data) {
     if(data.brUpdate.length>0){
         await updateSerialNo(data.brUpdate);
     }
-    let newRation =await insertNewRation(data.newData,data.firstLibID,stdRation,data.calQuantity);
+    let newRation =await insertNewRation(data.newData,data.defaultLibID,stdRation,data.calQuantity);
     let addRationGLJTime = +new Date();
     console.log("插入新定额时间-------------------------------"+(addRationGLJTime - stdRationTime));
     if(stdRation){
@@ -79,7 +79,7 @@ async function  updateSerialNo(serialNoUpdate){
 
 }
 
-async function insertNewRation(newData,firstLibID,std,calQuantity) {//插入新的定额
+async function insertNewRation(newData,defaultLibID,std,calQuantity) {//插入新的定额
     let startTime = +new Date();
     if(std){
         newData.code = std.code;
@@ -95,13 +95,17 @@ async function insertNewRation(newData,firstLibID,std,calQuantity) {//插入新
         }
         newData.prefix = '';
         newData.from = std.type === 'complementary' ? 'cpt' : 'std';
-        if(firstLibID !== std.rationRepId){//借
+        if(defaultLibID !== std.rationRepId){//借
             newData.prefix = '借';
         }
-        else if(std.rationRepId === firstLibID && newData.from === 'cpt') {
+        else if(std.rationRepId === defaultLibID && newData.from === 'cpt') {
             newData.prefix = '补';
         }
-        newData.programID = std.feeType;
+        if(std.feeType == undefined || std.feeType == null || std.feeType ==''){//定额取费专业为空的情况下,取项目属性中的定额取费专业ID
+            newData.programID = await getProgramForProject(newData.projectID);
+        }else {
+            newData.programID = std.feeType;
+        }
         newData.rationAssList =  createRationAss(std);
         // calculate ration Quantity
     }
@@ -110,7 +114,6 @@ async function insertNewRation(newData,firstLibID,std,calQuantity) {//插入新
     }
     let addRationGLJTime = +new Date();
     console.log("计算消耗量时间-------------------------------"+(addRationGLJTime - startTime));
-    console.log(newData);
     let newRation = await ration_model.model.create(newData);
     return newRation;
     /*ration_model.model.create(newData);
@@ -122,7 +125,7 @@ async function replaceRations(userID,data) {
     let recodes = [];
     for(let recode of data.nodeInfo){
         let stdRation = await searchDao.getRationItem(userID,data.libIDs,recode.newCode, null);
-        let newRecode = await replaceRation(recode,stdRation,data.firstLibID,data.projectID,data.calQuantity);
+        let newRecode = await replaceRation(recode,stdRation,data.defaultLibID,data.projectID,data.calQuantity);
         if(newRecode){
             recodes.push(newRecode);
         }else {
@@ -132,13 +135,13 @@ async function replaceRations(userID,data) {
     return recodes;
 }
 
-async function replaceRation(nodeInfo,stdRation,firstLibID,projectID,calQuantity) {
+async function replaceRation(nodeInfo,stdRation,defaultLibID,projectID,calQuantity) {
     if(nodeInfo.newCode == null||nodeInfo.newCode ==""){//说明是删除编号,则要变成一条空定额
         await deleRationSubRecode(projectID,nodeInfo.ID);//删除定额下挂的各种数据,如定额工料机等
         return await setEmptyRation(projectID,nodeInfo.ID);
     }else if(stdRation){
         await deleRationSubRecode(projectID,nodeInfo.ID);//删除定额下挂的各种数据,如定额工料机等
-        let newRation = await updateRation(stdRation,firstLibID,nodeInfo.ID,nodeInfo.billsItemID,projectID,calQuantity);//生成并插入新的定额
+        let newRation = await updateRation(stdRation,defaultLibID,nodeInfo.ID,nodeInfo.billsItemID,projectID,calQuantity);//生成并插入新的定额
         return await addRationSubList(stdRation,newRation,nodeInfo.needInstall);
     }else {
         return null;
@@ -337,7 +340,7 @@ async function deleRationSubRecode(projectID,rationID) {//删除挂在定额下
     await rationInstallationModel.deleteMany(delete_query);//删除安装增加费
 }
 
-async function  updateRation(std,firstLibID,rationID,billsItemID,projectID,calQuantity) {
+async function  updateRation(std,defaultLibID,rationID,billsItemID,projectID,calQuantity) {
     // insertNewRation
     let ration ={};
     ration.code = std.code;
@@ -358,10 +361,10 @@ async function  updateRation(std,firstLibID,rationID,billsItemID,projectID,calQu
     //定额前缀 none:0, complementary:1, borrow: 2
     ration.prefix = '';
     //借用优先级比补充高
-    if(std.rationRepId !== parseInt(firstLibID)){//借用
+    if(std.rationRepId !== parseInt(defaultLibID)){//借用
         ration.prefix = '借';
     }
-    else if(std.rationRepId === firstLibID && ration.from === 'cpt') {
+    else if(std.rationRepId === defaultLibID && ration.from === 'cpt') {
         ration.prefix = '补';
     }
     if(std.feeType == undefined || std.feeType == null || std.feeType ==''){//定额取费专业为空的情况下,取项目属性中的定额取费专业ID

+ 39 - 8
modules/pm/facade/pm_facade.js

@@ -23,6 +23,8 @@ let rationGLJModel = mongoose.model('ration_glj');
 let rationCoeModel = mongoose.model('ration_coe');
 let rationInstallationModel = mongoose.model('ration_installation');
 let quantityDetailModel = mongoose.model('quantity_detail');
+
+let featureLibModel =  mongoose.model("std_project_feature_lib");
 let scMathUtil = require('../../../public/scMathUtil').getUtil();
 import CounterModel from "../../glj/models/counter_model";
 import moment from 'moment';
@@ -43,6 +45,7 @@ module.exports={
     getSummaryInfoByTender: getSummaryInfoByTender,
     getConstructionProject: getConstructionProject,
     getFullPath: getFullPath,
+    getProjectFeature:getProjectFeature,
     projectType: projectType
 };
 
@@ -81,10 +84,18 @@ async function copyProject(userID, compilationID,data) {
 
     //更新项目的属性;
     projectMap['copy'].document.ID = newProjectID;
-    projectMap['copy'].document.property.calcProgramFile.ID = calcProgramFileID;
-    projectMap['copy'].document.property.labourCoeFile.ID = labourCoeFileID;
-    projectMap['copy'].document.property.feeFile.id = feeRateFileID;
-    projectMap['copy'].document.property.unitPriceFile.id = unitPriceFileID;
+    if(projectMap['copy'].document.property.calcProgramFile){
+        projectMap['copy'].document.property.calcProgramFile.ID = calcProgramFileID;
+    }
+    if(projectMap['copy'].document.property.labourCoeFile){
+        projectMap['copy'].document.property.labourCoeFile.ID = labourCoeFileID;
+    }
+    if(projectMap['copy'].document.property.feeFile){
+        projectMap['copy'].document.property.feeFile.id = feeRateFileID;
+    }
+    if(projectMap['copy'].document.property.unitPriceFile){
+        projectMap['copy'].document.property.unitPriceFile.id = unitPriceFileID;
+    }
     projectMap['copy'].document.userID = userID;
     projectMap['copy'].document.compilation = compilationID;
     projectMap['copy'].document.createDateTime = new Date();
@@ -104,16 +115,24 @@ async function copyProject(userID, compilationID,data) {
         copyBills(newProjectID,billMap),
         copyRations(newProjectID,billMap.uuidMaping,rationMap,projectGLJMap.IDMap),
         copyProjectGLJ(projectGLJMap.datas),
-        commonCopy(newProjectID,originalProperty.calcProgramFile.ID,calcProgramFileID,calcProgramsModel),
-        commonCopy(newProjectID,originalProperty.labourCoeFile.ID,labourCoeFileID,labourCoesModel),
-        copyFeeRate(originalProperty.rootProjectID,userID,originalProperty.feeFile.id,feeRateFileID,newFeeName),
-        copyUnitPriceFile(newProjectID,originalProperty.rootProjectID,userID,originalProperty.unitPriceFile.id,unitPriceFileID,newUnitName),
         copyInstallFee(originalID,newProjectID),
         copyRationSubList(originalID,newProjectID,billMap.uuidMaping,rationMap.uuidMaping,projectGLJMap.IDMap,rationGLJModel),
         copyRationSubList(originalID,newProjectID,billMap.uuidMaping,rationMap.uuidMaping,projectGLJMap.IDMap,rationCoeModel),
         copyRationSubList(originalID,newProjectID,billMap.uuidMaping,rationMap.uuidMaping,projectGLJMap.IDMap,quantityDetailModel),
         copyRationSubList(originalID,newProjectID,billMap.uuidMaping,rationMap.uuidMaping,projectGLJMap.IDMap,rationInstallationModel)
     ];
+    if(originalProperty.calcProgramFile){
+        copyTasks.push(commonCopy(newProjectID,originalProperty.calcProgramFile.ID,calcProgramFileID,calcProgramsModel));
+    }
+    if(originalProperty.labourCoeFile){
+        copyTasks.push(commonCopy(newProjectID,originalProperty.labourCoeFile.ID,labourCoeFileID,labourCoesModel));
+    }
+    if(originalProperty.feeFile){
+        copyTasks.push(copyFeeRate(originalProperty.rootProjectID,userID,originalProperty.feeFile.id,feeRateFileID,newFeeName));
+    }
+    if(originalProperty.unitPriceFile){
+        copyTasks.push(copyUnitPriceFile(newProjectID,originalProperty.rootProjectID,userID,originalProperty.unitPriceFile.id,unitPriceFileID,newUnitName));
+    }
     let p = await Promise.all(copyTasks);
     return p[0];
 }
@@ -692,4 +711,16 @@ async function getFullPath(projectID) {
             }
         }
     }
+}
+
+async function getProjectFeature(libID,engineerName){
+    let lib = await featureLibModel.findOne({'ID':libID})
+    if(lib){
+        let eng = _.find(lib.feature,{'key':'engineering'})
+        if(eng) eng.value = engineerName;
+        console.log(lib.feature);
+        return lib.feature;
+    }else {
+        return [];
+    }
 }

+ 5 - 2
modules/pm/models/project_model.js

@@ -164,8 +164,11 @@ ProjectsDAO.prototype.updateUserProjects = async function (userId, compilationId
                     //basicInformation[0]['items'][1]['value'] = data.updateData.property.engineeringName || '';
                     //data.updateData.property.basicInformation = basicInformation;
                     //工程特征
-                    projectFeature[0]['value'] = data.updateData.property.engineeringName || '';
-                    data.updateData.property.projectFeature = projectFeature;
+                    if(data.updateData.property.featureLibID){
+                        data.updateData.property.projectFeature = await pmFacade.getProjectFeature(data.updateData.property.featureLibID, data.updateData.property.engineeringName);
+                    }
+                    /*projectFeature[0]['value'] = data.updateData.property.engineeringName || '';
+                    data.updateData.property.projectFeature = projectFeature;*/
 
                     //呈现选项
                     data.updateData.property.displaySetting = displaySetting;

+ 3 - 2
modules/reports/controllers/rpt_tpl_controller.js

@@ -348,8 +348,9 @@ let mExport = {
     updateRptTpl: function (req, res) {
         let params = JSON.parse(req.body.params),
             rptTpl = JSON.parse(params.rptTpl);
-        let filter = {"ID": parseInt(rptTpl[JV.PROP_ID])};
-        RptTplModel.update(filter, rptTpl, function (err, rst) {
+        let filter = {"ID": parseInt(rptTpl[JV.PROP_ID])},
+            options = {"overwrite": true};
+        RptTplModel.update(filter, rptTpl, options, function (err, rst) {
             if (err) {
                 callback(req, res, true, 'The report template was updated failed!', false);
             } else {

+ 0 - 58
modules/reports/rpt_component/jpc_flow_tab.js

@@ -1124,25 +1124,17 @@ function combineAutoHeightCells(prepareObj, page, controls) {
                         if (mergeCell[JV.PROP_VALUE]) {
                             firstMergeCell[JV.PROP_VALUE] = firstMergeCell[JV.PROP_VALUE] + "|" + mergeCell[JV.PROP_VALUE];
                             validValueAmt++;
-                        } else {
-                            // firstMergeCell[JV.PROP_VALUE] = firstMergeCell[JV.PROP_VALUE] + "|" ;
                         }
                         rst.push(sameColCells[i].cellIdx); //记下Cell的位置,在函数外消除
                         //如果到了最后一条数据,得判断firstMergeCell是否满格(即数据是满的,有可能有些格数据也有折行但不是自动行高判断指标)
                         //不满格的cell的Vertical强制设置为 'center'
                         if (i === sameColCells.length - 1 && validValueAmt !== fullValidValueAmt) {
-                            // firstMergeCell[JV.PROP_CONTROL].Shrink = orgCtrl.Shrink;
-                            // firstMergeCell[JV.PROP_CONTROL].Wrap = "F";
-                            // firstMergeCell[JV.PROP_CONTROL].VerticalForExcel = null;
                             firstMergeCell[JV.PROP_CONTROL].VerticalForExcel = 'center';
                         }
                     } else {
                         //碰到新开始的自动行高行,判断原先的firstMergeCell是否满格(即数据是满的,有可能有些格数据也有折行但不是自动行高判断指标)
                         //不满格的cell的Vertical强制设置为 'center'
                         if (validValueAmt !== fullValidValueAmt) {
-                            // firstMergeCell[JV.PROP_CONTROL].Shrink = orgCtrl.Shrink;
-                            // firstMergeCell[JV.PROP_CONTROL].Wrap = "F";
-                            // firstMergeCell[JV.PROP_CONTROL].VerticalForExcel = null;
                             firstMergeCell[JV.PROP_CONTROL].VerticalForExcel = 'center';
                         }
                         firstMergeCell = sameColCells[i].cell;
@@ -1161,54 +1153,4 @@ function combineAutoHeightCells(prepareObj, page, controls) {
     return rst;
 }
 
-function combineAutoHeightCellsBk(prepareObj, page, controls) {
-    let rst = [];
-    if (prepareObj.cellsArr) {
-        //merge cells' value and area
-        //备注: 系统逻辑已经把Cell的顺序放好,无需再做排序。
-        for (let mergeKey in prepareObj.pageCellObj) {
-            let sameColCells = prepareObj.pageCellObj[mergeKey]; //左右位置相同的Cell先放在一起,统一处理
-            if (sameColCells.length > 1) {
-                let firstMergeCell = sameColCells[0].cell;
-                firstMergeCell[JV.PROP_STYLE] = firstMergeCell[JV.PROP_STYLE].slice(0, firstMergeCell[JV.PROP_STYLE].indexOf("_AutoHeightMerge"));
-                let orgCtrl = setupControl(firstMergeCell, controls);
-                let validValueAmt = 0;
-                for (let i = 1; i < sameColCells.length; i++) {
-                    let mergeCell = sameColCells[i].cell;
-                    if (mergeCell[JV.PROP_STYLE].indexOf("_AutoHeightMerge_Top") < 0) {
-                        //merge into the firstMergeCell!
-                        firstMergeCell[JV.PROP_AREA][JV.PROP_BOTTOM] = mergeCell[JV.PROP_AREA][JV.PROP_BOTTOM];
-                        firstMergeCell[JV.PROP_VALUE] = firstMergeCell[JV.PROP_VALUE] + "|" + mergeCell[JV.PROP_VALUE];
-                        if (mergeCell[JV.PROP_VALUE]) validValueAmt++;
-                        rst.push(sameColCells[i].cellIdx);
-                        if (i === sameColCells.length - 1 && validValueAmt === 0) {
-                            firstMergeCell[JV.PROP_CONTROL].Shrink = orgCtrl.Shrink;
-                            firstMergeCell[JV.PROP_CONTROL].Wrap = "F";
-                            firstMergeCell[JV.PROP_CONTROL].VerticalForExcel = null;
-                            // firstMergeCell[JV.PROP_CONTROL].VerticalForExcel = 'center';
-                        }
-                    } else {
-                        if (validValueAmt === 0) {
-                            firstMergeCell[JV.PROP_CONTROL].Shrink = orgCtrl.Shrink;
-                            firstMergeCell[JV.PROP_CONTROL].Wrap = "F";
-                            firstMergeCell[JV.PROP_CONTROL].VerticalForExcel = null;
-                            // firstMergeCell[JV.PROP_CONTROL].VerticalForExcel = 'center';
-                        }
-                        firstMergeCell = sameColCells[i].cell;
-                        firstMergeCell[JV.PROP_STYLE] = firstMergeCell[JV.PROP_STYLE].slice(0, firstMergeCell[JV.PROP_STYLE].indexOf("_AutoHeightMerge"));
-                        orgCtrl = setupControl(firstMergeCell, controls);
-                        validValueAmt = 0;
-                    }
-                }
-            }
-        }
-        rst.sort(function (i1, i2) {
-            return (i1 > i2)?1:-1;
-        });
-    }
-    // fsUtil.writeObjToFile(prepareObj, "D:/GitHome/ConstructionCost/tmp/afterMergeCellsPrepareObj_" + page + ".jsp");
-    // fsUtil.writeObjToFile(rst, "D:/GitHome/ConstructionCost/tmp/eliminateCells_" + page + ".jsp");
-    return rst;
-}
-
 module.exports = new JpcFlowTabSrv();

+ 6 - 2
public/web/gljUtil.js

@@ -210,8 +210,10 @@ let gljUtil = {
         let price_hasM_decimal = decimalObj.glj.unitPriceHasMix?decimalObj.glj.unitPriceHasMix:decimalObj.glj.unitPrice;
         let quantity_decimal = decimalObj.glj.quantity;
         let process_decimal = decimalObj.process;
+
         if (this.notEditType.indexOf(glj.unit_price.type)!=-1&&glj.ratio_data.length>0) {//对于混凝土、配合比、砂浆、机械台班等有组成物的材料,价格需根据组成物计算得出。
-            let p =0;
+            //2018-09-07 需求修改,定额价不按组成物的量和价实时计算出来,直接取单价文件中的定额价
+       /*     let p =0;
             for(let ratio of glj.ratio_data){
                 let tem =  _.find( projectGLJDatas.gljList,{
                     'code': ratio.code,
@@ -226,7 +228,9 @@ let gljUtil = {
                     p = scMathUtil.roundForObj(temP + p,process_decimal);
                 }
             }
-            return scMathUtil.roundForObj(p,price_hasM_decimal);
+            return scMathUtil.roundForObj(p,price_hasM_decimal);*/
+
+            return scMathUtil.roundForObj(glj.unit_price.base_price,price_hasM_decimal);
         }else {
             let tem_decimal =price_decimal; //isRadio==true?process_decimal:price_decimal;
             return scMathUtil.roundForObj(glj.unit_price.base_price,tem_decimal);

+ 3 - 3
web/building_saas/main/js/controllers/block_controller.js

@@ -498,9 +498,9 @@ let BlockController = {
             tem_ration.ID = uuid.v1();
             billsIDMap[tem_ration.billsItemID]?tem_ration.billsItemID = billsIDMap[tem_ration.billsItemID]:'';
 
-            let firstLibID = rationLibObj.getFirstStdRationLibID();
-            if(firstLibID&&tem_ration.type == rationType.ration){
-                tem_ration.prefix = projectObj.project.Ration.getRationPrefix(firstLibID,tem_ration);
+            let defaultLibID = rationLibObj.getDefaultStdRationLibID();
+            if(defaultLibID&&tem_ration.type == rationType.ration){
+                tem_ration.prefix = projectObj.project.Ration.getRationPrefix(defaultLibID,tem_ration);
             }
             return tem_ration;
 

+ 7 - 1
web/building_saas/main/js/models/calc_base.js

@@ -1238,7 +1238,9 @@ let baseFigureMap = {
     '安全文明施工专项费': {base: 'AQWMSGZXF', fixedFlag: fixedFlag.SAFETY_CONSTRUCTION, class: 'CSXM'},
     //不于清单直接关联==========
     '建筑面积': {base: 'JZMJ', class: 'FBFX'},
-    '税前工程造价': {base: 'SQGCZJ', class: 'SQGCZJ', multiRef: [fixedFlag.SUB_ENGINERRING, fixedFlag.OTHER, fixedFlag.CHARGE]},//安全文明施工专项费用使用
+    '税前工程造价': {base: 'SQGCZJ', class: 'SQGCZJ',//安全文明施工专项费用使用
+        cycleCalcRef: [fixedFlag.SUB_ENGINERRING, fixedFlag.OTHER, fixedFlag.CHARGE], //循环计算相关固定行,由于计算排除了本身,不用判断措施项目
+        multiRef: [fixedFlag.SUB_ENGINERRING, fixedFlag.OTHER, fixedFlag.CHARGE]}, //相关固定行,需要关联措施项目,因为需要提取出多处引用的进行排序
     '人材机价差': {base: 'RCJJC', class: 'RCJ'},
     '人工价差': {base: 'RGJC', class: 'RCJ'},
     '材料价差': {base: 'CLJC', class: 'RCJ'},
@@ -1359,7 +1361,11 @@ let cbAnalyzer = {
                 //重构后:
                 //多重引用基数
                 let figureMultiRef = baseFigures[figure.value]['multiRef'];
+                let cycleCalcRef = baseFigures[figure.value]['cycleCalcRef'];
                 if(cbTools.isDef(figureMultiRef)){
+                    if(cbTools.isDef(cycleCalcRef)){
+                        figureMultiRef = cycleCalcRef;
+                    }
                     for(let flag of figureMultiRef){
                         let bills = cbTools.findBill(flag);
                         if(bills){

+ 7 - 7
web/building_saas/main/js/models/ration.js

@@ -383,7 +383,7 @@ var Ration = {
         ration.prototype.updateRationCodes = function (recodes) {
             let libID =  rationLibObj.getCurrentStdRationLibID();
             let libIDs = rationLibObj.getStdRationLibIDs();
-            let firstLibID = rationLibObj.getFirstStdRationLibID();
+            let defaultLibID = rationLibObj.getDefaultStdRationLibID();
             let engineering = projectInfoObj.projectInfo.property.engineering;
             let projectID = projectInfoObj.projectInfo.ID;
             let project = projectObj.project;
@@ -406,7 +406,7 @@ var Ration = {
             }
             let calQuantity = optionsOprObj.getOption(optionsOprObj.optionsTypes.GENERALOPTS, 'rationQuanACToBillsQuan');
             $.bootstrapLoading.start();
-            CommonAjax.post("/ration/replaceRations",{nodeInfo:nodeInfo,libIDs:libIDs,firstLibID: firstLibID,projectID:projectID,calQuantity:calQuantity},function (data) {
+            CommonAjax.post("/ration/replaceRations",{nodeInfo:nodeInfo,libIDs:libIDs,defaultLibID: defaultLibID,projectID:projectID,calQuantity:calQuantity},function (data) {
                 for(let recode of data){
                    let node =  mainTree.getNodeByID(recode.ration.ID);
                    if(node) {
@@ -486,7 +486,7 @@ var Ration = {
                             brUpdate.push({projectID:newData.projectID,ID:br[i].ID,serialNo:br[i].serialNo});
                         }
                     }
-                    newDatas.push({itemQuery: items[i].itemQuery, newData: newData, firstLibID: rationLibObj.getFirstStdRationLibID(), calQuantity: calQuantity, brUpdate: brUpdate, needInstall: needInstall})
+                    newDatas.push({itemQuery: items[i].itemQuery, newData: newData, defaultLibID: rationLibObj.getDefaultStdRationLibID(), calQuantity: calQuantity, brUpdate: brUpdate, needInstall: needInstall})
                 }
                 let showLoding = true;
                 $.bootstrapLoading.start();
@@ -593,7 +593,7 @@ var Ration = {
                     needInstall = project.Bills.isFBFX(billsNode);//在分部分项插入的定额才需要定额安装增加费
                 }
                 $.bootstrapLoading.start();
-                CommonAjax.post("/ration/addNewRation",{itemQuery:itemQuery,newData:newData,firstLibID: rationLibObj.getFirstStdRationLibID(),calQuantity:calQuantity,brUpdate:brUpdate,needInstall:needInstall},function (data) {
+                CommonAjax.post("/ration/addNewRation",{itemQuery:itemQuery,newData:newData,defaultLibID: rationLibObj.getDefaultStdRationLibID(),calQuantity:calQuantity,brUpdate:brUpdate,needInstall:needInstall},function (data) {
                     //更新缓存
                     me.datas.push(data.ration);
                     project.ration_glj.addDatasToList(data.ration_gljs);
@@ -674,7 +674,7 @@ var Ration = {
                 newNode = project.mainTree.insert(billItemID, nextID, newID);
                 newNode.sourceType = project.Ration.getSourceType();
                 newNode.data = newData;
-                CommonAjax.post("/ration/addNewRation",{itemQuery:null,newData:newData,firstLibID: rationLibObj.getFirstStdRationLibID(),calQuantity:false,brUpdate:brUpdate,needInstall:false},function (data) {
+                CommonAjax.post("/ration/addNewRation",{itemQuery:null,newData:newData,defaultLibID: rationLibObj.getDefaultStdRationLibID(),calQuantity:false,brUpdate:brUpdate,needInstall:false},function (data) {
                     //更新缓存
                     me.datas.push(data.ration);
                     //插入树节点
@@ -827,8 +827,8 @@ var Ration = {
             }
         } ;
         //获取定额前缀
-        ration.prototype.getRationPrefix = function(firstLibID, ration){
-            if(firstLibID !== ration.libID){
+        ration.prototype.getRationPrefix = function(defaultLibID, ration){
+            if(defaultLibID !== ration.libID){
                 return rationPrefix.borrow;
             }
             if(ration.from && ration.from === rationFrom.cpt){

+ 15 - 18
web/building_saas/main/js/views/project_property_projFeature.js

@@ -20,13 +20,7 @@ let projFeatureView = {
             allowUserDragFill: false,
             scrollbarMaxAlign : true
         },
-        combos: [
-            {row: 2, key: 'projType', items: ['住宅', '公共建筑', '厂房', '办公楼']},
-            {row: 3, key: 'structureType', items: ['排架结构', '框架结构', '现浇、框架结构', '预制、砖混结构', '外砖内模', '内浇外挂', '钢结构']},
-            {row: 4, key: 'baseType', items: ['带基', '框排架柱距6m以内', '框排架柱距6m以外', '满基筏式', '满基板式', '满基箱式', '独立基础']},
-            {row: 5, key: 'buildingFeature', items: ['点式', '凹式', '凸式', 'Y式', '其他']}
-        ],
-        numRows: [6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
+        numRows: [],//6, 7, 8, 9, 10, 11, 12, 13, 14, 15
         dateRows: [],
         locked: {
             rows: [0, 1],
@@ -73,6 +67,9 @@ let projFeatureView = {
             for(let i = 0, len = headers.length; i < len; i++){
                 sheet.setValue(0, i, headers[i].name, GC.Spread.Sheets.SheetArea.colHeader);
                 sheet.setColumnWidth(i, headers[i].width, GC.Spread.Sheets.SheetArea.colHeader);
+                sheet.getRange(-1, i, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign[headers[i]['hAlign']]);
+                sheet.getRange(-1, i, -1, 1).vAlign(GC.Spread.Sheets.VerticalAlign[headers[i]['vAlign']]);
+
             }
         };
         me.renderSheetFuc(sheet, fuc);
@@ -107,17 +104,17 @@ let projFeatureView = {
             sheet.setRowCount(datas.length);
             me.initTree(sheet, true, datas);
             sheet.setFormatter(-1, 1, '@');
-            //setCombo
-            for(let i = 0, len = me.setting.combos.length; i < len; i++){
-                me.setCombo(sheet, me.setting.combos[i].row, me.setting.combos[i].items);
-            }
-            for(let col = 0, cLen = cols.length; col < cLen; col++){
-                sheet.getRange(-1, col, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign[cols[col]['hAlign']]);
-                sheet.getRange(-1, col, -1, 1).vAlign(GC.Spread.Sheets.VerticalAlign[cols[col]['vAlign']]);
-                for(let row = 0, rLen = datas.length; row < rLen; row++){
-                    sheet.setValue(row, col, datas[row][cols[col]['dataCode']]);
-                }
-            }
+           for(let row = 0;row < datas.length ; row ++){
+               if(datas[row].cellType == 'comboBox'){
+                   let options = datas[row].options?datas[row].options.split("@"):[];
+                   me.setCombo(sheet, row, options);
+               }else if(datas[row].cellType == 'number'){
+                   me.setting.numRows.push(row);
+               }
+               for(let col = 0;col < cols.length;col++){
+                   sheet.setValue(row, col, datas[row][cols[col]['dataCode']]);
+               }
+           }
         };
         this.renderSheetFuc(sheet, fuc);
     },

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

@@ -824,7 +824,7 @@ var projectObj = {
                 let quantityTime = +new Date();
                 console.log(`计算quantity时间——${quantityTime - mTime}`);
                 that.project.property = projectInfoObj.projectInfo.property;
-                if (overwriteRationCalcBases)
+                if (typeof overwriteRationCalcBases === 'function')
                     overwriteRationCalcBases(that.project.property.taxType);
                 //that.project.calcProgram.compileAllTemps();
                 that.project.calcBase.init(that.project);

+ 15 - 1
web/building_saas/main/js/views/std_ration_lib.js

@@ -45,7 +45,11 @@ var rationLibObj = {
         ration_lib.forEach(function (data) {
             let option = $('<option>').val(data.id).text(data.name);
             //select.append($('<option>').val(data.id).text(data.name));
-            if(selectedRationLib && data.id == selectedRationLib){
+            if(selectedRationLib){
+                if(data.id == selectedRationLib){
+                    option.attr('selected', 'selected');
+                }
+            }else if(data.isDefault == true){
                 option.attr('selected', 'selected');
             }
             select.append(option);
@@ -386,6 +390,16 @@ var rationLibObj = {
             return null;
         }
         return parseInt(projectInfoObj.projectInfo.engineeringInfo.ration_lib[0].id);
+    },
+    getDefaultStdRationLibID:function(){
+        let ration_lib = projectInfoObj.projectInfo.engineeringInfo.ration_lib;
+        if(ration_lib.length === 0){
+            alert('当前项目无定额库,请添加定额库。');
+            return null;
+        }
+        let defaultLib = _.find(ration_lib,{'isDefault':true});
+        let libID = defaultLib?defaultLib.id:ration_lib[0].id;
+        return parseInt(libID);
     }
 };
 

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

@@ -2384,6 +2384,10 @@ function AddTender() {
         // 一个项目里面,这两个文件必须得有,而界面又没有像费率、单价文件那样给出可选项。所以这里给出提示。
         if (!libs.artificial_lib)  throw '编办没有绑定人工系数标准文件';
 
+        let featureLibID = "";
+        if(libs.feature_lib && libs.feature_lib.length > 0) featureLibID = libs.feature_lib[0].id;
+
+
         let calcProgramName = $('#tender-calcProgram').children("option:selected").text();
 
         let callback = function() {
@@ -2413,7 +2417,8 @@ function AddTender() {
             calcProgram: {name: calcProgramName, id: calcProgram},
             taxType:taxType,
             templateLibID:templateLibID,
-            colLibID:colLibID
+            colLibID:colLibID,
+            featureLibID:featureLibID
         };
         AddTenderItems(selectedItem, projName, engName, tenderName, tenderInfo, callback);
 

+ 4 - 2
web/over_write/js/chongqing_2018.js

@@ -54,7 +54,7 @@ baseMachineTypes.push(gljType.INSTRUMENT, gljType.FUEL_POWER_FEE, gljType.DEPREC
     gljType.VERIFICATION_FEE, gljType.OTHER_FEE, gljType.OTHER_MACHINE_USED);
 baseMachineMasterTypes.push(gljType.INSTRUMENT);
 
-let overwriteRationCalcBases = function (taxType){
+function overwriteRationCalcBases (taxType){
     if (rationCalcBases){
         for (let key in rationCalcBases) {
             delete rationCalcBases[key];
@@ -263,7 +263,9 @@ if(typeof baseFigureMap !== 'undefined'){
         '甲定施工机具使用费': {base: 'JDJXF', class: 'RCJ'},
         '甲定主材费': {base: 'JDZCF', class: 'RCJ'},
         '暂估材料费(从子目汇总)': {base: 'ZGCLFFZM', class: 'RCJ'},
-        '税前工程造价': {base: 'SQGCZJ', class: 'SQGCZJ', multiRef: [fixedFlag.SUB_ENGINERRING, fixedFlag.MEASURE, fixedFlag.OTHER, fixedFlag.CHARGE]},//安全文明施工专项费用使用
+        '税前工程造价': {base: 'SQGCZJ', class: 'SQGCZJ',
+            cycleCalcRef: [fixedFlag.SUB_ENGINERRING, fixedFlag.OTHER, fixedFlag.CHARGE],   //循环计算相关固定行,由于计算排除了本身,不用判断措施项目
+            multiRef: [fixedFlag.SUB_ENGINERRING, fixedFlag.MEASURE, fixedFlag.OTHER, fixedFlag.CHARGE]},//相关固定行
     };
 }
 if(typeof baseFigureTemplate !== 'undefined'){