zhangweicheng 7 سال پیش
والد
کامیت
82aaa0f0ef

+ 5 - 5
modules/glj/models/glj_list_model.js

@@ -36,7 +36,7 @@ class GLJListModel extends BaseModel {
      * @var {Array}
      */
     ownCompositionTypes = [GLJTypeConst.CONCRETE, GLJTypeConst.MORTAR, GLJTypeConst.MIX_RATIO,
-        GLJTypeConst.COMMERCIAL_CONCRETE, GLJTypeConst.COMMERCIAL_MORTAR, GLJTypeConst.GENERAL_MACHINE];
+        GLJTypeConst.COMMERCIAL_CONCRETE, GLJTypeConst.COMMERCIAL_MORTAR, GLJTypeConst.GENERAL_MACHINE,GLJTypeConst.MAIN_MATERIAL];
 
     /**
      * 构造函数
@@ -139,7 +139,7 @@ class GLJListModel extends BaseModel {
                 // 有组成物的类型才查找
                 let key = keyMap[tmp.id];
                 if (quantityList[key]!=undefined&&(tmp.type === GLJTypeConst.CONCRETE || tmp.type === GLJTypeConst.MORTAR ||
-                    tmp.type === GLJTypeConst.MIX_RATIO || tmp.type === GLJTypeConst.GENERAL_MACHINE)){
+                    tmp.type === GLJTypeConst.MIX_RATIO || tmp.type === GLJTypeConst.GENERAL_MACHINE|| tmp.type === GLJTypeConst.MAIN_MATERIAL)){
                     connect_keys.push(key);
                 }
             }
@@ -309,9 +309,9 @@ class GLJListModel extends BaseModel {
             }
             let CompositionGLJ=[];
             let unitPriceModel = new UnitPriceModel();
-            // 判断类型,如果是混凝土、砂浆或者配合比则查找对应的组成物(前提是没有对应的项目工料机数据)
+            // 判断类型,如果是混凝土、砂浆、配合比或者主材则查找对应的组成物(前提是没有对应的项目工料机数据)
             if (data.type === GLJTypeConst.CONCRETE || data.type === GLJTypeConst.MORTAR ||
-                data.type === GLJTypeConst.MIX_RATIO || data.type === GLJTypeConst.GENERAL_MACHINE) {
+                data.type === GLJTypeConst.MIX_RATIO || data.type === GLJTypeConst.GENERAL_MACHINE||data.type === GLJTypeConst.MAIN_MATERIAL) {
                 //如果是新增
                 if(isAddProjectGLJ ){
                     await this.compositionInit(data, unitPriceFileId);
@@ -687,7 +687,7 @@ class GLJListModel extends BaseModel {
             let projectGLJData = await this.getDataById(projectGLJId,unitPriceFileId);
 
             let allowType = [GLJTypeConst.MIX_RATIO, GLJTypeConst.CONCRETE, GLJTypeConst.MORTAR,
-                GLJTypeConst.GENERAL_MACHINE];
+                GLJTypeConst.GENERAL_MACHINE,GLJTypeConst.MAIN_MATERIAL];
 
             if (projectGLJData.unit_price === null || allowType.indexOf(projectGLJData.unit_price.type) < 0) {
                 throw '找不到相关项目工料机';

+ 1 - 1
modules/main/facade/quantity_detail_facade.js

@@ -338,7 +338,7 @@ async function summateResults (query,detailList,decimal) {
         let bill = await bill_model.findOne({'projectID':query.projectID,deleteInfo: null,"ID":ration.billsItemID});
         let bill_decimal = await decimal_facade.getBillsQuantityDecimal(query.projectID,bill.unit);
         let bill_quantity = scMathUtil.roundForObj(bill.quantity,bill_decimal);
-        let contain = scMathUtil.roundForObj(quantity/bill_quantity,decimal.process);
+        let contain = bill_quantity==0?0:scMathUtil.roundForObj(quantity/bill_quantity,decimal.process);
         let r_quantity = quantity;
         quantity = getQuantityByUnit(quantity,ration.unit);
         quantity = scMathUtil.roundTo(quantity, -decimal.ration.quantity);

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

@@ -25,7 +25,7 @@ $(document).ready(function() {
             }
 
             // 筛选数据显示(显示混凝土、砂浆、配合比)
-            projectGLJSheet.filterData('unit_price.type', [GLJTypeConst.CONCRETE, GLJTypeConst.MORTAR, GLJTypeConst.MIX_RATIO]);
+            projectGLJSheet.filterData('unit_price.type', [GLJTypeConst.CONCRETE, GLJTypeConst.MORTAR, GLJTypeConst.MIX_RATIO,GLJTypeConst.MAIN_MATERIAL]);
 
             projectGLJSheet.selectRow(projectGLJSpread.firstMixRatioRow);
             projectGLJId = projectGLJSheet.getActiveDataByField('id');

+ 2 - 3
web/building_saas/main/js/controllers/project_controller.js

@@ -106,8 +106,8 @@ ProjectController = {
         if (selected.sourceType === project.Bills.getSourceType() && selected.depth() > 0) {
             if (selected.source.children.length > 0) {
                 alert('当前清单已有清单子项,不能套用定额。');
-            } else if (false) {
-                alert('当前清单已有公式计算,不能套用定额。');
+            } else if (selected.data.calcBase&&selected.data.calcBase!="") {
+                alert('当前有基数计算不能插入定额/量价/工料机。');
             } else {
                 if (std) {
                     newSource = project.Ration.insertStdRation(selected.source.getID(), null, std);
@@ -115,7 +115,6 @@ ProjectController = {
                 } else {
                     newSource = project.Ration.insertRation(selected.source.getID(),null, rationType);
                 }
-
                 newNode = project.mainTree.insert(selected.getID(), selected.tree.rootID());
             }
         } else if (selected.sourceType === project.Ration.getSourceType()) {

+ 12 - 1
web/building_saas/main/js/models/composition.js

@@ -74,4 +74,15 @@ Composition.prototype.getCompositionByCode = function(code, gljType = 0) {
     }
 
     return result;
-};
+};
+
+Composition.prototype.getCompositionByGLJ = function (glj) {
+    let mixRatioMap = projectObj.project.projectGLJ.datas.mixRatioMap;
+    let projectGljs = projectObj.project.projectGLJ.datas.gljList;
+    let connect_index = gljOprObj.getIndex(glj,gljKeyArray);
+    let gljList=[];
+    if(mixRatioMap[connect_index]){ //说明是有组成物的类型
+        gljList =  gljOprObj.getMixRationShowDatas(mixRatioMap[connect_index], projectGljs);
+    }
+    return gljList;
+}

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

@@ -545,7 +545,7 @@ var quantity_detail = {
                         if(node.sourceType === project.Bills.getSourceType()){
                             me.updateBillQuantity(value,node);
                         }else {
-                            me.updateRationQuantity(value,node);//to do 加上工程量表达式和含量更新
+                            me.updateRationQuantity(value,node);
                         }
                     }else {
                         projectObj.mainController.refreshTreeNode([node]);

+ 5 - 4
web/building_saas/main/js/models/ration_glj.js

@@ -492,7 +492,6 @@ var ration_glj = {
             selectedSerialNo == null ? "" : postData.selectedSerialNo = selectedSerialNo;
             $.bootstrapLoading.start();
             CommonAjax.post("/ration/insertGLJAsRation", postData, function (data) {
-                console.log(data);
                 // 更新兄弟节点的序列号
                 if (selectedSerialNo != null) {
                     let selectIndex = _.findIndex(children, {"serialNo": selectedSerialNo});
@@ -502,11 +501,12 @@ var ration_glj = {
                         }
                     }
                 }
+                let newNode=null;
                 for (let r_glj of data) {
                     r_glj.marketUnitFee = r_glj.marketPrice;
                     r_glj.quantity = r_glj.quantity + "";
                     project.Ration.datas.push(r_glj);
-                    let newNode = project.mainTree.insert(parentNodeID, nextNodeID);
+                    newNode = project.mainTree.insert(parentNodeID, nextNodeID);
                     newNode.source = r_glj;
                     newNode.sourceType = project.Ration.getSourceType();
                     newNode.data = r_glj;
@@ -515,7 +515,7 @@ var ration_glj = {
                 let parentNode = project.mainTree.nodes[project.mainTree.prefix + parentNodeID];
                 project.calcProgram.calcLeafAndSave(parentNode);//计算父级清单的所有子节点
                 //this.nodes[this.prefix + parentID];
-                callback();
+                callback(newNode);
                 $.bootstrapLoading.end();
             }, function () {
                 $.bootstrapLoading.end();
@@ -746,9 +746,10 @@ var ration_glj = {
             });
             return node;
         };
-        ration_glj.prototype.reCalcWhenGLJChange = function (ration_glj) {//当改变定额工料机时,重新计算定额以及父节点
+        ration_glj.prototype.reCalcWhenGLJChange = function (ration_glj) {//当改变定额工料机时,重新计算定额以及父节点
             let node = this.findRationNodeByID(ration_glj.rationID);
             if (node) {
+                node.changed = true;
                 project.calcProgram.calcAndSave(node);
             }
         };

+ 49 - 17
web/building_saas/main/js/views/glj_view.js

@@ -390,6 +390,10 @@ var gljOprObj = {
         }
     },
     onCheckBoxClick: function (sender, args) {
+        let selected = projectObj.project.mainTree.selected;
+        if(selected.sourceType == ModuleNames.ration_glj||(selected.sourceType == ModuleNames.ration&&selected.data.type==rationType.gljRation)){//选中的是工料机时不可编辑
+            return ;
+        }
         var checkboxValue = args.sheet.getCell(args.row, args.col).value();
         var newval = 0;
         if (checkboxValue) {
@@ -599,9 +603,11 @@ var gljOprObj = {
             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,gljKeyArray);
+    hasComposition:function (ration_glj,isRationType) {//判断是否有组成物,有则返回true   现在主材类型的工料机也有可能有组成物。
+        let type = isRationType==true? ration_glj.subType:ration_glj.type;
+        if(notEditType.indexOf(type)!=-1||type==gljType.MAIN_MATERIAL){
+            let keyArray = isRationType==true? rationKeyArray:gljKeyArray;
+            let con_key = this.getIndex(ration_glj,keyArray);
             var mixRatioMap = projectObj.project.projectGLJ.datas.mixRatioMap;
             if(mixRatioMap[con_key]&&mixRatioMap[con_key].length>0){
                 return true;
@@ -681,13 +687,17 @@ var gljOprObj = {
                 this.selectedNodeId = node.getID();
             }
             if (node.sourceType == "ration") {
-                this.showRationGLJData(node);
-                this.showRationCoeData(node);
-                this.showRationAssData(node);
+                if(node.data.type==rationType.gljRation){
+                    this.showMixRatio(node);
+                }else {
+                    this.showRationGLJData(node);
+                    this.showRationCoeData(node);
+                    this.showRationAssData(node);
+                }
                 isShow = true;
             }
             if(node.sourceType == ModuleNames.ration_glj){
-
+                this.showMixRatio(node);
                 isShow = true;
             }
 
@@ -708,14 +718,14 @@ var gljOprObj = {
     showMixRatio:function (node) {//显示组成物到定额工料机
         let mixRatioMap = projectObj.project.projectGLJ.datas.mixRatioMap;
         let projectGljs = projectObj.project.projectGLJ.datas.gljList;
-        let indexArray =node.getSourceType()==ModuleNames.ration?rationKeyArray:gljKeyArray;
+        let indexArray =node.sourceType==ModuleNames.ration?rationKeyArray:gljKeyArray;
         let connect_index = this.getIndex(node.data,indexArray);
         let gljList=[];
         if(mixRatioMap[connect_index]){ //说明是有组成物的类型
             gljList =  this.getMixRationShowDatas(mixRatioMap[connect_index], projectGljs);
         }
         if(gljList.length>0){//计算总消耗量
-            if(node.getSourceType()==ModuleNames.ration){
+            if(node.sourceType==ModuleNames.ration){
                 this.calcMixRationTotalQuantity(gljList,node.data.quantity);
             }else {
                let totalQuantity = this.getTotalQuantity(node.data);
@@ -726,6 +736,15 @@ var gljOprObj = {
         this.sheet.setRowCount(0);
         this.sheetData = sortRationGLJ(this.sheetData);
         sheetCommonObj.showData(this.sheet, this.setting, this.sheetData);
+
+        this.sheet.getRange(-1, 0, -1, this.setting.header.length).locked(true);//锁住定额工料机的所有列
+        this.detailSheet.getRange(-1, 0, -1, this.detailSetting.header.length).locked(true);//锁住工程量明细的所有列
+
+        sheetCommonObj.showData(this.coeSheet, this.coeSetting, []);
+        sheetCommonObj.showData(this.assSheet, this.assSetting, []);
+
+        this.coeSheetData = [];
+        this.assSheetData = [];
     },
 
     showRationGLJData: function (node) {
@@ -835,7 +854,7 @@ var gljOprObj = {
                 var glj = _.find(projectGljs, {'id': ration_gljs[i].projectGLJID});
                 if (glj) {
                     let typeString = ration_gljs[i].type + "";
-                    if (typeString.indexOf("2") != -1||typeString=='4'||typeString=='5') {//只有材料类型才显示是否暂估
+                    if (typeString.startsWith("2") != -1||typeString=='4'||typeString=='5') {//只有材料类型才显示是否暂估
                         ration_gljs[i].isEstimate = glj.is_evaluate;
                     }
                     ration_gljs[i].isAdd = glj.unit_price.is_add;
@@ -915,16 +934,22 @@ var gljOprObj = {
                 specs: pg.specs,
                 unit: pg.unit,
                 shortName: pg.unit_price.short_name,
+                consumption:mixRatioList[i].consumption,
                 rationItemQuantity: mixRatioList[i].consumption,
                 // quantity:mixRatioList[i].consumption,
-                basePrice: pg.unit_price.base_price,
+              /*  basePrice: pg.unit_price.base_price,
                 marketPrice: pg.unit_price.market_price,
-                adjustPrice: pg.adjust_price,
-                isEstimate: pg.is_evaluate,
+                adjustPrice: pg.adjust_price,*/
+                //isEstimate: pg.is_evaluate,
                 isMixRatio: true,
                 isAdd: pg.unit_price.is_add,
                 GLJID: pg.glj_id
+            };
+            let typeString = pg.type + "";
+            if (typeString.startsWith("2")||typeString=='4'||typeString=='5') {//只有材料类型才显示是否暂估
+                tem.isEstimate =  pg.is_evaluate;
             }
+            this.setGLJPrice(tem,pg);
             temRationGLJs.push(tem);
         }
         temRationGLJs = _.sortBy(temRationGLJs, 'code');
@@ -1235,15 +1260,22 @@ var gljOprObj = {
         return distTypeTree;
     },
     doInsertGLJ: function () {
+        var me = this;
         var selected = projectObj.project.mainTree.selected;
         var project = projectObj.project;
-        if (gljOprObj.GLJSelection.length <= 0) {
+        if (me.GLJSelection.length <= 0) {
             return;
         }
         $("#glj_tree_div").modal('hide');
-        project.ration_glj.insertGLJAsRation(gljOprObj.GLJSelection, selected, function (result) {
-            project.projectGLJ.loadData();
-            gljOprObj.showRationGLJSheetData();
+        project.ration_glj.insertGLJAsRation(me.GLJSelection, selected, function (node) {
+            project.projectGLJ.loadData(function () {
+                if(me.hasComposition(node.data,true)){
+                    me.showMixRatio(node);
+                }else {
+                    me.showRationGLJSheetData();
+                }
+            });
+
         })
     },
     doAddGLJ: function () {

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

@@ -573,16 +573,30 @@ var projectObj = {
                     icon: 'fa-sign-in',
                     disabled: function () {
                         var selected = project.mainTree.selected;
-                        if (selected) {
-                            if (            // CSL, 2017-11-28
-                                selected.sourceType === project.Ration.getSourceType() ||
-                                (selected.sourceType === project.Bills.getSourceType() && selected.source.children.length === 0)
-                               ) return false
-                            else return true
-                        } else return true
+                        if (selected) {// Vincent, 2018-01-02
+                            if(selected.sourceType === project.Ration.getSourceType()){ // 焦点行是定额/量价/工料机,有效显示。
+                                return false;
+                            }else if(selected.sourceType === project.Bills.getSourceType()){
+                               if(selected.data.type == billType.FX){//焦点行是分项,有效显示。
+                                  return false
+                               }
+                               if(selected.data.type == billType.BILL && selected.source.children.length === 0){//焦点行是清单,且没有子项,有效显示。
+                                    return false
+                               }
+                            }
+                        }
+                        return true;
                     },
                     callback: function (key, opt) {
                         ProjectController.addRation(project, controller, rationType.ration);
+                    },
+                    visible: function(key, opt){
+                        var selected = project.mainTree.selected;
+                        if(selected.sourceType == ModuleNames.bills&&selected.data.type == billType.DXFY){
+                            return false
+                        }else {
+                            return true
+                        }
                     }
                 },
                 "insertLJ": {