Ver código fonte

Merge branch 'master' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost

zhongzewei 7 anos atrás
pai
commit
60b85cd19b

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

@@ -16,6 +16,7 @@ let ration_coe_facade = require('./ration_coe_facade');
 let ration_coe = mongoose.model('ration_coe');
 let std_ration_lib_ration_items = mongoose.model('std_ration_lib_ration_items');
 let glj_calculate_facade = require('./glj_calculate_facade');
+let glj_type_util = require('../../../public/cache/std_glj_type_util');
 let quantity_detail_facade = require('../../main/facade/quantity_detail_facade');
 let logger = require("../../../logs/log_helper").logger;
 import stdgljutil  from "../../../public/cache/std_glj_type_util";
@@ -563,7 +564,7 @@ function getGLJSearchInfo(ration_glj) {
         code: ration_glj.code,
         original_code: ration_glj.original_code,
         name: ration_glj.name,
-        shortName: ration_glj.shortName,
+        //shortName: ration_glj.shortName,
         specs: ration_glj.specs,
         unit: ration_glj.unit,
         type: ration_glj.subType ? ration_glj.subType : ration_glj.type,//如果有subType,则是通过插入定额级的工料机进来的
@@ -574,6 +575,10 @@ function getGLJSearchInfo(ration_glj) {
         adjCoe: ration_glj.adjCoe,
         from: ration_glj.from ? ration_glj.from : 'std'//std:标准工料机库, cpt:补充工料机库
     };
+    let glj_type_object = glj_type_util.getStdGljTypeCacheObj();
+    let type = glj_type_object.getItemById(data.type);
+    data.shortName = type.shortName;
+
     if (data.from == 'cpt') {//从补充工料机来的数据即为新增数据
         data.is_add = 1;
     }

+ 2 - 2
web/building_saas/glj/js/composition_spread.js

@@ -275,8 +275,8 @@ CompositionSpread.prototype.getCompositionSumPrice = function(scene, affectRow,
         parentBasePrice += operationWithRound(consumption,basePrice,"glj.unitPrice","*");
     }
 
-    parentMarketPrice = parentMarketPrice.toDecimal(2);
-    parentBasePrice = parentBasePrice.toDecimal(2);
+    parentMarketPrice = parentMarketPrice.toDecimal(getDecimal("glj.unitPrice"));
+    parentBasePrice = parentBasePrice.toDecimal(getDecimal("glj.unitPrice"));
 
     return [parentMarketPrice, parentBasePrice]
 };

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

@@ -44,7 +44,7 @@ ProjectGLJSpread.prototype.init = function () {
         {name: '名称', field: 'name', visible: true,width:160},
         {name: '规格型号', field: 'specs', visible: true,width:120},
         {name: '单位', field: 'unit', visible: true,width:45},
-        {name: '类型', field: 'unit_price.short_name', visible: true,width:45},
+        {name: '类型', field: 'short_name', visible: true,width:45},
         {name: 'ID', field: 'id', visible: false},
         {name: '类型', field: 'unit_price.type', visible: false},
         {name: '总消耗量', field: 'quantity', visible: true,width:100,decimalField:'glj.quantity'},
@@ -283,10 +283,14 @@ ProjectGLJSpread.prototype.specialColumn = function (sourceData) {
     let connectCodeColumn = this.sheetObj.getFieldColumn('connect_code');
     let consumptionColumn = this.sheetObj.getFieldColumn('consumption');
     let supplyColumn = this.sheetObj.getFieldColumn('supply');
+    let shortNameColumn = this.sheetObj.getFieldColumn('short_name');
     let supplyQuantity = this.sheetObj.getFieldColumn('supply_quantity');
     let activeSheet = this.sheetObj.getSheet();
 
+
     for (let data of sourceData) {
+        //设置类型名称:
+        activeSheet.setValue(rowCounter, shortNameColumn,projectObj.project.projectGLJ.getShortNameByID(data.unit_price.type));
         // 只有材料才显示是否暂估
         if (materialIdList.indexOf(data.unit_price.type) < 0) {
             let string = new GC.Spread.Sheets.CellTypes.Text();

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

@@ -759,6 +759,7 @@ class CalcProgram {
                 let data = {
                     ID: node.data.ID,
                     projectID: me.project.ID(),
+                    unit:node.data.unit,//对清单来说,改变单位,工程量精度会跟着改变从而影响计算。
                     /*  subType、quantity、calcBase、programID、marketUnitFee等等字段较为特殊,它们的改变一定会触发计算并导致计算
                     结果的变化,从而引发保存动作。将这些字段放在该位置跟计算结果一起保存,可减少前端跟后端的通讯频率。              */
                     subType: node.data.subType,

+ 2 - 1
web/building_saas/main/js/models/main_consts.js

@@ -50,7 +50,8 @@ const notEditType = [
     gljType.CONCRETE,
     gljType.MORTAR,
     gljType.MIX_RATIO,
-    gljType.GENERAL_MACHINE
+    gljType.GENERAL_MACHINE,
+    gljType.MAIN_MATERIAL
 ];
 
 const CP_Col_Width = {          // 多处计算程序界面的列宽统一设置

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

@@ -372,7 +372,7 @@ ProjectGLJ.prototype.getAdjustPrice = function (glj) {
         //let labour=1;
         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) {//对于混凝土、配合比、砂浆、机械台班,调整价根据组成物计算得出。
+    } else if (notEditType.indexOf(glj.unit_price.type)>0&&glj.ratio_data.length>0) {//对于混凝土、配合比、砂浆、机械台班,调整价根据组成物计算得出。
         let p =0;
         for(let ratio of glj.ratio_data){
            let tem =  _.find( projectObj.project.projectGLJ.datas.gljList,{

+ 9 - 7
web/building_saas/main/js/models/ration_glj.js

@@ -114,15 +114,15 @@ var ration_glj = {
             } else {
                 me.datas = neRecodes;
             }
-            gljOprObj.showRationGLJSheetData(true);
-            //add to mainTree;
-            me.addToMainTree(neRecodes);
-            let node = project.mainTree.selected;
             project.projectGLJ.loadData(function () {
+                gljOprObj.showRationGLJSheetData(true);
+                //add to mainTree;
+                me.addToMainTree(neRecodes);
+                let node = project.mainTree.selected;
                 project.calcProgram.calcAndSave(node);
                 if (activeSubSheetIs(subSheetIndex.ssiCalcProgram)) {
                     calcProgramObj.showData(node, false);
-                };
+                }
             });
         };
         ration_glj.prototype.addToMainTree = function (datas) {
@@ -154,14 +154,16 @@ var ration_glj = {
         };
         ration_glj.prototype.refreshAfterUpdate = function (data) {
             var me = this;
+            var rationID=null;
             if (data.quantityRefresh) {
                 data.glj_result.forEach(function (item) {
-                    me.refreshEachItme(item.doc, item.query);
+                   rationID = me.refreshEachItme(item.doc, item.query);
                 })
             } else {
-                me.refreshEachItme(data.doc, data.query);
+                rationID =  me.refreshEachItme(data.doc, data.query);
             }
             gljOprObj.showRationGLJSheetData(true);
+            this.reCalcWhenGLJChange({rationID:rationID});
         };
         ration_glj.prototype.refreshEachItme = function (doc, query) {
             var glj_list = projectObj.project.ration_glj.datas;

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

@@ -363,7 +363,7 @@ var feeRateObject={
         this.mainViews = new GC.Spread.Views.DataView($('#divFee')[0],
             this.dataSource, this.columns, new GC.Spread.Views.Plugins.GridLayout(this.options));
         this.mainViews["rowClick"].addHandler(subRateObject.reFreshRateViews);
-        this.mainViews .invalidate();
+        this.mainViews.invalidate();
         document.querySelector('#divFee').focus();
     },
     reFreshRateViews:function() {

+ 38 - 22
web/building_saas/main/js/views/glj_view.js

@@ -289,6 +289,12 @@ var gljOprObj = {
         // me.detailSheet.selectionUnit(0);//0 cell,1 row,2 col;
         sheet.name('quantity_detail');
         me.bindSheetEvent(sheet);
+        sheet.bind(GC.Spread.Sheets.Events.EditStarting, function (sender, args) {
+            if(args.sheet.getValue(args.row,args.col)==null){//这里是为了解决当单元格里的值是null的时候,在单元格里输入数据,按键盘箭头移动光标的时候,会直接结束编辑,跳到另外的单元格。
+                args.sheet.setValue(args.row,args.col,"");
+            }
+        });
+
 
     },
     showCoeData: function (sheet, setting, datas) {
@@ -579,7 +585,7 @@ var gljOprObj = {
                 disable = true;
             }else {
                 if (header[args.col] && header[args.col].dataCode == 'marketPrice') {
-                    if(me.hasComposition(me.sheetData[args.row])){
+                    if(me.marketPriceReadOnly({data:me.sheetData[args.row]})){
                         disable = true;
                     }else {
                         disable = false;
@@ -588,7 +594,7 @@ var gljOprObj = {
                 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])){//如果有组成物,不可修改
+                        if(me.marketPriceReadOnly({data:me.sheetData[args.row]})){//如果有组成物,不可修改
                             disable = true;
                         }else {
                             disable = false;
@@ -758,6 +764,7 @@ var gljOprObj = {
         }
     },
     showRationGLJSheetData: function (init) {
+        let selected = this.sheet.getSelections();
         this.combineWithProjectGlj(this.sheetData);
         this.sheet.setRowCount(0);
         //console.log(+new Date())
@@ -767,7 +774,9 @@ var gljOprObj = {
         this.addMixRatioToShow();//显示组成物信息
         this.initRationTree(init);
         sheetCommonObj.showData(this.sheet, this.setting, this.sheetData);
-
+        if(selected){//定位光标到之前的位置
+            this.sheet.setSelection(selected[0].row,selected[0].col,selected[0].rowCount,selected[0].colCount);
+        }
     },
     initRationTree: function (init) {
         this.sheet.getRange(-1, 0, -1, 1).cellType(this.getTreeNodeCellType(this.sheetData));
@@ -854,9 +863,10 @@ var gljOprObj = {
                 var glj = _.find(projectGljs, {'id': ration_gljs[i].projectGLJID});
                 if (glj) {
                     let typeString = ration_gljs[i].type + "";
-                    if (typeString.startsWith("2") != -1||typeString=='4'||typeString=='5') {//只有材料类型才显示是否暂估
+                    if (typeString.startsWith("2")||typeString=='4'||typeString=='5') {//只有材料类型才显示是否暂估
                         ration_gljs[i].isEstimate = glj.is_evaluate;
                     }
+                    ration_gljs[i].shortName =projectObj.project.projectGLJ.getShortNameByID(ration_gljs[i].type);
                     ration_gljs[i].isAdd = glj.unit_price.is_add;
                     ration_gljs[i]=this.setGLJPrice(ration_gljs[i],glj);//设置工料机价格
                     var connect_index = this.getIndex(glj, gljKeyArray);
@@ -934,7 +944,7 @@ var gljOprObj = {
                 specs: pg.specs,
                 unit: pg.unit,
                 type:mixRatioList[i].type,
-                shortName: pg.unit_price.short_name,
+                shortName: projectObj.project.projectGLJ.getShortNameByID(mixRatioList[i].type),
                 consumption:mixRatioList[i].consumption,
                 rationItemQuantity: mixRatioList[i].consumption,
                 // quantity:mixRatioList[i].consumption,
@@ -1297,9 +1307,9 @@ var gljOprObj = {
                     //project.ration_glj.datas = project.ration_glj.datas.concat(result.newRecodes);//显示和缓存统一,这样的话就不用更新两个位置了
                     project.ration_glj.datas = project.ration_glj.datas.concat(result.showData);
                     gljOprObj.sheetData = gljOprObj.sheetData.concat(result.showData);
-                    gljOprObj.showRationGLJSheetData();
                     project.ration_glj.addToMainTree(result.showData);
                     project.projectGLJ.loadData(function () {
+                        gljOprObj.showRationGLJSheetData();
                         project.calcProgram.calcAndSave(selected);
                         projectObj.mainController.refreshTreeNode([selected]);
                         $.bootstrapLoading.end();
@@ -1328,24 +1338,24 @@ var gljOprObj = {
                 var nodes = [selected];
                 gljOprObj.sheetData[index] = data;
                 glj_list[list_index] = data;
-                gljOprObj.showRationGLJSheetData();
-                if (project.ration_glj.needShowToTree(data)) {//当替换的是主材或设备时,刷新对应的树节点
-                    var node = project.ration_glj.findGLJNodeByID(data.ID);
-                    if (node) {
-                        project.ration_glj.transferToNodeData(data);
-                        node.source = data;
-                        node.data = data;
-                    }
-                    node ? nodes.push(node) : "";
-                }
-                //project.ration_glj.addToMainTree(data);
-                selected.data.adjustState = result.adjustState;
                 project.projectGLJ.loadData(function () {//加载完项目工料机再计算
+                    gljOprObj.showRationGLJSheetData();
+                    if (project.ration_glj.needShowToTree(data)) {//当替换的是主材或设备时,刷新对应的树节点
+                        var node = project.ration_glj.findGLJNodeByID(data.ID);
+                        if (node) {
+                            project.ration_glj.transferToNodeData(data);
+                            node.source = data;
+                            node.data = data;
+                        }
+                        node ? nodes.push(node) : "";
+                    }
+                    //project.ration_glj.addToMainTree(data);
+                    selected.data.adjustState = result.adjustState;
                     projectObj.mainController.refreshTreeNode(nodes);
                     project.calcProgram.calcAndSave(selected);
+                    $.bootstrapLoading.end();
                 });
             }
-            $.bootstrapLoading.end();
         })
     },
     doMReplaceGLJ: function () {
@@ -1370,9 +1380,9 @@ var gljOprObj = {
                     }
                 }
             })
-            me.showRationGLJSheetData();
-            var rationNodes = me.refreshStateAfterMreplace(stateList, nodes);
             project.projectGLJ.loadData(function () {
+                me.showRationGLJSheetData();
+                var rationNodes = me.refreshStateAfterMreplace(stateList, nodes);
                 project.calcProgram.calcRationsAndSave(rationNodes);
                 $.bootstrapLoading.end();
             });
@@ -1538,7 +1548,13 @@ var gljOprObj = {
         return new TreeNodeCellType()
     },
     marketPriceReadOnly: function (node) {
-        return node.data.type == gljType.CONCRETE || node.data.type == gljType.MORTAR || node.data.type == gljType.MIX_RATIO || node.data.type == gljType.GENERAL_MACHINE || node.data.isEstimate == 1
+        let hasCom = false;
+        if(node.sourceType==ModuleNames.ration&&node.data.type==rationType.gljRation){
+            hasCom = this.hasComposition(node.data,true);
+        }else {
+            hasCom = this.hasComposition(node.data);
+        }
+        return hasCom|| node.data.isEstimate == 1;
     }
 
 }

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

@@ -35,7 +35,7 @@ var gljContextMenu = {
                         var disable = true;
                         var selected = projectObj.project.mainTree.selected;
                         var sheetData = gljOprObj.sheetData;
-                        if(selected&&selected.sourceType==ModuleNames.ration){
+                        if(selected&&selected.sourceType==ModuleNames.ration&&selected.data.type==rationType.ration){
                             disable=false;
                         }
                         if(subSpread.getActiveSheetIndex()==0&&sheetData!=null&&sheetData.length>0&&gljContextMenu.selectedRow<sheetData.length){

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

@@ -128,7 +128,7 @@ let MainTreeCol = {
             return MainTreeCol.readOnly.glj(node) || MainTreeCol.readOnly.billsParent(node)
         },
         forMarketPrice: function (node) {
-            return MainTreeCol.readOnly.bills(node) || (MainTreeCol.readOnly.ration(node) && node.data.type == rationType.ration) || gljOprObj.marketPriceReadOnly(node);
+            return MainTreeCol.readOnly.bills(node) || (node.sourceType === ModuleNames.ration && (node.data.type == rationType.ration||node.data.type== rationType.volumePrice)) || gljOprObj.marketPriceReadOnly(node);
         },
         forContain:function (node) {
             return MainTreeCol.readOnly.non_ration(node)&&!MainTreeCol.readOnly.glj(node);

+ 7 - 0
web/building_saas/main/js/views/project_view.js

@@ -309,6 +309,13 @@ var projectObj = {
                 else node.data[fieldName] = value;
                 project.calcProgram.calcAndSave(node);
                 gljOprObj.showRationGLJSheetData();
+            } else if (node.sourceType === project.Bills.getSourceType()&&fieldName === 'unit'){//修改清单单位的时候清单工程量要重新4舍5入
+                node.data[fieldName] = value;
+                node.changed = true;
+                if(node.data.quantity){
+                    node.data.quantity =scMathUtil.roundForObj(node.data.quantity,getDecimal("quantity",node));
+                }
+                project.calcProgram.calcAndSave(node);
             }
             else {
                 if (node.sourceType === project.Bills.getSourceType()) {