瀏覽代碼

Merge branch 'master' into olym

olym 7 年之前
父節點
當前提交
9cebab07cf

+ 9 - 4
modules/glj/controllers/glj_controller.js

@@ -14,6 +14,8 @@ import UnitPriceFileModel from "../models/unit_price_file_model";
 let logger = require("../../../logs/log_helper").logger;
 let consts = require('../../main/models/project_consts');
 let glj_type_util = require('../../../public/cache/std_glj_type_util');
+let mongoose = require('mongoose');
+let ration = mongoose.model('ration');
 
 const ProjectModel = require('../../pm/models/project_model').project;
 class GLJController extends BaseController {
@@ -552,7 +554,7 @@ class GLJController extends BaseController {
         res.json(result);
     }
 
-    async addGlj(req,res){
+    async modifyKeyValue(req,res){//修改工料机关键的属性:名称、类型、规格、型号等
         let result={
             error:0
         }
@@ -560,9 +562,12 @@ class GLJController extends BaseController {
             let data = req.body.data;
             data = JSON.parse(data);
             let gljListModel = new GLJListModel();
-            // 添加项目工料机
-            let datas = await gljListModel.addList(data);
-            result.data=datas;
+            let ration_data = await ration.findOne(data.ration);
+            //  修改项目工料机
+            let projcetGLJ = await gljListModel.modifyGLJ(data.updateData,ration_data);
+
+           // let datas = await gljListModel.addList(data);
+            result.data=projcetGLJ;
         }catch (err){
             logger.err(err);
             result.error=1;

+ 17 - 4
modules/glj/models/glj_list_model.js

@@ -377,7 +377,7 @@ class GLJListModel extends BaseModel {
         let unitPriceFileId = unitPriceFile.id;
         let unitPriceModel = new UnitPriceModel();
         let [unitPriceData, isAdd] = await unitPriceModel.addUnitPrice(data, unitPriceFileId,"modify");
-        let gljData={};
+        let gljData=null;
         if(isAdd){ //如果是新增,则新增一条新的项目工料机
             data.code = unitPriceData.code;
             gljData  = await this.insertGLJWhenIsAdd(data,ration_glj,unitPriceFileId);
@@ -390,8 +390,15 @@ class GLJListModel extends BaseModel {
                 type:data.type,
                 unit:data.unit
             }
-            gljData = await this.findDataByCondition(condition,{_id: 0});
-            if(!gljData){
+            let gljList = await this.findDataByCondition(condition,{_id: 0},false);
+            if(gljList&&gljList.length>0){
+                for(let tem of gljList){
+                    if(tem.code == unitPriceData.code){
+                        gljData = tem;
+                    }
+                }
+            }
+            if(gljData==null){
                 data.code = unitPriceData.code;
                 gljData  = await this.insertGLJWhenIsAdd(data,ration_glj,unitPriceFileId);
             }
@@ -408,7 +415,13 @@ class GLJListModel extends BaseModel {
         if (glj.type === GLJTypeConst.CONCRETE || glj.type === GLJTypeConst.MORTAR ||
             glj.type === GLJTypeConst.MIX_RATIO || glj.type === GLJTypeConst.GENERAL_MACHINE){
             // 配合比数据插入
-            let connect_key =this.getIndex(ration_glj,['code','name','specs','unit','type']);
+            let key_array = [];
+            if(ration_glj.subType){//定额类型的工料机和定额工料机的key有点不同subType
+                key_array=  ['code','name','specs','unit','subType'];
+            }else {
+                key_array=  ['code','name','specs','unit','type'];
+            }
+            let connect_key =this.getIndex(ration_glj,key_array);
             let connect_key_n =this.getIndex(glj,['code','name','specs','unit','type']);
             //先查找配合比数据是否已经存在
             let mixRatioModel = new MixRatioModel();

+ 3 - 1
modules/glj/models/unit_price_model.js

@@ -121,7 +121,9 @@ class UnitPriceModel extends BaseModel {
         };
         if(data.from=='cpt'){//如果是来自补充工料机,则都添加新增标记
             insertData.is_add=1;
-        }else if (unitPriceData&&unitPriceData.length>0) {// 如果原始编码能找到,但不存在一样的编号,名称,单位.型号等,更改code和添加新增标记
+        }
+
+        if (unitPriceData&&unitPriceData.length>0) {// 如果原始编码能找到,但不存在一样的编号,名称,单位.型号等,更改code和添加新增标记
             insertData.code = data.original_code+"-"+unitPriceData.length;
             insertData.is_add=1;
         }

+ 1 - 1
modules/glj/routes/glj_router.js

@@ -22,7 +22,7 @@ router.post('/change-file', gljController.init, gljController.changeUnitPriceFil
 router.post('/save-as', gljController.init, gljController.unitPriceSaveAs);
 router.post('/get-composition', gljController.init, gljController.getComposition);
 router.post('/updatePrice', gljController.init, gljController.updateUnitPrice);
-router.post('/add',gljController.init, gljController.addGlj)
+router.post('/modifyKeyValue',gljController.init, gljController.modifyKeyValue);
 
 router.get('/test', gljController.init, gljController.test);
 router.get('/testModify', gljController.init, gljController.testModify);

+ 1 - 0
modules/main/models/ration.js

@@ -66,6 +66,7 @@ let rationSchema = new Schema({
     specs:String,//规格型号
     shortName:String,//缩写
     customQuantity:String,//自定义消耗
+    adjCoe:Number,
     from:{type: String,default:'std'}//std, cpt  来自标准工料机库、补充工料机库
 
 });

+ 1 - 1
modules/ration_glj/facade/glj_calculate_facade.js

@@ -101,7 +101,7 @@ async function calculateQuantityPerGLJ(glj,index,coeList,assList,adjustState,noN
     };
     try {
         if(noNeedCal==null){
-            if(!glj._doc.hasOwnProperty('customQuantity')||glj.customQuantity==null){
+            if(!glj._doc.hasOwnProperty('customQuantity')||glj.customQuantity==null||glj.customQuantity==""){
                 quantity =scMathUtil.roundTo(parseFloat(glj.rationItemQuantity),-decimal);
                 quantity =calculateAss(quantity,assList,glj);
                 quantity = calculateQuantityByCoes(quantity,coeList,glj);

+ 0 - 1
modules/ration_glj/facade/ration_glj_facade.js

@@ -717,7 +717,6 @@ async function insertGLJAsRation(data) {
     let gljList = data.gljList;
     //先更新counter
     let counter = await projCounter.model.findOneAndUpdate({projectID:data.projectID},{ration:data.rationCount},{new:true});
-    console.log(counter);
     if(data.hasOwnProperty("selectedSerialNo")){ //如果需要,更新序列号。
         let query={
             projectID:data.projectID,

+ 36 - 25
modules/reports/util/rpt_construct_data_util.js

@@ -735,33 +735,39 @@ function ext_getFee(feeKey, dtlFeeKey) {
     let dtObj = parentObj["myOwnRawDataObj"];
     if (feeKey && dtObj) {
         for (let dItem of dtObj.data) {
-            let hasValue = false;
-            if (dItem.hasOwnProperty("fees")) {
-                for (let fee of dItem["fees"]) {
-                    if (fee["fieldName"] === feeKey) {
-                        if (dtlFeeKey) {
-                            rst.push(fee[dtlFeeKey]);
-                        } else {
-                            rst.push(fee["unitFee"]);
-                        }
-                        hasValue = true;
-                        break;
-                    }
+            rst.push(pri_getFee(dItem, feeKey, dtlFeeKey));
+        }
+    }
+    for (let i = 0; i < rst.length; i++) {
+        rst[i] = parseFloat(rst[i]);
+    }
+    return rst;
+}
+
+function pri_getFee(dItem, feeKey, dtlFeeKey) {
+    let rst = 0;
+    let hasValue = false;
+    if (dItem.hasOwnProperty("fees")) {
+        for (let fee of dItem["fees"]) {
+            if (fee["fieldName"] === feeKey) {
+                if (dtlFeeKey) {
+                    rst = fee[dtlFeeKey];
+                } else {
+                    rst = fee["unitFee"];
                 }
-            } else if (dItem.hasOwnProperty(feeKey)) {
-                hasValue = true;
-                rst.push(dItem[feeKey]);
-            } else {
                 hasValue = true;
-                rst.push(0);
-            }
-            if (!hasValue) {
-                rst.push(0);
+                break;
             }
         }
+    } else if (dItem.hasOwnProperty(feeKey)) {
+        hasValue = true;
+        rst = dItem[feeKey];
+    } else {
+        hasValue = true;
+        rst = 0;
     }
-    for (let i = 0; i < rst.length; i++) {
-        rst[i] = parseFloat(rst[i]);
+    if (!hasValue) {
+        rst = 0;
     }
     return rst;
 }
@@ -868,7 +874,7 @@ function ext_getPropertyByFlag(flagVal, rstKey, dftValIfEmpty) {
     if (flagVal && rstKey && dtObj) {
         let isArr = (flagVal instanceof Array);
         for (let dItem of dtObj.data) {
-            let doc = (dItem._doc === null || dItem._doc === undefined)?dItem:dItem._doc;
+            let doc = (dItem._doc)?dItem._doc:dItem;
             if (doc.hasOwnProperty("flags")) {
                 let bFlag = false;
                 for (let flagItem of doc.flags) {
@@ -882,13 +888,18 @@ function ext_getPropertyByFlag(flagVal, rstKey, dftValIfEmpty) {
                     if (bFlag) break;
                 }
                 if (bFlag) {
-                    rst.push(doc[rstKey]);
+                    let keys = rstKey.split(".");
+                    if (keys[0] === "fees") {
+                        rst.push(pri_getFee(doc, "common", keys[1]));
+                    } else {
+                        //其他,比如名称什么
+                    }
                     break;
                 }
             }
         }
     }
-    if (rst.length === 0 && dftValIfEmpty) {
+    if (rst.length === 0 && dftValIfEmpty !== null) {
         rst.push(dftValIfEmpty);
     }
     return rst;

+ 11 - 1
public/web/scMathUtil.js

@@ -159,6 +159,16 @@ let scMathUtil = {
     isNumber : function (obj) {
         return obj === +obj;
     },
+    roundForObj:function(obj,decimal){
+        let me = this;
+        let value;
+        if(me.isNumber(obj)){
+            value = me.roundTo(obj,-decimal)
+        }else {
+            value = me.roundTo(Number(obj),-decimal);
+        }
+        return value
+    },
     roundToString:function(obj,decimal){
         let me = this;
         let value;
@@ -173,7 +183,7 @@ let scMathUtil = {
 
 Number.prototype.toDecimal = function (ADigit) {
     //return parseFloat(this.toFixed(ADigit));
-    digit = (ADigit && typeof(ADigit) === 'number' && Number.isInteger(ADigit) && ADigit >= 0) ? -ADigit : -2;
+    digit = ((ADigit!=null||ADigit!=undefined) && typeof(ADigit) === 'number' && Number.isInteger(ADigit) && ADigit >= 0) ? -ADigit : -2;
     // var s = scMathUtil.roundTo(this, digit);
     // console.log('Number: ' + this + '   Digit: ' + digit + '    Result: ' + s);
     // return parseFloat(s);

+ 2 - 2
public/web/sheet/sheet_common.js

@@ -235,7 +235,7 @@ var sheetCommonObj = {
         ComboCellForActiveCell.prototype = new GC.Spread.Sheets.CellTypes.ComboBox();
         ComboCellForActiveCell.prototype.paintValue = function (ctx, value, x, y, w, h, style, options) {
             let sheet = options.sheet;
-            if (options.row === sheet.getActiveRowIndex() && options.col === sheet.getActiveColumnIndex()) {
+            if (options.row === sheet.getActiveRowIndex() && options.col === sheet.getActiveColumnIndex() && !sheet.getCell(options.row, options.col).locked()) {
                 GC.Spread.Sheets.CellTypes.ComboBox.prototype.paintValue.apply(this, arguments);
 
             } else {
@@ -244,7 +244,7 @@ var sheetCommonObj = {
         };
         ComboCellForActiveCell.prototype.getHitInfo = function (x, y, cellStyle, cellRect, options) {
             let sheet = options.sheet;
-            if (options.row === sheet.getActiveRowIndex() && options.col === sheet.getActiveColumnIndex()) {
+            if (options.row === sheet.getActiveRowIndex() && options.col === sheet.getActiveColumnIndex() && !sheet.getCell(options.row, options.col).locked()) {
                 return GC.Spread.Sheets.CellTypes.ComboBox.prototype.getHitInfo.apply(this, arguments);
 
             } else {

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

@@ -0,0 +1,115 @@
+/**
+ * Created by Tony on 2017/12/18.
+ */
+
+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');
+
+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 = 229, pagesize = "A4";
+
+let userId_Leng = 1142; //小冷User Id
+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('测试 - 打开模板: 封-1 ', 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);
+                    //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();
+});

+ 5 - 0
web/building_saas/css/main.css

@@ -323,4 +323,9 @@ body {
 label.title{
     display: inline-block;
     width: 100px;
+}
+.modal-feeRate {max-width: 550px}
+
+.gc-column-header-cell{
+    text-align: center!important;
 }

+ 27 - 9
web/building_saas/main/js/models/calc_program.js

@@ -341,18 +341,24 @@ let executeObj = {
                 if (!me.treeNode.data.gljList) return 0;
                 let result = 0;
                 for (let glj of me.treeNode.data.gljList) {
-                    let price = 0;
+                    let price = 0, temp = 0;
                     if (base.gljTypes.indexOf(glj.type) >= 0) {
-                        if (base.calcType == baseCalcType.baseCalc){ price = parseFloat(glj["basePrice"]);}
-                        else if (base.calcType == baseCalcType.adjustCalc){price = parseFloat(glj["adjustPrice"]);}
-                        else if (base.calcType == baseCalcType.budgetCalc){price = parseFloat(glj["marketPrice"]);}
-                        else if (base.calcType == baseCalcType.diffCalc){
+                        if (base.calcType == baseCalcType.diffCalc){
                             let aprice = glj["adjustPrice"] ? glj["adjustPrice"] : 0;
+                            aprice = parseFloat(aprice);
                             let mprice = glj["marketPrice"] ? glj["marketPrice"] : 0;
-                            price = (parseFloat(mprice) - parseFloat(aprice)).toDecimal(decimalObj.process);
+                            mprice = parseFloat(mprice);
+                            temp = (glj["quantity"] * mprice).toDecimal(decimalObj.ration.unitPrice) - (glj["quantity"] * aprice).toDecimal(decimalObj.ration.unitPrice);
+                            temp = temp.toDecimal(decimalObj.ration.unitPrice);
+                        }
+                        else {
+                            if (base.calcType == baseCalcType.baseCalc){ price = parseFloat(glj["basePrice"]);}
+                            else if (base.calcType == baseCalcType.adjustCalc){price = parseFloat(glj["adjustPrice"]);}
+                            else if (base.calcType == baseCalcType.budgetCalc){price = parseFloat(glj["marketPrice"]);}
+                            temp = (glj["quantity"] * price).toDecimal(decimalObj.ration.unitPrice);
                         };
-                        result = result + (glj["quantity"] * price).toDecimal(decimalObj.process);
-                        result = (result).toDecimal(decimalObj.process);
+
+                        result = (result + temp).toDecimal(decimalObj.ration.unitPrice);
                     };
                 };
                 return result;
@@ -601,6 +607,18 @@ class CalcProgram {
         return me.isLeafBill(treeNode) && (treeNode.children.length ===0) && (!treeNode.data.calcBase);
     };
 
+    isRation(treeNode){
+        return treeNode.sourceType === ModuleNames.ration && treeNode.data.type === rationType.ration;
+    };
+
+    isVolumePrice(treeNode){
+        return treeNode.sourceType === ModuleNames.ration && treeNode.data.type === rationType.volumePrice;
+    };
+
+    isGljRation(treeNode){
+        return treeNode.sourceType === ModuleNames.ration && treeNode.data.type === rationType.gljRation;
+    };
+
     initFeeField(treeNode, fieldName){
         if (!treeNode.data.fees) {
             treeNode.data.fees = [];
@@ -915,7 +933,7 @@ class CalcProgram {
                     feeRate: node.data.feeRate,
                     feeRateID: node.data.feeRateID
                 };
-                if(node.sourceType==ModuleNames.ration&&node.data.type==rationType.gljRation){//定额类型的工料机做特殊处理
+                if(node.sourceType==ModuleNames.ration && node.data.type==rationType.gljRation){//定额类型的工料机做特殊处理
                     data.code=node.data.code;
                     data.projectGLJID = node.data.projectGLJID;
                     delete data.marketUnitFee;

+ 70 - 0
web/building_saas/main/js/models/project_glj.js

@@ -154,10 +154,80 @@ ProjectGLJ.prototype.updatePriceFromRG=function(recode,updateField,newval){
     }
 };
 
+ProjectGLJ.prototype.updatePropertyFromMainSpread = function (node,updateField,newval) {
+   if(updateField=="contain"){
+
+   }else {
+       this.updateGLJProperty(node,updateField,newval);
+   }
+};
+
+
+ProjectGLJ.prototype.updateGLJProperty=function (node,updateField,newval) {
+    let rationTypeGLJ = node.data;
+    let postData = {};
+    if(rationTypeGLJ[updateField]==newval){
+        return;
+    }
+    let data ={
+        glj_id: rationTypeGLJ.GLJID,
+        project_id: rationTypeGLJ.projectID,
+        code: rationTypeGLJ.code,
+        original_code:rationTypeGLJ.original_code,
+        name: rationTypeGLJ.name,
+        shortName:rationTypeGLJ.shortName,
+        specs: rationTypeGLJ.specs,
+        unit: rationTypeGLJ.unit,
+        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:补充工料机库
+    };
+    if(updateField=='subType'){
+        data.type = newval;
+        data.type_of_work = newval;
+        data.shortName = this.getShortNameByID(newval);
+    }else {
+        data[updateField]=newval;
+    }
+    postData.ration = {
+        ID:rationTypeGLJ.ID,
+        projectID:rationTypeGLJ.projectID
+    };
+    postData.updateData = data;
+    $.bootstrapLoading.start();
+    CommonAjax.post("/glj/modifyKeyValue",postData,function (result) {
+        console.log(result);  //更新节点信息
+        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.shortName = result.unit_price.short_name;
+        //触发计算并更新节点信息
+        node.changed=true;
+        projectObj.project.projectGLJ.loadData(function () {
+            projectObj.project.calcProgram.calculate(node);
+            projectObj.project.calcProgram.saveNode(node);
+            $.bootstrapLoading.end();
+        });//重新加载项目工料机数据
+        //上面两步都是异步操作,这句应该是要等上面两步做完了再执行的
+    },function (err) {
+        $.bootstrapLoading.end();
+    });
+    
+}
+
 ProjectGLJ.prototype.updateBasePriceFromRG=function(recode,updateField,newval){
     let me = this;
     let projectGljs = this.datas.gljList;
     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) {

+ 1 - 1
web/building_saas/main/js/models/ration_glj.js

@@ -653,11 +653,11 @@ var ration_glj = {
                 var mixRatioMap = projectGLJData.mixRatioMap;
                 var glj = _.find(projectGljs,{'id':ration.projectGLJID});
                 if(glj){
+                    ration.basePrice=glj.unit_price.base_price;
                     ration.marketUnitFee=glj.unit_price.market_price;
                     //ration_gljs[i].adjustPrice=glj.adjust_price;
                     ration.isEstimate=glj.is_evaluate;
                     ration.isAdd=glj.unit_price.is_add;
-                    ration.adjustPrice=projectObj.project.projectGLJ.getAdjustPrice(glj);
                     var connect_index = gljOprObj.getIndex(glj,['code','name','specs','unit','subType'])
                     if(mixRatioMap.hasOwnProperty(connect_index)){
                         var mixRatios = gljOprObj.getMixRationShowDatas(mixRatioMap[connect_index],projectGljs);

+ 7 - 1
web/building_saas/main/js/views/glj_view.js

@@ -606,9 +606,13 @@ var gljOprObj = {
               if(glj.isMixRatio==true){//如果是用于显示的组成物,则不用计算,跳过
                   continue;
               }
+              quantity = scMathUtil.roundForObj(quantity,getDecimal("ration.quantity"));
+              glj.quantity=scMathUtil.roundForObj(glj.quantity,getDecimal("glj.quantity"));
               glj.totalQuantity = scMathUtil.roundToString(quantity*glj.quantity,getDecimal("glj.quantity"));
               if(glj.hasOwnProperty('subList')){//需要计算glj下挂的组成物的总消耗量
                   for(let subG of glj.subList){
+                      subG.rationItemQuantity=scMathUtil.roundForObj(subG.rationItemQuantity,getDecimal("glj.quantity"));
+                      glj.totalQuantity=scMathUtil.roundForObj(glj.totalQuantity,getDecimal("glj.quantity"));
                       subG.totalQuantity = scMathUtil.roundToString(subG.rationItemQuantity*glj.totalQuantity,getDecimal("glj.quantity"));
                   }
               }
@@ -751,7 +755,7 @@ var gljOprObj = {
         var newval;
         if(updateField=='marketPrice'||updateField=='customQuantity'||updateField=='basePrice'){
             if(args.editingText==null){
-                updateField=='marketPrice'||updateField=='customQuantity'?newval=0:newval="";
+                updateField=='marketPrice'?newval=0:newval="";
             }else {
                 var decimal = updateField=='customQuantity'?getDecimal("glj.quantity"):getDecimal("glj.unitPrice");
                 newval = number_util.checkNumberValue(args.editingText,decimal);
@@ -794,6 +798,8 @@ var gljOprObj = {
             }
         }else {
             if(value!=null){
+                projectObj.project.projectGLJ.updatePropertyFromMainSpread(node,fieldName,value)
+                return;
                 //update
             }
         }

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

@@ -77,7 +77,7 @@ let MainTreeCol = {
             return node.sourceType === projectObj.project.Bills.getSourceType();
         },
         ration: function (node) {
-            return node.sourceType === projectObj.project.Ration.getSourceType();
+            return projectObj.project.calcProgram.isRation(node);
         },
         glj: function (node) {
             return node.sourceType == projectObj.project.ration_glj.getSourceType();

+ 17 - 7
web/building_saas/main/js/views/project_property_bills_quantity_decimal.js

@@ -61,7 +61,7 @@ let billsDecimalView = {
     },
     
     setComboBox: function (sheet, items) {
-        let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
+        let combo = sheetCommonObj.getDynamicCombo();
         combo.items(items);
         combo.editable(true);
         sheet.getRange(-1, 1, -1, 1).cellType(combo);
@@ -94,10 +94,12 @@ let billsDecimalView = {
     bindEvent: function (workBook) {
         const _events = GC.Spread.Sheets.Events;
         let sheet = workBook.getActiveSheet();
-        sheet.bind(_events.EditStarting, this.onEditStarting);
-        sheet.bind(_events.EditEnded, this.onEditEnded);
-        sheet.bind(_events.ClipboardPasting, this.onClipboardPasting);
-        sheet.bind(_events.ClipboardPasted, this.onClipboardPasted);
+        let me = billsDecimalView;
+        sheet.bind(_events.EnterCell, me.onEnterCell);
+        sheet.bind(_events.EditStarting, me.onEditStarting);
+        sheet.bind(_events.EditEnded, me.onEditEnded);
+        sheet.bind(_events.ClipboardPasting, me.onClipboardPasting);
+        sheet.bind(_events.ClipboardPasted, me.onClipboardPasted);
     },
 
     showData(datas){
@@ -116,6 +118,10 @@ let billsDecimalView = {
         this.renderSheetFuc(sheet, fuc);
     },
 
+    onEnterCell: function (sender, args) {
+        args.sheet.repaint();
+    },
+
     onEditStarting: function (sender, args) {
         if(args.col === 0 && args.row === 0){//其他未列单位不可编辑
             args.cancel = true;
@@ -123,13 +129,16 @@ let billsDecimalView = {
     },
 
     onEditEnded: function (sender, args) {
+        console.log('enter');
         let me = billsDecimalView;
-        let v =  args.editingText ? args.editingText.toString().trim() : '';
+        console.log(args);
+        let v =  args.editingText !== undefined && args.editingText !== null ? args.editingText.toString().trim() : '';
+        console.log(v);
         if(v.length === 0){
             return;
         }
         if(args.col === 0){
-            if(me.hasUnit(me.cache, v)){
+            if(v !== me.cache[args.row].unit && me.hasUnit(me.cache, v)){
                 alert('已存在此计量单位');
                 args.sheet.setValue(args.row, args.col, me.isDef(me.cache[args.row]) ? me.cache[args.row].unit : '');
             }
@@ -150,6 +159,7 @@ let billsDecimalView = {
                 me.cache[args.row].decimal = v;
             }
         }
+        console.log(me.cache[args.row]);
     },
 
     onClipboardPasting: function (sender, args) {

+ 0 - 1
web/building_saas/main/js/views/project_property_decimal_view.js

@@ -79,7 +79,6 @@ function isValidDigit(v){
 //newV用户可编辑数据
 function toUpdateDecimal(orgV, newV){
     let rst = false;
-    let len = Object.keys(newV).length;
     reCompare(orgV, newV);
     function reCompare(orgV, newV){
         for(let attr in newV){

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

@@ -59,7 +59,7 @@ let labourCoeView = {
         let value = args.newValue;
         let oValue = args.oldValue;
         if (number_util.isNumber(value)) {
-            value = value.toDecimal(3);
+            value = value.toDecimal(2);
             me.sheet.suspendEvent();
             cell.value(value);
             me.sheet.resumeEvent();

+ 18 - 11
web/building_saas/main/js/views/project_view.js

@@ -270,8 +270,8 @@ var projectObj = {
             project.ration_glj.updateFromMainSpread(value,node,fieldName);
         }if(node.sourceType==ModuleNames.ration&&node.data.type==rationType.gljRation){
             gljOprObj.updateRationTypeGLJ(value,node,fieldName);
-        } else if (value !== calcFees.getFee(node.data, fieldName)) {
-            if (fieldName === 'code') {
+        } else if (value !== calcFees.getFee(node.data, fieldName)||fieldName == 'quantity') {//工程量需要进行转换,所以做特殊处理
+            if (fieldName === 'code' && !project.calcProgram.isVolumePrice(node)) {
                 projectObj.updateCode(node, value);
             }
             else if(fieldName ==='feeRate'){
@@ -282,7 +282,11 @@ var projectObj = {
                 if (fieldName === 'quantity') {
                    if (value) {
                        value = project.quantity_detail.autoTransformQuantity(value,node);
-                       value = value.toDecimal(decimalObj.decimal(fieldName,node))
+                       value = scMathUtil.roundForObj(value,decimalObj.decimal(fieldName,node));
+                       if(value==node.data[fieldName]){
+                           projectObj.mainController.refreshTreeNode([node]);
+                           return;
+                       }
                    };
                    if(project.quantity_detail.quantityEditChecking(value,node,fieldName)){
                        node.data.isFromDetail=0;
@@ -840,20 +844,23 @@ $('#property_ok').click(function () {
     }
     //清单工程量精度
     let newBillsDecimalDatas = billsDecimalView.toBillsDecimalDatas(billsDecimalView.cache);
-    console.log(newBillsDecimalDatas);
-    console.log(billsQuanDecimal.datas);
     if(billsDecimalView.toUpdate(billsQuanDecimal.datas, newBillsDecimalDatas)){
-        console.log(newBillsDecimalDatas);
+        billsQuanDecimal.datas = newBillsDecimalDatas;
         reCalcBills = true;
         properties['property.billsQuantityDecimal'] = newBillsDecimalDatas;
     }
     //小数位数
     let updateDecimal = m_getDecimalData($('input', '#poj-settings-decimal'));
-    if(toUpdateDecimal(decimalObj, updateDecimal)){
+    if(toUpdateDecimal(decimalObj, updateDecimal)) {
+        let frChanged = decimalObj.feeRate != updateDecimal.feeRate;
+        setDecimal(decimalObj, updateDecimal);
+        if (frChanged) {
+            project.calcProgram.compileAllTemps()
+        }
         reCalcRations = true;
         reCalcBills = true;
         properties['property.decimal'] = updateDecimal;
-    };
+    }
     // 呈现选项
     projDisplayView.updateChecking(projectID, properties);
 
@@ -868,7 +875,6 @@ $('#property_ok').click(function () {
         reCalcRations = true;
         reCalcBills = true;
     };
-    console.log(properties);
     // 重新计算树节点
     let changedNodes = [];
     if (reCalcRations)    // 定额动,全部计算。
@@ -898,8 +904,9 @@ $('#property_ok').click(function () {
         };
     };
 
-    console.log(mixDatas);
-    // return;   // for test.
+    // for test.
+/*    console.log(mixDatas);
+    return; */
     function hasMixData() {
         return Object.keys(mixDatas.properties).length > 0 ||
             mixDatas.labourCoes.updateData || mixDatas.rations.length > 0 || mixDatas.bills.length > 0;