Bladeren bron

Merge branch 'master' into olym

olym 7 jaren geleden
bovenliggende
commit
39d8bc0438

+ 2 - 1
modules/ration_repository/controllers/ration_controller.js

@@ -10,7 +10,8 @@ var callback = function(req, res, err, message, data){
 module.exports = {
     getRationItemsBySection: function(req, res){
         var sectionId = req.body.sectionID;
-        rationItem.getRationItemsBySection(sectionId, function(err, message, rst){
+        var rationRepId = req.body.rationRepId;
+        rationItem.getRationItemsBySection(rationRepId, sectionId, function(err, message, rst){
             if (err) {
                 callback(req, res, err, message, null);
             } else {

+ 2 - 2
modules/ration_repository/models/ration_item.js

@@ -47,8 +47,8 @@ import stdGljListModel from '../../common/std/schemas/std_ration_lib_glj_list';
 
 var rationItemDAO = function(){};
 
-rationItemDAO.prototype.getRationItemsBySection = function(sectionId,callback){
-    rationItemModel.find({"sectionId": sectionId, "$or": [{"isDeleted": null}, {"isDeleted": false} ]}, null, {sort: {code: 1}}, function(err,data){
+rationItemDAO.prototype.getRationItemsBySection = function(rationRepId, sectionId,callback){
+    rationItemModel.find({"rationRepId": rationRepId, "sectionId": sectionId, "$or": [{"isDeleted": null}, {"isDeleted": false} ]}, null, {sort: {code: 1}}, function(err,data){
         if(err) callback(true, "Fail to get items", "")
         else callback(false,"Get items successfully", data);
     })

+ 2 - 2
modules/reports/rpt_component/helper/jpc_helper_area.js

@@ -50,12 +50,12 @@ let JpcAreaHelper = {
                 }
             } else {
                 //颗粒度更加细化的控制,可能上下两边的计算坐标方式都不同
-                if (areaNode[JV.PROP_H_CALCULATION][JV.PROP_TOP] === JV.CAL_TYPE[JV.CAL_TYPE_PERCENTAGE]) {
+                if (areaNode[JV.PROP_V_CALCULATION][JV.PROP_TOP] === JV.CAL_TYPE[JV.CAL_TYPE_PERCENTAGE]) {
                     innerTop = (1.0 * areaNode[JV.PROP_TOP] * areaHeight / JV.HUNDRED_PERCENT);
                 } else {
                     innerTop = 1.0 * areaNode[JV.PROP_TOP] * unitFactor;
                 }
-                if (areaNode[JV.PROP_H_CALCULATION][JV.PROP_BOTTOM] === JV.CAL_TYPE[JV.CAL_TYPE_PERCENTAGE]) {
+                if (areaNode[JV.PROP_V_CALCULATION][JV.PROP_BOTTOM] === JV.CAL_TYPE[JV.CAL_TYPE_PERCENTAGE]) {
                     innerBottom = (1.0 * areaNode[JV.PROP_BOTTOM] * areaHeight / JV.HUNDRED_PERCENT);
                 } else {
                     innerBottom = 1.0 * areaNode[JV.PROP_BOTTOM] * unitFactor;

+ 3 - 0
test/unit/reports/test_cover_01.js

@@ -31,6 +31,9 @@ require('../../../modules/fee_rates/models/fee_rates');
 // 引入人工系数模块
 require('../../../modules/main/models/labour_coe_model');
 require('../../../modules/main/models/calc_program_model');
+//config.setupCache();
+let cfgCacheUtil = require("../../../config/cacheCfg");
+cfgCacheUtil.setupDftCache();
 
 let fsUtil = require("../../../public/fsUtil");
 

+ 3 - 0
test/unit/reports/test_cover_02.js

@@ -31,6 +31,9 @@ require('../../../modules/fee_rates/models/fee_rates');
 // 引入人工系数模块
 require('../../../modules/main/models/labour_coe_model');
 require('../../../modules/main/models/calc_program_model');
+//config.setupCache();
+let cfgCacheUtil = require("../../../config/cacheCfg");
+cfgCacheUtil.setupDftCache();
 
 let fsUtil = require("../../../public/fsUtil");
 

+ 170 - 0
test/unit/reports/test_tpl_09.js

@@ -0,0 +1,170 @@
+/**
+ * Created by Tony on 2017/12/20.
+ */
+
+let test = require('tape');
+import JpcEx from "../../../modules/reports/rpt_component/jpc_ex";
+import JV from "../../../modules/reports/rpt_component/jpc_value_define";
+let mongoose = require("mongoose");
+let fileUtils = require("../../../modules/common/fileUtils");
+let path = require('path');
+let dbm = require("../../../config/db/db_manager");
+let rpt_cfg = require('./rpt_cfg');
+dbm.connect();
+let consts = require('../../../modules/main/models/project_consts');
+let projectConsts = consts.projectConst;
+fileUtils.getGlobbedFiles('../../../modules/complementary_glj_lib/models/*.js').forEach(function(modelPath) {
+    require(path.resolve(modelPath));
+});
+
+fileUtils.getGlobbedFiles('../../../modules/ration_glj/models/*.js').forEach(function(modelPath) {
+    require(path.resolve(modelPath));
+});
+
+//引入报表模块
+fileUtils.getGlobbedFiles('../../../modules/reports/models/*.js').forEach(function(modelPath) {
+    require(path.resolve(modelPath));
+})
+
+//暂时引入其它模块的model
+require('../../../modules/fee_rates/models/fee_rates');
+// 引入人工系数模块
+require('../../../modules/main/models/labour_coe_model');
+require('../../../modules/main/models/calc_program_model');
+//config.setupCache();
+let cfgCacheUtil = require("../../../config/cacheCfg");
+cfgCacheUtil.setupDftCache();
+
+let fsUtil = require("../../../public/fsUtil");
+
+let prjMdl = require('../../../modules/pm/models/project_model');
+let projectDataMdl = require('../../../modules/main/models/project');
+let demoPrjId = - 1;
+let demoRptId = 232, pagesize = "A4";
+
+let userId_Leng = 1142; //小冷User Id
+// demoPrjId = 720; //QA: DW3
+demoPrjId = 1296; //QA:
+//*/
+let userId_Dft = userId_Leng;
+/*/
+ let userId_Dft = 76075;
+ //*/
+
+let rptTplFacade = require("../../../modules/reports/facade/rpt_template_facade");
+let rptTplDataFacade = require("../../../modules/reports/facade/rpt_tpl_data_facade");
+
+import rptDataExtractor from "../../../modules/reports/util/rpt_construct_data_util";
+
+let fs = require('fs');
+//设置Date Format函数
+fs.readFile(__dirname.slice(0, __dirname.length - 18) + '/public/web/date_util.js', 'utf8', 'r', function (err, data) {
+    eval(data);
+});
+
+/*/
+ test('测试 - 获取project数据: ', function (t) {
+ projectDataMdl.getData(demoPrjId, function (err, message, result) {
+ if (!err) {
+ fsUtil.writeObjToFile(result, "D:/GitHome/ConstructionCost/tmp/ProjectDataFullObject.js");
+ t.pass('pass succeeded!');
+ t.end();
+ } else {
+ //callback(req, res, err, message, null);
+ t.pass('pass failed!');
+ t.end();
+ }
+ });
+ });
+ //*/
+/*/
+ test('测试 - 获取project部分数据: ', function (t) {
+ let filter = [];
+ filter.push(projectConsts.BILLS);
+ filter.push(projectConsts.RATION);
+ filter.push(projectConsts.RATION_GLJ);
+ filter.push(projectConsts.PROJECTGLJ);
+ filter.push(projectConsts.FEERATE);
+ filter.push(projectConsts.CALC_PROGRAM);
+ prjMdl.project.getUserProject(userId_Dft, demoPrjId, function(err, msg, prjObj){
+ if (!err) {
+ projectDataMdl.getFilterData(demoPrjId, filter, function (results) {
+ if (results) {
+ // let newData = [];
+ // for (let item of results) {
+ //     newData.push(JSON.stringify(item));
+ // }
+ // fsUtil.writeArrayToFile(newData, "D:/GitHome/ConstructionCost/tmp/getProjectData_partial.js");
+ // fsUtil.writeObjToFile(prjObj, "D:/GitHome/ConstructionCost/tmp/getProjectObjectNew.js");
+ fsUtil.writeObjToFile(results, "D:/GitHome/ConstructionCost/tmp/getProjectData_partialNew.js");
+ t.pass('pass succeeded!');
+ t.end();
+ } else {
+ //callback(req, res, err, message, null);
+ t.pass('get project data failed!');
+ t.end();
+ }
+ });
+ } else {
+ t.pass('get project failed!');
+ t.end();
+ }
+ });
+ });
+ //*/
+
+//*
+test('测试 - 测试模板啦: ', function (t) {
+    rptTplFacade.getRptTemplate(demoRptId).then(function(rptTpl) {
+        let rptDataUtil = new rptDataExtractor();
+        rptDataUtil.initialize(rptTpl._doc);
+        let filter = rptDataUtil.getDataRequestFilter();
+        console.log(filter);
+        //正常应该根据报表模板定义的数据类型来请求数据
+        rptTplDataFacade.prepareProjectData(userId_Dft, demoPrjId, filter, function (err, msg, rawDataObj) {
+            if (!err) {
+                try {
+                    // fsUtil.writeObjToFile(rawDataObj, "D:/GitHome/ConstructionCost/tmp/rptTplRawDataObject.js");
+                    let tplData = rptDataUtil.assembleData(rawDataObj);
+                    //it's time to build the report!!!
+                    let printCom = JpcEx.createNew();
+                    rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_PAGE_SIZE] = pagesize;
+                    let defProperties = rpt_cfg;
+                    let dftOption = JV.PAGING_OPTION_NORMAL;
+                    printCom.initialize(rptTpl);
+                    printCom.analyzeData(rptTpl, tplData, defProperties, dftOption);
+                    let maxPages = printCom.totalPages;
+                    let pageRst = printCom.outputAsSimpleJSONPageArray(rptTpl, tplData, 1, maxPages, defProperties);
+                    if (pageRst) {
+                        // fsUtil.writeObjToFile(pageRst, "D:/GitHome/ConstructionCost/tmp/testBuiltPageResult.js");
+                    } else {
+                        console.log("oh! no pages were created!");
+                    }
+                } catch (ex) {
+                    console.log(ex);
+                    t.pass('pass with exception!');
+                    t.end();
+                }
+
+                t.pass('pass succeeded!');
+                t.end();
+            } else {
+                console.log(msg);
+                t.pass('pass with error!');
+                t.end();
+            }
+        })
+    });
+});
+//*/
+
+test('close the connection', function (t) {
+    setTimeout(function () {
+        mongoose.disconnect();
+        t.pass('closing db connection');
+        t.end();
+    }, 3000);
+    // mongoose.disconnect();
+    // t.pass('closing db connection');
+    // t.end();
+});

+ 4 - 0
test/unit/reports/test_tpl_09_1.js

@@ -31,6 +31,10 @@ require('../../../modules/fee_rates/models/fee_rates');
 require('../../../modules/main/models/labour_coe_model');
 require('../../../modules/main/models/calc_program_model');
 
+//config.setupCache();
+let cfgCacheUtil = require("../../../config/cacheCfg");
+cfgCacheUtil.setupDftCache();
+
 let fsUtil = require("../../../public/fsUtil");
 
 let prjMdl = require('../../../modules/pm/models/project_model');

+ 1 - 1
web/building_saas/glj/js/project_glj_spread.js

@@ -19,7 +19,7 @@ function ProjectGLJSpread() {
     this.successCallback = null;
     this.supplyType = ['自行采购', '部分甲供', '完全甲供', '甲定乙供'];
     // 工料机类型是混凝土、砂浆、配合比、机械(不包括机械组成物)时,供货方式列只读。
-    this.supplyReadonlyType = [GLJTypeConst.CONCRETE, GLJTypeConst.MORTAR, GLJTypeConst.MIX_RATIO, GLJTypeConst.GENERAL_MACHINE];
+    this.supplyReadonlyType = notEditType;
 }
 
 /**

+ 15 - 5
web/building_saas/main/js/models/calc_base.js

@@ -462,6 +462,7 @@ let cbAnalyzer = {
                 let bill = baseFigures[figure]['fixedBill']['bill'];
                 if(checkStack(getRefStack([bill.ID]), sbillID)){
                     console.log('循环计算');
+                    calcBase.errMsg = '表达式出现循环计算';
                     return true;
                 }
             }
@@ -522,6 +523,9 @@ let cbParser = {
 
     //将表达式转换为可编译的表达式
     toCompileExpr: function(v){
+        if(v === ''){
+            return '$CBC.base(\'NONE\')';
+        }
         let strs = this.getFigure(v);
         let exps = [];
         for(let i = 0, len = strs.length; i < len; i++){
@@ -541,6 +545,9 @@ let cbParser = {
 let cbCalctor = {
     //计算基数
     base: function (figure) {
+        if(figure === 'NONE'){
+            return 0;
+        }
         return baseFigureTemplate[calcBase.baseFigures[figure]['base']]();
     },
     //计算
@@ -550,6 +557,7 @@ let cbCalctor = {
 };
 
 let calcBase = {
+    errMsg: '表达式不正确',
     success: false,
     //清单固定行
     fixedFlag: null,
@@ -566,7 +574,6 @@ let calcBase = {
         cbTools.setFixedBills(project, me.fixedBills, me.fixedFlag);
         me.baseFigures = baseFigureMap;
         cbTools.setBaseBills(me.baseFigures, me.fixedBills);
-        //me.baseFigures.fixedBills = me.fixedBills;
         cbTools.setBaseFigureClass(me.baseFigures, me.baseFigureClass);
     },
     getBase: function (figure) {
@@ -586,11 +593,13 @@ let calcBase = {
             $CBC = cbCalctor;
         try {
             me.success = false;
+            me.errMsg = '表达式不正确';
             //分析输入式合法性
             let exp = $CBA.legalExp(node);
-            if(!exp){
+            if(!cbTools.isDef(exp)){
                 throw '表达式不正确';
             }
+
             //输入式转换表达式
             let compileExp = $CBP.toCompileExpr(exp);
 
@@ -599,15 +608,16 @@ let calcBase = {
             if(!cbTools.isNum(calcBaseValue)){
                 throw '表达式不正确';
             }
+
             //存储
             me.success = true;
             node.data.calcBase = exp;
             node.data.calcBaseValue = parseFloat(calcBaseValue).toDecimal(decimalObj.decimal('totalPrice', node));
-            me.project.calcProgram.calculate(node);
-            me.project.calcProgram.saveNode(node);
+           /* me.project.calcProgram.calculate(node);
+            me.project.calcProgram.saveNode(node);*/
         }
         catch (err){
-            alert('表达式不正确');
+            alert(me.errMsg);
         }
     }
 };

+ 6 - 0
web/building_saas/main/js/models/main_consts.js

@@ -47,6 +47,12 @@ const gljType = {
     EQUIPMENT: 5
 };
 
+const notEditType = [
+    gljType.CONCRETE,
+    gljType.MORTAR,
+    gljType.MIX_RATIO,
+    gljType.GENERAL_MACHINE
+];
 
 const CP_Col_Width = {          // 多处计算程序界面的列宽统一设置
     rowHeader: 30,

+ 104 - 88
web/building_saas/main/js/models/project_glj.js

@@ -27,13 +27,13 @@ ProjectGLJ.prototype.loadData = function (callback = null) {
         type: 'post',
         dataType: 'json',
         data: {project_id: scUrlUtil.GetQueryString('project')},
-        error: function() {
+        error: function () {
             // alert('数据传输错误');
         },
-        beforeSend: function() {
+        beforeSend: function () {
             self.isLoading = true;
         },
-        success: function(response) {
+        success: function (response) {
             self.isLoading = false;
             if (response.err === 1) {
                 let msg = response.msg !== undefined && response.msg !== '' ? response.msg : '读取工料机数据失败!';
@@ -53,7 +53,7 @@ ProjectGLJ.prototype.loadData = function (callback = null) {
 
 ProjectGLJ.prototype.loadToCache = function (data) {
     this.datas = data;
-    projectObj.project.projectGLJ=this;
+    projectObj.project.projectGLJ = this;
 }
 
 
@@ -74,7 +74,7 @@ ProjectGLJ.prototype.getDataByCode = function (code) {
         return result;
     }
 
-    for(let tmp of gljList) {
+    for (let tmp of gljList) {
         if (tmp.code === code) {
             result = tmp;
             break;
@@ -91,7 +91,7 @@ ProjectGLJ.prototype.getDataByCode = function (code) {
  * @param {Object} data
  * @return {boolean}
  */
-ProjectGLJ.prototype.updateData = function(id, data) {
+ProjectGLJ.prototype.updateData = function (id, data) {
     let result = false;
     if (this.datas === null) {
         return result;
@@ -104,7 +104,7 @@ ProjectGLJ.prototype.updateData = function(id, data) {
 
     // 查找对应的index
     let index = -1;
-    for(let tmp in gljList) {
+    for (let tmp in gljList) {
         if (gljList[tmp].id === id) {
             index = tmp;
             break;
@@ -116,8 +116,8 @@ ProjectGLJ.prototype.updateData = function(id, data) {
     }
 
     // 修改数据
-    for(let tmpIndex in data) {
-        if(tmpIndex.indexOf('_price') >= 0) {
+    for (let tmpIndex in data) {
+        if (tmpIndex.indexOf('_price') >= 0) {
             // 修改unit_price中的对象
             this.datas.gljList[index]['unit_price'][tmpIndex] = data[tmpIndex];
         } else {
@@ -132,110 +132,110 @@ ProjectGLJ.prototype.updateData = function(id, data) {
  *
  * @return {void}
  */
-ProjectGLJ.prototype.loadCacheData = function() {
+ProjectGLJ.prototype.loadCacheData = function () {
     // 加载工料机数据
     let data = this.datas === null ? null : this.datas;
     if (data === null) {
         return;
     }
     jsonData = data.gljList !== undefined && data.gljList.length > 0 ? data.gljList : [];
-    jsonData=filterProjectGLJ(jsonData);
+    jsonData = filterProjectGLJ(jsonData);
     jsonData = sortProjectGLJ(jsonData);
     projectGLJSheet.setData(jsonData);
     projectGLJSpread.specialColumn(jsonData);
 };
 
-ProjectGLJ.prototype.updatePriceFromRG=function(recode,updateField,newval){
-    if(updateField=='marketPrice'){
-        this.updateBasePriceFromRG(recode,"market_price",newval);
+ProjectGLJ.prototype.updatePriceFromRG = function (recode, updateField, newval) {
+    if (updateField == 'marketPrice') {
+        this.updateBasePriceFromRG(recode, "market_price", newval);
     }
-    if(updateField=='basePrice'){
-        this.updateBasePriceFromRG(recode,"base_price",newval);
+    if (updateField == 'basePrice') {
+        this.updateBasePriceFromRG(recode, "base_price", newval);
     }
 };
 
-ProjectGLJ.prototype.updatePropertyFromMainSpread = function (node,updateField,newval) {
-   if(updateField=="contain"){
+ProjectGLJ.prototype.updatePropertyFromMainSpread = function (node, updateField, newval) {
+    if (updateField == "contain") {
 
-   }else {
-       this.updateGLJProperty(node,updateField,newval);
-   }
+    } else {
+        this.updateGLJProperty(node, updateField, newval);
+    }
 };
 
 
-ProjectGLJ.prototype.updateGLJProperty=function (node,updateField,newval) {
+ProjectGLJ.prototype.updateGLJProperty = function (node, updateField, newval) {
     let rationTypeGLJ = node.data;
     let postData = {};
-    if(rationTypeGLJ[updateField]==newval){
+    if (rationTypeGLJ[updateField] == newval) {
         return;
     }
-    let data ={
+    let data = {
         glj_id: rationTypeGLJ.GLJID,
         project_id: rationTypeGLJ.projectID,
         code: rationTypeGLJ.code,
-        original_code:rationTypeGLJ.original_code,
+        original_code: rationTypeGLJ.original_code,
         name: rationTypeGLJ.name,
-        shortName:rationTypeGLJ.shortName,
+        shortName: rationTypeGLJ.shortName,
         specs: rationTypeGLJ.specs,
         unit: rationTypeGLJ.unit,
-        type:rationTypeGLJ.subType,
-        type_of_work:rationTypeGLJ.subType,
+        type: rationTypeGLJ.subType,
+        type_of_work: rationTypeGLJ.subType,
         base_price: rationTypeGLJ.basePrice,
         market_price: rationTypeGLJ.basePrice,
-        repositoryId:rationTypeGLJ.repositoryId,
-        adjCoe:rationTypeGLJ.adjCoe,
-        from:rationTypeGLJ.from?rationTypeGLJ.from:'std'//std:标准工料机库, cpt:补充工料机库
+        repositoryId: rationTypeGLJ.repositoryId,
+        adjCoe: rationTypeGLJ.adjCoe,
+        from: rationTypeGLJ.from ? rationTypeGLJ.from : 'std'//std:标准工料机库, cpt:补充工料机库
     };
-    if(updateField=='subType'){
+    if (updateField == 'subType') {
         data.type = newval;
         data.type_of_work = newval;
         data.shortName = this.getShortNameByID(newval);
-    }else {
-        data[updateField]=newval;
+    } else {
+        data[updateField] = newval;
     }
     postData.ration = {
-        ID:rationTypeGLJ.ID,
-        projectID:rationTypeGLJ.projectID
+        ID: rationTypeGLJ.ID,
+        projectID: rationTypeGLJ.projectID
     };
     postData.updateData = data;
     $.bootstrapLoading.start();
-    CommonAjax.post("/glj/modifyKeyValue",postData,function (result) {
+    CommonAjax.post("/glj/modifyKeyValue", postData, function (result) {
         console.log(result);  //更新节点信息
-        rationTypeGLJ[updateField]=newval;
+        rationTypeGLJ[updateField] = newval;
         rationTypeGLJ.projectGLJID = result.id;
         rationTypeGLJ.code = result.code;
         rationTypeGLJ.basePrice = result.unit_price.base_price;
         rationTypeGLJ.marketUnitFee = result.unit_price.market_price;
         rationTypeGLJ.isAdd = result.unit_price.is_add;
-        rationTypeGLJ.isEstimate=result.is_evaluate;
+        rationTypeGLJ.isEstimate = result.is_evaluate;
         rationTypeGLJ.shortName = result.unit_price.short_name;
         //触发计算并更新节点信息
-        node.changed=true;
+        node.changed = true;
         projectObj.project.projectGLJ.loadData(function () {
             projectObj.project.calcProgram.calculate(node);
             projectObj.project.calcProgram.saveNode(node);
             $.bootstrapLoading.end();
         });//重新加载项目工料机数据
         //上面两步都是异步操作,这句应该是要等上面两步做完了再执行的
-    },function (err) {
+    }, function (err) {
         $.bootstrapLoading.end();
     });
-    
+
 }
 
-ProjectGLJ.prototype.updateBasePriceFromRG=function(recode,updateField,newval){
+ProjectGLJ.prototype.updateBasePriceFromRG = function (recode, updateField, newval) {
     let me = this;
     let projectGljs = this.datas.gljList;
-    let glj = _.find(projectGljs,{'id':recode.projectGLJID});
+    let glj = _.find(projectGljs, {'id': recode.projectGLJID});
     console.log(glj);
-    if(glj){
-        let data = {id:glj.unit_price.id,field:updateField,newval:newval};
-        let callback =function (data) {
-            if(updateField=='base_price'){
-                glj.unit_price.base_price=newval;
+    if (glj) {
+        let data = {id: glj.unit_price.id, field: updateField, newval: newval};
+        let callback = function (data) {
+            if (updateField == 'base_price') {
+                glj.unit_price.base_price = newval;
                 me.setAdjustPrice(glj);
-            }else {
-                glj.unit_price.market_price=newval;
+            } else {
+                glj.unit_price.market_price = newval;
             }
             //更新项目工料机价格
             me.refreshProjectGLJPrice(data);
@@ -247,17 +247,17 @@ ProjectGLJ.prototype.updateBasePriceFromRG=function(recode,updateField,newval){
             $.bootstrapLoading.end();
         }
         $.bootstrapLoading.start();
-        CommonAjax.post("/glj/updatePrice",data,callback,function (err) {
+        CommonAjax.post("/glj/updatePrice", data, callback, function (err) {
             $.bootstrapLoading.end();
         });
-    }else {
+    } else {
         gljOprObj.showRationGLJSheetData();
     }
 }
 ProjectGLJ.prototype.refreshTreeNodePriceIfNeed = function (data) {
-    if((data.unit_price.type = gljType.MAIN_MATERIAL||data.unit_price.type==gljType.EQUIPMENT)&&projectInfoObj.projectInfo.property.displaySetting.disPlayMainMaterial==true){
-        var nodes = _.filter(projectObj.project.mainTree.items,function (tem) {
-            if(tem.sourceType==ModuleNames.ration_glj&&tem.data.projectGLJID ==data.id){
+    if ((data.unit_price.type = gljType.MAIN_MATERIAL || data.unit_price.type == gljType.EQUIPMENT) && projectInfoObj.projectInfo.property.displaySetting.disPlayMainMaterial == true) {
+        var nodes = _.filter(projectObj.project.mainTree.items, function (tem) {
+            if (tem.sourceType == ModuleNames.ration_glj && tem.data.projectGLJID == data.id) {
                 tem.data.marketUnitFee = data.unit_price.market_price;
                 return true;
             }
@@ -269,35 +269,35 @@ ProjectGLJ.prototype.refreshTreeNodePriceIfNeed = function (data) {
 
 //根据工料机,取得所有受影响的定额节点
 ProjectGLJ.prototype.getImpactRationNodes = function (glj) {
-    let nodes=[];
+    let nodes = [];
     let rationMap = {};
     //先根据项目工料机ID,找到受影响定额的ID
-    let ration_glj_list =projectObj.project.ration_glj.datas; //取定额工料机数据
-    for(let rg of ration_glj_list){
-        if(rg.projectGLJID==glj.id){
+    let ration_glj_list = projectObj.project.ration_glj.datas; //取定额工料机数据
+    for (let rg of ration_glj_list) {
+        if (rg.projectGLJID == glj.id) {
             rationMap[rg.rationID] = true;  //取所有定额ID,用MAP方式去重
         }
     }
-    for(let item of projectObj.project.mainTree.items){
-        if(item.sourceType==ModuleNames.ration){
-            if(item.data.type==rationType.gljRation){//取定额类型的工料机
-                if(item.data.projectGLJID == glj.id){
+    for (let item of projectObj.project.mainTree.items) {
+        if (item.sourceType == ModuleNames.ration) {
+            if (item.data.type == rationType.gljRation) {//取定额类型的工料机
+                if (item.data.projectGLJID == glj.id) {
                     item.data.marketUnitFee = glj.unit_price.market_price; //更新市场单价
                     nodes.push(item);
                 }
-            }else if( rationMap[item.data.ID]==true){  //受影响的定额
-                   nodes.push(item)
+            } else if (rationMap[item.data.ID] == true) {  //受影响的定额
+                nodes.push(item)
             }
         }
     }
     return nodes;
 };
-ProjectGLJ.prototype.refreshRationGLJPrice=function (glj) {
-    for(let ration_glj of gljOprObj.sheetData){
-        if(ration_glj.projectGLJID ==glj.id){
-            ration_glj.basePrice=glj.unit_price.base_price;
-            ration_glj.marketPrice=glj.unit_price.market_price;
-            ration_glj.adjustPrice=this.getAdjustPrice(glj);
+ProjectGLJ.prototype.refreshRationGLJPrice = function (glj) {
+    for (let ration_glj of gljOprObj.sheetData) {
+        if (ration_glj.projectGLJID == glj.id) {
+            ration_glj.basePrice = glj.unit_price.base_price;
+            ration_glj.marketPrice = glj.unit_price.market_price;
+            ration_glj.adjustPrice = this.getAdjustPrice(glj);
         }
     }
 }
@@ -306,19 +306,19 @@ ProjectGLJ.prototype.refreshRationTypeGLJ = function (glj) {
 
 }
 
-ProjectGLJ.prototype.refreshProjectGLJPrice=function(data){
+ProjectGLJ.prototype.refreshProjectGLJPrice = function (data) {
     let projectGljs = this.datas.gljList;
-    let indexList = ['code','name','specs','unit','type'];
-    for(let d of data){
-        if(d){
+    let indexList = ['code', 'name', 'specs', 'unit', 'type'];
+    for (let d of data) {
+        if (d) {
             let condition = {};
-            for(let index of indexList){
-                if(d[index]!=null&&d[index]!=undefined&&d[index]!=''){
-                    condition[index]=d[index]
+            for (let index of indexList) {
+                if (d[index] != null && d[index] != undefined && d[index] != '') {
+                    condition[index] = d[index]
                 }
             }
-            let glj = _.find(projectGljs,condition);
-            if(glj){
+            let glj = _.find(projectGljs, condition);
+            if (glj) {
                 glj.unit_price.base_price = d.base_price;
                 glj.unit_price.market_price = d.market_price;
                 this.setAdjustPrice(glj);
@@ -329,7 +329,7 @@ ProjectGLJ.prototype.refreshProjectGLJPrice=function(data){
     }
 }
 
-ProjectGLJ.prototype.setAdjustPrice=function(glj){
+ProjectGLJ.prototype.setAdjustPrice = function (glj) {
     switch (glj.unit_price.type + '') {
         // 人工: 调整基价=基价单价*调整系数
         case GLJTypeConst.LABOUR:
@@ -348,18 +348,34 @@ ProjectGLJ.prototype.setAdjustPrice=function(glj){
 
 ProjectGLJ.prototype.getAdjustPrice = function (glj) {
     GLJTypeConst = this.datas.constData.GLJTypeConst !== undefined ? JSON.parse(this.datas.constData.GLJTypeConst) : GLJTypeConst;
-    if(glj.unit_price.type==GLJTypeConst.LABOUR||glj.unit_price.type==GLJTypeConst.MACHINE_LABOUR){
+    let decimal = getDecimal("glj.unitPrice");
+    let quantity_decimal = getDecimal("glj.quantity")
+    if (glj.unit_price.type == GLJTypeConst.LABOUR || glj.unit_price.type == GLJTypeConst.MACHINE_LABOUR) {//人工、机上人工,调整价根据定额价*调整系数计算得出。
         let labour = projectObj.project.calcProgram.compiledLabourCoes[glj.adjCoe];
         //let labour=1;
-        let coe = labour&&labour.coe?labour.coe:1;
-        let decimal = getDecimal("glj.unitPrice");
-        return scMathUtil.roundTo(parseFloat(coe*glj.unit_price.base_price),-decimal);
-    }else {
+        let coe = labour && labour.coe ? labour.coe : 1;
+        return scMathUtil.roundTo(parseFloat(coe * scMathUtil.roundForObj(glj.unit_price.base_price,decimal)), -decimal);
+    } else if (notEditType.indexOf(glj.unit_price.type)>0) {//对于混凝土、配合比、砂浆、机械台班,调整价根据组成物计算得出。
+        let p =0;
+        for(let ratio of glj.ratio_data){
+           let tem =  _.find( projectObj.project.projectGLJ.datas.gljList,{
+               'code': ratio.code,
+               'name': ratio.name,
+               'specs':ratio.specs,
+               'type': ratio.type,
+               'unit': ratio.unit
+           })
+            if(tem){
+                p+=scMathUtil.roundForObj(this.getAdjustPrice(tem)*scMathUtil.roundForObj(ratio.consumption,quantity_decimal),decimal);
+            }
+        }
+        return scMathUtil.roundForObj(p,decimal);
+    } else {//对于其他普通材料等,无调整系数,调整价=定额价。
         return glj.unit_price.base_price
     }
 }
 
 ProjectGLJ.prototype.getShortNameByID = function (ID) {
     let gljTypeMap = this.datas.constData.gljTypeMap;
-    return gljTypeMap["typeId"+ID].shortName;
+    return gljTypeMap["typeId" + ID].shortName;
 }

+ 2 - 3
web/building_saas/main/js/models/ration_glj.js

@@ -345,7 +345,6 @@ var ration_glj = {
                 let initShow = false;//是否需要表格初始化显示
                 if (updateField == 'customQuantity') {
                     me.refreshAfterQuantityUpdate(data, node);
-                    me.refreshTreeNodeIfNeeded(recode);//需刷新主材和设备的工程量和含量
                 } else {
                     var doc = data.doc;
                     for (var key in doc) {
@@ -360,11 +359,11 @@ var ration_glj = {
                     if (node) {//如果不是在造价书页面直接编辑,则不用刷新
                         if (updateField == "type" && !(newval == gljType.MAIN_MATERIAL || newval == gljType.EQUIPMENT)) {//如果改变类型后不是主材或设备,则在造价书树中移除
                             projectObj.mainController.deleteNode(node, true);
-                        } else {
-                            me.refreshTreeNodeIfNeeded(recode);
                         }
                     }
                 }
+                me.refreshTreeNodeIfNeeded(recode);//刷新造价书上的树节点(如果需要)
+
                 if (initShow == false) {//不需要初始化,只需耍新当前显示就可以了
                     gljOprObj.showRationGLJSheetData();
                 }

+ 1 - 2
web/building_saas/main/js/views/calc_base_view.js

@@ -195,8 +195,7 @@ let calcBaseView = {
         let me = calcBaseView;
         me.confirmBtn.bind('click', function () {
             let selected = projectObj.project.mainTree.selected;
-            selected.data.userCalcBase = me.getInputExpr();
-            projectObj.project.calcBase.calculate(selected);
+            projectObj.updateCellValue(selected, me.getInputExpr(), {data: {field: 'calcBase'}});
             if(projectObj.project.calcBase.success){
                 $('#qd-jsjs').modal('hide');
             }

+ 54 - 13
web/building_saas/main/js/views/glj_view.js

@@ -94,9 +94,10 @@ var gljOprObj = {
         view: {
             comboBox: [{row: -1, col: 12, rowCount: -1, colCount: 1}],
             lockedCells: [{row: -1, col: 3, rowCount: -1, colCount: 1}],
-            lockColumns: [0, 4, 5, 7, 8, 9, 10, 12]
+            lockColumns: [0, 4, 5, 7, 8, 10, 12]
         },
-        notEditedType: ['砼', '桨', '配比', '机']
+        // 工料机类型是混凝土、砂浆、配合比、机械台班时,价格不可编辑。
+        editedTyep:[GLJTypeConst.MAIN_MATERIAL,GLJTypeConst.EQUIPMENT]//主材设备
     },
     coeSetting: {
         header: [
@@ -262,6 +263,7 @@ var gljOprObj = {
         sheet.name('ration_glj');
         me.bindSheetEvent(sheet);
         sheet.bind(GC.Spread.Sheets.Events.CellClick, me.onCellClick);
+        sheet.bind(GC.Spread.Sheets.Events.CellDoubleClick, me.onCellDoubleClick);
         gljContextMenu.loadGLJSpreadContextMenu();
     },
     initCoeSheet: function (sheet) {
@@ -430,6 +432,26 @@ var gljOprObj = {
         }
         me.editChecking(args);
     },
+    onCellDoubleClick:function (sender, args) {
+        var me = gljOprObj;
+        var header = me.setting.header;
+        if (args.row >= me.sheetData.length) {
+            return;
+        }
+        if (header[args.col] && header[args.col].dataCode == 'marketPrice') {
+            if(me.hasComposition(me.sheetData[args.row])){
+                alert("当前工料机的市场价由组成物计算得出,不可直接修改。");
+            }
+        }
+        if (header[args.col] && header[args.col].dataCode == 'basePrice') {
+            var isAdd = me.sheetData[args.row].isAdd;
+            if(isAdd==1){//是新增但没有组成物时允许修改定额价
+                if(me.hasComposition(me.sheetData[args.row])){//如果有组成物,不可修改
+                    alert("当前工料机的定额价由组成物计算得出,不可直接修改。");
+                }
+            }
+        }
+    },
     onCoeCellClick: function (sender, args) {
         var me = gljOprObj;
         var floatingObject = me.coeSheet.floatingObjects.get('customerCoe');
@@ -552,23 +574,42 @@ var gljOprObj = {
         if (me.sheetData[args.row] != undefined) {
             if (me.sheetData[args.row].isMixRatio) {
                 disable = true;
+            }else {
+                if (header[args.col] && header[args.col].dataCode == 'marketPrice') {
+                    if(me.hasComposition(me.sheetData[args.row])){
+                        disable = true;
+                    }else {
+                        disable = false;
+                    }
+                }
+                if (header[args.col] && header[args.col].dataCode == 'basePrice') {
+                    var isAdd = me.sheetData[args.row].isAdd;
+                    if(isAdd==1){//是新增但没有组成物时允许修改定额价
+                        if(me.hasComposition(me.sheetData[args.row])){//如果有组成物,不可修改
+                            disable = true;
+                        }else {
+                            disable = false;
+                        }
+                    } else {
+                        disable = true;
+                    }
+                }
             }
         }
-        if (header[args.col] && header[args.col].dataCode == 'marketPrice') {
-            var type = me.sheetData[args.row].shortName;
-            var index = _.indexOf(me.setting.notEditedType, type);
-            disable = index == -1 ? false : true;
-        }
-        if (header[args.col] && header[args.col].dataCode == 'basePrice') {
-            var isAdd = me.sheetData[args.row].isAdd;
-            var type_b = me.sheetData[args.row].shortName;
-            var index_b = _.indexOf(me.setting.notEditedType, type);
-            disable = isAdd == 1 && index_b == -1 ? false : true
-        }
         if (disable != null) {
             me.sheet.getCell(args.row, args.col, GC.Spread.Sheets.SheetArea.viewport).locked(disable);
         }
     },
+    hasComposition:function (ration_glj) {//判断是否有组成物,有则返回true
+        if(notEditType.indexOf(ration_glj.type)!=-1){
+            let con_key = this.getIndex(ration_glj,['code', 'name', 'specs', 'unit', 'type']);
+            var mixRatioMap = projectObj.project.projectGLJ.datas.mixRatioMap;
+            if(mixRatioMap[con_key]&&mixRatioMap[con_key].length>0){
+                return true;
+            }
+        }
+        return false;
+    },
     addDropDownList: function () {
         var sheet = this.coeSheet;
         sheet.suspendPaint();

+ 10 - 9
web/building_saas/main/js/views/project_view.js

@@ -301,16 +301,17 @@ var projectObj = {
                 }
                 else if (fieldName === 'calcBase') {
                     //zhong
-                    if(value){
-                        node.data.userCalcBase = value;
-                        project.calcBase.calculate(node);
-                        if(!project.calcBase.success){
-                            let activeCell = projectObj.mainSpread.getActiveSheet().getSelections()[0];
-                            projectObj.mainSpread.getActiveSheet().setValue(activeCell.row, activeCell.col, node.data.calcBase? node.data.calcBase: '');
-                        }
+                    if(value === undefined ||value === null || value.toString().trim() === ''){
+                        value = '';
+                    }
+                    node.data.userCalcBase = value;
+                    project.calcBase.calculate(node);
+                    if(!project.calcBase.success){
+                        let activeCell = projectObj.mainSpread.getActiveSheet().getSelections()[0];
+                        projectObj.mainSpread.getActiveSheet().setValue(activeCell.row, activeCell.col, node.data.calcBase? node.data.calcBase: '');
+                        return;
                     }
-                    return;
-                   // if (value) {value = parseFloat(value).toDecimal(decimalObj.decimal("totalPrice", node))};
+                    // if (value) {value = parseFloat(value).toDecimal(decimalObj.decimal("totalPrice", node))};
                 };
                 node.changed = true;
                 if (fieldName == 'feesIndex.common.unitFee'){