ソースを参照

Merge branch 'master' of http://192.168.1.12:3000/SmartCost/ConstructionCost

TonyKang 7 年 前
コミット
59427c2969

+ 45 - 0
modules/common/const/bills_fixed.js

@@ -0,0 +1,45 @@
+/**
+ * Created by Zhong on 2017/12/18.
+ */
+const fixedFlag = {
+    // 分部分项工程
+    SUB_ENGINERRING: 1,
+    // 措施项目
+    MEASURE: 2,
+    // 施工技术措施项目
+    CONSTRUCTION_TECH: 3,
+    // 安全文明施工按实计算费用
+    SAFETY_CONSTRUCTION_ACTUAL: 4,
+    // 施工组织措施专项费用
+    CONSTRUCTION_ORGANIZATION: 5,
+    // 安全文明施工专项费用
+    SAFETY_CONSTRUCTION: 6,
+    // 其他项目
+    OTHER: 7,
+    // 暂列金额
+    PROVISIONAL: 8,
+    // 暂估价
+    ESTIMATE: 9,
+    // 材料(工程设备)暂估价
+    MATERIAL_PROVISIONAL: 10,
+    // 专业工程暂估价
+    ENGINEERING_ESITIMATE: 11,
+    // 计日工
+    DAYWORK: 12,
+    // 总承包服务费
+    TURN_KEY_CONTRACT: 13,
+    // 索赔与现场签证
+    CLAIM_VISA: 14,
+    // 规费
+    CHARGE: 15,
+    // 社会保险费及住房公积金 Social insurance fee and housing accumulation fund
+    SOCIAL_INSURANCE_HOUSING_FUND: 16,
+    // 工程排污费 charges for disposing pollutants
+    POLLUTANTS: 17,
+    // 税金
+    TAX: 18,
+    //工程造价
+    ENGINEERINGCOST: 19
+};
+
+export default fixedFlag;

+ 19 - 0
modules/glj/controllers/glj_controller.js

@@ -552,6 +552,25 @@ class GLJController extends BaseController {
         res.json(result);
     }
 
+    async addGlj(req,res){
+        let result={
+            error:0
+        }
+        try {
+            let data = req.body.data;
+            data = JSON.parse(data);
+            let gljListModel = new GLJListModel();
+            // 添加项目工料机
+            let datas = await gljListModel.addList(data);
+            result.data=datas;
+        }catch (err){
+            logger.err(err);
+            result.error=1;
+            result.message = err.message;
+        }
+        res.json(result);
+    }
+
 }
 
 /**

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

@@ -22,6 +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.get('/test', gljController.init, gljController.test);
 router.get('/testModify', gljController.init, gljController.testModify);

+ 3 - 3
modules/main/controllers/labour_coe_controller.js

@@ -44,12 +44,12 @@ async function getStdLabourCoe(req, res) {
 function save(req, res) {
     let result = {error: 0, message: '', data: null};
 
-    labourCoeFacade.save(req.body.data, function (err, message, data) {
-        if (err == 0){
+    labourCoeFacade.save(req.body.data, function (err, data) {
+        if (err == ''){
             result.data = data;
         }else{
             result.error = 1;
-            result.message = message;
+            result.message = err;
         }
     });
 

+ 4 - 3
modules/main/facade/labour_coe_facade.js

@@ -112,9 +112,10 @@ function save (data, callback) {
     projectLabourCoesModel.bulkWrite(updateArr)
         .then(function(){
             logger.info(`Project LabourCoe saved successful : ${data.projectID}`);
-            callback(0, '', null);
+            callback('', null);
         })
         .catch(function (err) {
-            logger.err(err);
-            callback(1, err, null)});
+            logger.err('labourCoe save error: ' + err);
+            callback(err, null)
+        });
 }

+ 29 - 13
modules/pm/controllers/pm_controller.js

@@ -12,6 +12,7 @@ let fee_rate_facade = require("../../fee_rates/facade/fee_rates_facade");
 let billsModel = require('../../main/models/bills').model;
 let rationsModel = require('../../main/models/ration').model;
 let projectModel = require("../models/project_schema");
+let asyncTool = require('async');
 
 //统一回调函数
 let callback = function(req, res, err, message, data){
@@ -43,8 +44,8 @@ module.exports = {
             callback(false);
         });
     },
-    getProjects: function(req, res){
-        ProjectsData.getUserProjects(req.session.sessionUser.ssoId, req.session.sessionCompilation._id, function(err, message, projects){
+    getProjects: async function(req, res){
+         await ProjectsData.getUserProjects(req.session.sessionUser.ssoId, req.session.sessionCompilation._id, function(err, message, projects){
             if (projects) {
                 callback(req, res, err, message, projects);
             } else {
@@ -64,40 +65,55 @@ module.exports = {
     },
     // CSL, 2017-12-14 该方法用于项目属性:提交保存混合型数据,这些数据来自不同的表,包括projects.property、ration、bills、labour_coes.
     updateMixDatas: function(req, res){
-        let callBackInner = function (err, message, data) {
-            if (err === 0) {
-                res.json({error: err, message: message, data: data});
-            } else {
-                res.json({error: err, message: message, data: null});
+        let datas = JSON.parse(req.body.data).mixDataArr;
+        let functions = [];
+
+        function updateFunc(model, cod, doc) {
+            return function (cb) {
+                model.update(cod, doc, cb);
             }
         };
 
-        let datas = JSON.parse(req.body.data).mixDataArr;
+        function updateLC(){
+            return function (cb) {
+                datas.labourCoes.updateData.projectID = datas.projectID;
+                labourCoe.save(datas.labourCoes.updateData, cb);
+            }
+        };
 
         // 项目属性
         if (Object.keys(datas.properties).length > 0){
-            projectModel.update({ID: datas.projectID}, datas.properties, callBackInner);
+            functions.push(updateFunc(projectModel, {ID: datas.projectID}, datas.properties));
         };
 
         // 人工系数
         if (datas.labourCoes.updateData){
-            datas.labourCoes.updateData.projectID = datas.projectID;
-            labourCoe.save(datas.labourCoes.updateData, callBackInner);
+            functions.push(updateLC());
         };
 
         // 清单:每文档doc只存储一条清单,每条清单都必须定位一次文档,无法合并处理
         if (datas.bills.length > 0){
             for (let bill of datas.bills){
-                billsModel.update({projectID: datas.projectID, ID: bill.ID, deleteInfo: null}, bill, callBackInner);
+                functions.push(updateFunc(billsModel, {projectID: datas.projectID, ID: bill.ID, deleteInfo: null}, bill));
             };
         };
 
         // 定额:每文档doc只存储一条定额,每条定额都必须定位一次文档,无法合并处理
         if (datas.rations.length > 0){
             for (let ration of datas.rations){
-                rationsModel.update({projectID: datas.projectID, ID: ration.ID, deleteInfo: null}, ration, callBackInner);
+                functions.push(updateFunc(rationsModel, {projectID: datas.projectID, ID: ration.ID, deleteInfo: null}, ration));
             };
         };
+
+        asyncTool.parallel(functions, function(err, result){
+            {
+                if (!err) {
+                    res.json({error: 0, message: err, data: result});
+                } else {
+                    res.json({error: 1, message: err, data: null});
+                }
+            }
+        });
     },
     updateFiles: async function(req, res){
         let data = JSON.parse(req.body.data);

+ 14 - 7
modules/pm/models/project_model.js

@@ -6,6 +6,7 @@ import async_c from 'async';
 import UnitPriceFileModel from "../../glj/models/unit_price_file_model";
 import UnitPriceFiles from '../../glj/models/schemas/unit_price_file';
 import {defaultDecimal, billsQuantityDecimal, basicInformation, projectFeature,displaySetting} from './project_property_template';
+import fixedFlag from '../../common/const/bills_fixed';
 let FeeRateFiles = mongoose.model('fee_rate_file');
 let counter = require("../../../public/counter/counter.js");
 
@@ -15,6 +16,7 @@ let feeRateFacade = require('../../fee_rates/facade/fee_rates_facade');
 let labourCoeFacade = require('../../main/facade/labour_coe_facade');
 let calcProgramFacade = require('../../main/facade/calc_program_facade');
 let logger = require("../../../logs/log_helper").logger;
+let BillsModel = require("../../main/models/bills").model;
 
 let Projects = require("./project_schema");
 let projectType = {
@@ -30,14 +32,19 @@ let fileType = {
 
 let ProjectsDAO = function(){};
 
-ProjectsDAO.prototype.getUserProjects = function(userId, compilation, callback){
-    Projects.find({'$or': [{'userID': userId, 'compilation': compilation, 'deleteInfo': null}, {'userID': userId, 'compilation': compilation, 'deleteInfo.deleted': {'$in': [null, false]}}]}, '-_id', function(err, templates){
-        if (err) {
-            callback(1, 'Error', null);
-        } else {
-            callback(0, '', templates);
+ProjectsDAO.prototype.getUserProjects = async function(userId, compilation, callback){
+    try {
+        let projects = await Projects.find({'$or': [{'userID': userId, 'compilation': compilation, 'deleteInfo': null}, {'userID': userId, 'compilation': compilation, 'deleteInfo.deleted': {'$in': [null, false]}}]}, '-_id');
+        for(let i = 0 , len = projects.length; i < len; i++){
+            let proj = projects[i];
+            let engineeringCost = await BillsModel.find({projectID: proj.ID, 'flags.flag': fixedFlag.ENGINEERINGCOST, 'fees.totalFee': {$exists:  true}});
+            proj._doc.engineeringCost = engineeringCost.length > 0 ? engineeringCost[0].fees[0].totalFee : 0;
         }
-    });
+        callback(0, '', projects);
+    }
+    catch (err){
+        callback(1, 'Error', null);
+    }
 };
 
 ProjectsDAO.prototype.getUserProject = function (userId, ProjId, callback) {

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

@@ -38,7 +38,9 @@ const fixedFlag = {
     // 工程排污费 charges for disposing pollutants
     POLLUTANTS: 17,
     // 税金
-    TAX: 18
+    TAX: 18,
+    //工程造价
+    ENGINEERINGCOST: 19
 };
 
 let cbTools = {

+ 39 - 14
web/building_saas/main/js/models/calc_program.js

@@ -854,8 +854,6 @@ class CalcProgram {
         }
         else if (me.isLeafBill(treeNode)) {
             if (treeNode.children && treeNode.children.length > 0){
-                // me.calcLeafBillChildren(treeNode);
-
                 // 清单单价计算模式下的叶子清单:取自己的计算程序ID,找到自己的计算程序计算。(汇总清单所有定额的工料机)
                 if (me.project.property.billsCalcMode === leafBillGetFeeType.billsPrice)
                     treeNode.calcType = treeNodeCalcType.ctBillCalcProgram;
@@ -891,7 +889,7 @@ class CalcProgram {
         me.saveNodes(nodesArr);
     };
 
-    // 多个树结点入库存储,刷新界面显示。
+    // 存储、刷新零散的多个树结点
     saveNodes(treeNodes){
         if (treeNodes.length < 1) return;
 
@@ -937,14 +935,14 @@ class CalcProgram {
         };
     };
 
-/*    计算所有树结点(分3种情况),并将发生计算改动的结点入库存储
+/*    计算所有树结点(分3种情况),并返回发生变动的零散的多个树结点
     参数取值如下:
     calcAllType.catAll       计算所有树结点 (不指定参数时的默认值)
     calcAllType.catBills     计算所有清单 (改变项目属性中清单取费算法时会用到)
     calcAllType.catRations   计算所有定额、工料机形式的定额、量价,因为它们都走自己的计算程序 (改变人工系数、费率值、工料机单价时会用到) */
     calcAllNodes(calcType = calcAllType.catAll){
         let me = this;
-        let needSaveNodes = [];
+        let changedNodes = [];
 
         function calcNodes(nodes) {
             for (let node of nodes) {
@@ -954,31 +952,58 @@ class CalcProgram {
 
                 if ((calcType == calcAllType.catAll) || (calcType == node.sourceType)) {
                     me.calculate(node, false);
-                    if (node.changed) needSaveNodes.push(node);
+                    if (node.changed) changedNodes.push(node);
                 };
             }
         };
 
         calcNodes(me.project.mainTree.roots);
-        // me.saveNodes(needSaveNodes);   保存要与计算分离,否则实际应用场景中,会产生多次通讯。
-        return needSaveNodes;
+        // me.saveNodes(changedNodes);   保存要与计算分离,否则实际应用场景中,会产生多次通讯。
+        return changedNodes;
     };
 
-    // 重新计算叶子清单下的所有子结点:如定额、工料机定额等(calculate算法基于定额、工料机定额的计算结果是正确的,实际上有时它们的计算结果并不是最新的)
-    calcLeafBillChildren(treeNode){
+    // 计算叶子清单下的所有子结点(如定额、量价、工料机定额等), 并计算自身和所有父结点。最后打包存储。
+    calcLeafAndSave(treeNode){
         let me = this;
         if(!me.isLeafBill(treeNode)) return;
         if (treeNode.children && treeNode.children.length > 0) {
-            let needSaveNodes = [];
+            let changedNodes = [];
             for (let child of treeNode.children){
                 me.calculate(child, false);
-                if (child.changed) needSaveNodes.push(child);
+                if (child.changed) changedNodes.push(child);
+            };
+
+            me.calculate(treeNode);
+            let cur = treeNode;
+            while (cur) {
+                if (cur.changed) changedNodes.push(cur);
+                cur = cur.parent;
             };
-            me.saveNodes(needSaveNodes);
+
+            me.saveNodes(changedNodes);
         };
     };
-    calcRationsAndSave(nodes){//计算批量替换工料机后受影响的定额,同时将结果打包保存
 
+    // 计算多条零散的定额,并计算他们所属的清单、父级清单,然后打包存储。如:批量替换工料机后受影响的定额。
+    calcRationsAndSave(rationNodes){
+        let me = this, leafBills = [], changedNodes = [];
+        for (let node of rationNodes) {
+            me.calculate(node, false);
+            if (node.changed) changedNodes.push(node);
+            let leafBill = node.parent;
+            if (leafBill && leafBills.indexOf(leafBill) < 0) leafBills.push(leafBill);      // 多条定额同属一条叶子清单时,避免叶子清单重复计算
+        };
+
+        for (let node of leafBills){
+            me.calculate(node);
+            let cur = node;
+            while (cur) {
+                if (cur.changed && changedNodes.indexOf(cur) < 0) changedNodes.push(cur);
+                cur = cur.parent;
+            };
+        };
+
+        me.saveNodes(changedNodes);
     };
 
 }

+ 3 - 0
web/building_saas/main/js/models/project.js

@@ -139,6 +139,9 @@ var PROJECT = {
                 var newNode, br = that.Ration.getBillsSortRation(cacheNode.source.getID()), i;
                 for (i = 0; i < br.length; i++) {
                     newNode = that.mainTree.addNode(cacheNode);
+                    if(br[i].type==rationType.gljRation){
+                        br[i]=  that.ration_glj.combineRationAndGLJ(br[i]);
+                    }
                     newNode.source = br[i];
                     newNode.sourceType = that.Ration.getSourceType();
                     newNode.data = br[i];

+ 32 - 4
web/building_saas/main/js/models/project_glj.js

@@ -169,11 +169,11 @@ ProjectGLJ.prototype.updateBasePriceFromRG=function(recode,updateField,newval){
             }
             //更新项目工料机价格
             me.refreshProjectGLJPrice(data);
-            me.refreshRationGLJPrice(glj);
+            me.refreshRationGLJPrice(glj);//刷新定额工料机列表的记录
             gljOprObj.showRationGLJSheetData();
-            me.refreshTreeNodePriceIfNeed(glj);
-            //触发计算
-            projectObj.project.ration_glj.reCalcWhenGLJChange(recode);
+            me.refreshTreeNodePriceIfNeed(glj);//刷新造价书中主树上的定额工料机;
+            let nodes = me.getImpactRationNodes(glj);//取到因为改变工料机价格而受影响的定额
+            projectObj.project.calcProgram.calcRationsAndSave(nodes);//触发计算程序
             $.bootstrapLoading.end();
         }
         $.bootstrapLoading.start();
@@ -197,6 +197,31 @@ ProjectGLJ.prototype.refreshTreeNodePriceIfNeed = function (data) {
     }
 }
 
+//根据工料机,取得所有受影响的定额节点
+ProjectGLJ.prototype.getImpactRationNodes = function (glj) {
+    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){
+            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){
+                    item.data.marketUnitFee = glj.unit_price.market_price; //更新市场单价
+                    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){
@@ -205,9 +230,12 @@ ProjectGLJ.prototype.refreshRationGLJPrice=function (glj) {
             ration_glj.adjustPrice=this.getAdjustPrice(glj);
         }
     }
+}
 
+ProjectGLJ.prototype.refreshRationTypeGLJ = function (glj) {
 
 }
+
 ProjectGLJ.prototype.refreshProjectGLJPrice=function(data){
     let projectGljs = this.datas.gljList;
     let indexList = ['code','name','specs','unit','type'];

+ 1 - 0
web/building_saas/main/js/models/ration.js

@@ -365,6 +365,7 @@ var Ration = {
             ration.unit = std.unit;
             ration.libID = std.rationRepId;
             ration.content = std.jobContent;
+            ration.adjustState = '';
             if (std.chapter) {
                 ration.comments = std.chapter.explanation;
                 ration.ruleText = std.chapter.ruleText;

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

@@ -476,9 +476,12 @@ var ration_glj = {
             CommonAjax.post("/ration/insertGLJAsRation",postData,function (data) {
                 console.log(data);
                  // 更新兄弟节点的序列号
-                if(selectedSerialNo!=null&&selectedSerialNo<children.length){
-                    for(let i = selectedSerialNo;i<children.length;i++){
-                        children[i].serialNo+=gljList.length;
+                if(selectedSerialNo!=null){
+                    let selectIndex = _.findIndex(children,{"serialNo":selectedSerialNo});
+                    if(selectIndex+1<children.length){
+                        for(let i = selectIndex+1;i<children.length;i++){
+                            children[i].serialNo+=gljList.length;
+                        }
                     }
                 }
                 for(let r_glj of data){
@@ -491,6 +494,9 @@ var ration_glj = {
                     newNode.data = r_glj;
                     ProjectController.syncDisplayNewNode(projectObj.mainController, newNode);
                 }
+                let parentNode = project.mainTree.nodes[project.mainTree.prefix+parentNodeID];
+                project.calcProgram.calcLeafAndSave(parentNode);//计算父级清单的所有子节点
+                //this.nodes[this.prefix + parentID];
                 callback();
                 $.bootstrapLoading.end();
             },function () {
@@ -640,6 +646,27 @@ var ration_glj = {
             data.subType = data.type;
             data.marketUnitFee = data.marketPrice;
         };
+        ration_glj.prototype.combineRationAndGLJ = function (ration) {
+            if(ration){
+                var projectGLJData = projectObj.project.projectGLJ.datas;
+                var projectGljs = projectGLJData.gljList;
+                var mixRatioMap = projectGLJData.mixRatioMap;
+                var glj = _.find(projectGljs,{'id':ration.projectGLJID});
+                if(glj){
+                    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);
+                        ration.subList = mixRatios;
+                    }
+                }
+            }
+            return ration;
+        };
         ration_glj.prototype.updateFromMainSpread=function (value,node,fieldName) {
             if(node.data[fieldName]===value){
                 return;

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

@@ -138,6 +138,7 @@ let calcBaseView = {
         }
         me.buildSheet();
         let baseObj = projectObj.project.calcBase.getBaseByClass(node);
+        console.log(baseObj);
         me.showData(me.toViewData(baseObj));
 
     },

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

@@ -779,6 +779,32 @@ var gljOprObj = {
             projectObj.project.ration_glj.updateRationGLJByEdit(recode,updateField,newval);
         }
     },
+    updateRationTypeGLJ:function (value,node,fieldName) {
+        console.log(fieldName)
+        console.log(value);
+        let newval;
+        let updatePrice = false;
+        if(fieldName=="marketUnitFee"){
+            updatePrice = true;
+            if(value==null){
+                newval=0;
+            }else {
+                var decimal = getDecimal("glj.unitPrice");
+                newval = number_util.checkNumberValue(value,decimal);
+            }
+        }else {
+            if(value!=null){
+                //update
+            }
+        }
+        if(newval&&updatePrice==true){
+            projectObj.project.projectGLJ.updatePriceFromRG(node.data,"marketPrice",newval);
+            return
+        }
+
+        projectObj.mainController.refreshTreeNode([node]);
+    },
+
     updateRationAss:function (args) {
         var me = gljOprObj;
         var newval;
@@ -1072,7 +1098,7 @@ var gljOprObj = {
           if(node){
               node.data.adjustState=s.adjustState;
               nodes.push(node);
-              rationNode.push(node);
+              rationNodes.push(node);
           }
         });
         gljNodes.length>0?nodes = nodes.concat(gljNodes):"";

+ 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) {

+ 15 - 3
web/building_saas/main/js/views/project_property_labour_coe_view.js

@@ -56,7 +56,20 @@ let labourCoeView = {
         var me = labourCoeView;
         if (args.propertyName !== "value"){return;};
         let cell = me.sheet.getCell(args.row, args.col);
-        me.addNeedUpdateData({ID: cell.tag(), coe: cell.value()});
+        let value = args.newValue;
+        let oValue = args.oldValue;
+        if (number_util.isNumber(value)) {
+            value = value.toDecimal(3);
+            me.sheet.suspendEvent();
+            cell.value(value);
+            me.sheet.resumeEvent();
+            me.addNeedUpdateData({ID: cell.tag(), coe: value});
+        } else {
+            me.sheet.suspendEvent();
+            cell.value(oValue);  // 屏蔽事件,否则这句会导致死循环
+            me.sheet.resumeEvent();
+            alert('当前输入的数据类型不正确,请重新输入。');
+        }
     },
 
     addNeedUpdateData: function (data) {
@@ -131,9 +144,8 @@ let labourCoeView = {
         me.loadData(datas);
     },
 
-    refresh(data){
+    refresh(){
         let me = this;
-        projectObj.project.labourCoe.refreshData(data);
         me.needUpdateDatas.splice(0, me.needUpdateDatas.length);
         $("#std_labour_coe_files").val('');
         calcProgramManage.buildSheet();

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

@@ -269,7 +269,7 @@ var projectObj = {
         if(node.sourceType==project.ration_glj.getSourceType()){
             project.ration_glj.updateFromMainSpread(value,node,fieldName);
         }if(node.sourceType==ModuleNames.ration&&node.data.type==rationType.gljRation){
-            console.log("hehe");
+            gljOprObj.updateRationTypeGLJ(value,node,fieldName);
         } else if (value !== calcFees.getFee(node.data, fieldName)) {
             if (fieldName === 'code') {
                 projectObj.updateCode(node, value);
@@ -327,7 +327,7 @@ var projectObj = {
                 };
 
                 if (colSetting.data.wordWrap) {
-                    info.sheet.autoFitRow(node.serialNo());
+                    this.mainSpread.getActiveSheet().autoFitRow(node.serialNo());
                 }
                 projectObj.mainController.refreshTreeNode([node]);
             }
@@ -767,16 +767,16 @@ $('#property_ok').click(function () {
 
     // 人工系数
     if (labourCoeView.needSave()){
-        reCalcRations = true;
-        reCalcBills = true;
-        project.calcProgram.compileAllTemps();
-
         let libID = $("#std_labour_coe_files").children("option:selected").val();
         let libName = $("#std_labour_coe_files").children("option:selected").text();
 
         labourCoes.updateData = {libID: libID, libName: libName, newItemArr: labourCoeView.needUpdateDatas};
+        project.labourCoe.refreshData(labourCoes.updateData);  // 全编译所用到的人工系数来自project.labourCoe,所以必须先刷新project.labourCoe
+        project.calcProgram.compileAllTemps();
+        reCalcRations = true;
+        reCalcBills = true;
     };
-
+    console.log(properties);
     // 重新计算树节点
     let changedNodes = [];
     if (reCalcRations)    // 定额动,全部计算。
@@ -807,18 +807,19 @@ $('#property_ok').click(function () {
     };
 
     console.log(mixDatas);
+    // return;   // for test.
     function hasMixData() {
         return Object.keys(mixDatas.properties).length > 0 ||
             mixDatas.labourCoes.updateData || mixDatas.rations.length > 0 || mixDatas.bills.length > 0;
     }
 
-    if(hasMixData){
+    if(hasMixData()){
         CommonAjax.post('/pm/api/updateMixDatas', {user_id: userID, mixDataArr: mixDatas}, function (rstData) {
 /*            if (changedNodes.length > 0) {
                 for (let node of changedNodes){delete node.changed};
             };
-            if (mixDatas.labourCoes.updateData) labourCoeView.refresh(mixDatas.labourCoes.updateData);*/
-            // window.location.href = '/main?project=' + projectID;
+            if (mixDatas.labourCoes.updateData) labourCoeView.refresh();*/
+            window.location.href = '/main?project=' + projectID;
         });
     }
 });

+ 1 - 1
web/building_saas/pm/js/pm_ajax.js

@@ -45,7 +45,7 @@ var UpdateProjectData = function (updateData, callback) {
     });
 };
 // 重命名项目
-var RenameProject = function(projId, newName, callback) {
+var RenameProject_ajax = function(projId, newName, callback) {
     $.ajax({
         type: "POST",
         url: '/pm/api/renameProject',

+ 1 - 1
web/building_saas/pm/js/pm_main.js

@@ -101,7 +101,7 @@ let ProjTreeSetting = {
             event: {
                 getText: function (html, node, text) {
                     if(node.data.projType === projectType.tender){
-                        html.push('0');
+                        let engineeringCostText = node.data.engineeringCost ? node.data.engineeringCost : 0;
                     }
                 }
             }