zhangweicheng 7 年 前
コミット
d89bb0708f

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

@@ -114,10 +114,13 @@ class GLJListModel extends BaseModel {
             for(let tmp of gljData) {
                 // 有组成物的类型才查找
                 let key = keyMap[tmp.id];
-                if (tmp.type === GLJTypeConst.CONCRETE || tmp.type === GLJTypeConst.MORTAR ||
-                    tmp.type === GLJTypeConst.MIX_RATIO || tmp.type === GLJTypeConst.GENERAL_MACHINE|| tmp.type === GLJTypeConst.MAIN_MATERIAL){
+                if(this.ownCompositionTypes.indexOf(tmp.type)!=-1){
                     connect_keys.push(key);
                 }
+                /*if (tmp.type === GLJTypeConst.CONCRETE || tmp.type === GLJTypeConst.MORTAR ||
+                    tmp.type === GLJTypeConst.MIX_RATIO || tmp.type === GLJTypeConst.GENERAL_MACHINE|| tmp.type === GLJTypeConst.MAIN_MATERIAL){
+                    connect_keys.push(key);
+                }*/
             }
             // 查找组成物的消耗量
             let totalComposition = {};
@@ -267,8 +270,7 @@ 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.MAIN_MATERIAL) {
+            if(this.ownCompositionTypes.indexOf(data.type)!=-1) {
                 //如果是新增
                 if(isAddProjectGLJ ){
                     await this.compositionInit(data, unitPriceFileId);
@@ -380,8 +382,7 @@ class GLJListModel extends BaseModel {
         //新增项目工料机
         let gljData = await this.add(glj);
         //查看是否是有配合比的工料机类型
-        if (glj.type === GLJTypeConst.CONCRETE || glj.type === GLJTypeConst.MORTAR ||
-            glj.type === GLJTypeConst.MIX_RATIO || glj.type === GLJTypeConst.GENERAL_MACHINE){
+        if(this.ownCompositionTypes.indexOf(glj.type)!=-1){
             // 配合比数据插入
             let key_array = [];
             if(ration_glj.subType){//定额类型的工料机和定额工料机的key有点不同subType
@@ -651,8 +652,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.MAIN_MATERIAL];
+            let allowType = this.ownCompositionTypes;
 
             if (projectGLJData.unit_price === null || allowType.indexOf(projectGLJData.unit_price.type) < 0) {
                 throw '找不到相关项目工料机';

+ 1 - 0
public/web/sheet/sheet_common.js

@@ -63,6 +63,7 @@ var sheetCommonObj = {
         for (var i = 0; i < setting.header.length; i++) {
             sheet.setValue(0, i, setting.header[i].headerName, ch);
             sheet.setColumnWidth(i, setting.header[i].headerWidth?setting.header[i].headerWidth:100);
+            sheet.setColumnVisible(i,setting.header[i].visible === false ? false:true);
         }
     },
     cleanSheet: function(sheet, setting, rowCount) {

+ 25 - 23
web/building_saas/main/js/controllers/block_controller.js

@@ -24,7 +24,13 @@ let BlockController = {
         if(blockData.firstNodeType != blockType.RATION && blockData.isFBFX !=  Bills.isFBFX(selected)){//除了复制定额外,焦点行和复制的块不是来自同一个地方(分部分项工其它)
             return true;
         }
-        if(selected.sourceType == Bills.getSourceType() && selected.data.type == billType.FX && blockData.firstNodeType == blockType.FB){//焦点行是分项,复制块的第一层是分部,则无效。
+        if(this.blockIsFXorBX(blockData.firstNodeType) && this.isFB(selected)){//复制块的第一层是分项或补项,焦点行是分部,且分部有子项并且子项不是分项或补项,则无效。
+            if(selected.children.length && !this.isFXorBX(selected.children[0])){
+                return true;
+            }
+        }
+
+        if(this.isFXorBX(selected) && blockData.firstNodeType == blockType.FB){//焦点行是分项或补项,复制块的第一层是分部,则无效。
             return true;
         }
         if(blockData.firstNodeType == blockType.RATION && selected.sourceType == Bills.getSourceType()){ //复制的是定额/量价/工料机、焦点行是分部/清单父项则无效
@@ -142,7 +148,7 @@ let BlockController = {
             if(selected.sourceType == ModuleNames.ration && selected.data.type != rationType.install ){//焦点行是定额/量价/工料机,则粘贴为后项
                 return "next";
             }
-            if(isFXorBX(selected)||(selected.sourceType === Bills.getSourceType()&& selected.source.children.length == 0)){//焦点行是分项/叶子清单,且无基数计算,则粘贴到分项/叶子清单下
+            if(this.isFXorBX(selected)||(selected.sourceType === Bills.getSourceType()&& selected.source.children.length == 0)){//焦点行是分项/叶子清单,且无基数计算,则粘贴到分项/叶子清单下
                 if(!this.haveCalcBase(selected)){//无基数计算
                     return "sub";
                 }
@@ -154,8 +160,8 @@ let BlockController = {
         setRadioProp('pre_node',{checked:false,disabled:false});
         if(Bills.isFBFX(selected)){//  (2.1)、焦点行属于“分部分项工程”:
             //复制块的第一层、焦点行的类型都是“分部”
-            if(blockData.firstNodeType == blockType.FB && isFB(selected)){
-                if(selected.children.length > 0 && isFXorBX(selected.children[0])){//焦点行分部下有分项补项,弹出“粘贴位置选择”,默认为当前行的后项,可选前项,子项灰显。
+            if(blockData.firstNodeType == blockType.FB && this.isFB(selected)){
+                if(selected.children.length > 0 && this.isFXorBX(selected.children[0])){//焦点行分部下有分项补项,弹出“粘贴位置选择”,默认为当前行的后项,可选前项,子项灰显。
                     setRadioProp('sub_node',{checked:false,disabled:true});
                 }else {
                     //默认为当前行的后项,可选前项、子项。
@@ -163,13 +169,13 @@ let BlockController = {
                 }
             }
             //复制块的第一层、焦点行的类型都是“分项”或补项
-            if(blockIsFXorBX(blockData.firstNodeType) && isFXorBX(selected)){
+            if(this.blockIsFXorBX(blockData.firstNodeType) && this.isFXorBX(selected)){
                 //默认为当前行的后项,可选前项,子项灰显不可选。
                 setRadioProp('sub_node',{checked:false,disabled:true});
             }
             //复制块的第一层是分项,焦点行是分部,且分部下无子项或者子项是分项
-            if(blockIsFXorBX(blockData.firstNodeType)&& isFB(selected)){
-                if(selected.children.length == 0 || isFXorBX(selected.children[0])){
+            if(this.blockIsFXorBX(blockData.firstNodeType)&& this.isFB(selected)){
+                if(selected.children.length == 0 || this.isFXorBX(selected.children[0])){
                     return 'sub';//不弹出选择窗口,直接粘贴为子项。
                 }
             }
@@ -193,21 +199,6 @@ let BlockController = {
            $("#"+id).prop("checked",options.checked);
            $("#"+id).prop("disabled",options.disabled);
        }
-
-       function isFB(selected) {
-           return selected.sourceType == Bills.getSourceType() && selected.data.type == billType.FB;
-       }
-
-       function isFXorBX(selected) {//是分项或者补项
-            if(selected.sourceType == Bills.getSourceType()){
-                return   selected.data.type == billType.FX || selected.data.type == billType.BX;
-            }
-            return false;
-       }
-       function blockIsFXorBX(type) {
-           return type == blockType.FX||type == blockType.BX;
-       }
-
     },
     /**
      * @param blockData
@@ -601,7 +592,18 @@ let BlockController = {
         }
         return matchs;
     },
-
+    isFB :function (selected) {
+        return selected.sourceType == projectObj.project.Bills.getSourceType() && selected.data.type == billType.FB;
+    },
+    isFXorBX:function (selected) {//是分项或者补项
+        if(selected.sourceType == projectObj.project.Bills.getSourceType()){
+            return   selected.data.type == billType.FX || selected.data.type == billType.BX;
+        }
+        return false;
+    },
+    blockIsFXorBX: function (type) {
+        return type == blockType.FX||type == blockType.BX;
+    },
     removeBlock:function () {
         removeLocalCache('project_block');
     }

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

@@ -312,9 +312,9 @@ var Bills = {
                             updateNode[n_key].data[u_key] =updateDoc[u_key];
                         }
                     }
-                    project.calcProgram.calcAndSave(newParent);
                     controller.singleDelete();//删除树节点
                     me.tree.singleDelete(node.source);
+                    project.calcProgram.calcAndSave(newParent);
                     $.bootstrapLoading.end();
                 }, function () {
                     $.bootstrapLoading.end();

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

@@ -611,7 +611,8 @@ let calcTools = {
             feeRateID: treeNode.data.feeRateID,
             contain: treeNode.data.contain,
             quantityEXP: treeNode.data.quantityEXP,
-            summaryFees: treeNode.data.summaryFees
+            summaryFees: treeNode.data.summaryFees,
+            name:treeNode.data.name
         };
 
         // 定额大类

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

@@ -508,7 +508,7 @@ ProjectGLJ.prototype.getImpactRationNodes = function (gljs) {
     let nodes = [];
     let rationMap = {};
     let idArray = _.map(gljs,'id');
-    let priceArray = _.map(gljs,'unit_price');
+    let gljMap = _.indexBy(gljs,'id');
     //先根据项目工料机ID,找到受影响定额的ID
     let ration_glj_list = projectObj.project.ration_glj.datas; //取定额工料机数据
     for (let rg of ration_glj_list) {
@@ -519,9 +519,9 @@ ProjectGLJ.prototype.getImpactRationNodes = function (gljs) {
     for (let item of projectObj.project.mainTree.items) {
         if (item.sourceType == ModuleNames.ration) {
             if (item.data.type == rationType.gljRation) {//取定额类型的工料机
-                let idx = _.indexOf(idArray,item.data.projectGLJID);
-                if (idx != -1) {
-                    item.data.marketUnitFee = priceArray[idx].market_price; //更新市场单价
+                let tem_g = gljMap[item.data.projectGLJID];
+                if(tem_g){
+                    item.data.marketUnitFee = this.getMarketPrice(tem_g);//这里要按计算的市场价为准,不能直接取
                     nodes.push(item);
                 }
             } else if (rationMap[item.data.ID] == true) {  //受影响的定额

+ 26 - 28
web/building_saas/main/js/models/ration_glj.js

@@ -428,12 +428,11 @@ var ration_glj = {
                         }
                     }
                 }
-                me.refreshTreeNodeIfNeeded(recode);//刷新造价书上的树节点(如果需要)
-
                 if (initShow == false) {//不需要初始化,只需耍新当前显示就可以了
                     gljOprObj.showRationGLJSheetData();
                 }
                 projectObj.project.projectGLJ.loadData(function () {//等项目工料机加载完成后再给用户编辑
+                    me.refreshTreeNodeIfNeeded(recode);//刷新造价书上的树节点(如果需要)
                     me.reCalcWhenGLJChange(recode);//触发计算定额以及父节点
                     if (initShow == true) {
                         gljOprObj.refreshView();
@@ -751,36 +750,35 @@ var ration_glj = {
             return ration;
         };
         ration_glj.prototype.updateFromMainSpread = function (value, node, fieldName) {
-            if (node.data[fieldName] === value) {
-                return;
-            }
-            if (fieldName == "marketUnitFee") {
-                var decimal = getDecimal("glj.unitPrice");
-                var newval = number_util.checkNumberValue(value, decimal);
-                if (newval) {
-                    fieldName = "marketPrice";
-                    projectObj.project.projectGLJ.updatePriceFromRG(node.data, fieldName, newval);
-                    return;
+            if (node.data[fieldName] !== value) {
+                if (fieldName == "marketUnitFee") {
+                    var decimal = getDecimal("glj.unitPrice");
+                    var newval = number_util.checkNumberValue(value, decimal);
+                    if (newval) {
+                        fieldName = "marketPrice";
+                        projectObj.project.projectGLJ.updatePriceFromRG(node.data, fieldName, newval);
+                        return;
 
-                }
-            } else {
-                if(fieldName == "contain"){
-                    if(value==null){
-                        value="";
-                    }else {
-                        var decimal = getDecimal("glj.quantity");
-                        value = number_util.checkNumberValue(value, decimal);
-                        fieldName="customQuantity";//填入自定义消耗
                     }
-                }
+                } else {
+                    if(fieldName == "contain"){
+                        if(value==null){
+                            value="";
+                        }else {
+                            var decimal = getDecimal("glj.quantity");
+                            value = number_util.checkNumberValue(value, decimal);
+                            fieldName="customQuantity";//填入自定义消耗
+                        }
+                    }
 
-                if (value !== undefined && value !== null) {
-                    if (fieldName == "subType") {
-                        node.data.subType = value;
-                        fieldName = "type";//转换成更新工料机类型
+                    if (value !== undefined && value !== null) {
+                        if (fieldName == "subType") {
+                            node.data.subType = value;
+                            fieldName = "type";//转换成更新工料机类型
+                        }
+                        this.updateRationGLJByEdit(node.data, fieldName, value, node);
+                        return;
                     }
-                    this.updateRationGLJByEdit(node.data, fieldName, value, node);
-                    return;
                 }
             }
             // node.data.subType = value;

+ 22 - 17
web/building_saas/main/js/views/glj_view_contextMenu.js

@@ -16,15 +16,18 @@ var gljContextMenu = {
                     icon: 'fa-remove',
                     disabled: function () {
                         var sheetData = gljOprObj.sheetData;
+                        if(gljOprObj.isInstallationNode(projectObj.project.mainTree.selected)){
+                            return true;
+                        }
                         if(subSpread.getActiveSheetIndex()==0&&sheetData!=null&&sheetData.length>0&&gljContextMenu.selectedRow<sheetData.length){
                             if( sheetData[gljContextMenu.selectedRow].isMixRatio==true){
                                 return true;
                             }
-                        }
-                        if(gljOprObj.isInstallationNode(projectObj.project.mainTree.selected)){
+                            return false;
+                        }else {
                             return true;
                         }
-                        return false;
+
                     },
                     callback: function () {
                         var sheetData = gljOprObj.sheetData;
@@ -67,15 +70,16 @@ var gljContextMenu = {
                     icon: 'fa-sign-in',
                     disabled: function () {
                         var sheetData = gljOprObj.sheetData;
+                        if(gljOprObj.isInstallationNode(projectObj.project.mainTree.selected)){
+                            return true;
+                        }
                         if(subSpread.getActiveSheetIndex()==0&&sheetData!=null&&sheetData.length>0&&gljContextMenu.selectedRow<sheetData.length){
                             if(sheetData[gljContextMenu.selectedRow].isMixRatio==true){
                                 return true;
                             }
+                            return false;
                         }
-                        if(gljOprObj.isInstallationNode(projectObj.project.mainTree.selected)){
-                            return true;
-                        }
-                        return false;
+                        return true;
                     },
                     callback: function () {
                         getGLJData('replace');
@@ -88,17 +92,17 @@ var gljContextMenu = {
                     name: '批量替换人材机',
                     icon: 'fa-sign-in',
                     disabled: function () {
-                        var sheetData = gljOprObj.sheetData;
-                        var disable = true;
+                        let sheetData = gljOprObj.sheetData;
+                        if(gljOprObj.isInstallationNode(projectObj.project.mainTree.selected)){
+                            return true;
+                        }
                         if(subSpread.getActiveSheetIndex()==0&&sheetData!=null&&sheetData.length>0&&gljContextMenu.selectedRow<sheetData.length){
                             if(sheetData[gljContextMenu.selectedRow].isMixRatio==true){
                                 return true;
                             }
+                            return false;
                         }
-                        if(gljOprObj.isInstallationNode(projectObj.project.mainTree.selected)){
-                            return true;
-                        }
-                        return false;
+                        return true;
                     },
                     callback: function () {
                         getGLJData('m_replace');
@@ -112,17 +116,18 @@ var gljContextMenu = {
                     icon: 'fa-sign-in',
                     disabled: function () {
                         var sheetData = gljOprObj.sheetData;
+                        if(gljOprObj.isInstallationNode(projectObj.project.mainTree.selected)){
+                            return true;
+                        }
                         if(subSpread.getActiveSheetIndex()==0&&sheetData!=null&&sheetData.length>0&&gljContextMenu.selectedRow<sheetData.length){
                             var recode = sheetData[gljContextMenu.selectedRow];
                             if(!(recode.isMixRatio!=true&&recode.isAdd==true)){
                                 return true
                             }
+                            return false;
                           //  disable= recode.isMixRatio!=true&&recode.isAdd==true?false:true
                         }
-                        if(gljOprObj.isInstallationNode(projectObj.project.mainTree.selected)){
-                            return true;
-                        }
-                        return false;
+                        return true;
                     },
                     callback: function () {
                         var sheetData = gljOprObj.sheetData;

+ 17 - 2
web/building_saas/main/js/views/project_glj_view.js

@@ -14,7 +14,7 @@ projectGljObject={
             {headerName: "规格型号", headerWidth: 120, dataCode: "specs", hAlign: "left", dataType: "String"},
             {headerName: "单位", headerWidth: 45, dataCode: "unit", hAlign: "center", dataType: "String"},
             {headerName: "类型", headerWidth: 45, dataCode: "short_name", hAlign: "center", dataType: "String"},
-            {headerName: "总消耗量", headerWidth: 100, dataCode: "quantity", hAlign: "right", dataType: "Number",decimalField:'glj.quantity'},
+            {headerName: "总消耗量", headerWidth: 130, dataCode: "quantity", hAlign: "right", dataType: "Number",decimalField:'glj.quantity'},
             {headerName: "定额价", headerWidth: 70, dataCode: "basePrice", hAlign: "right", dataType: "Number",decimalField:'glj.unitPrice',validator:"number"},
             {headerName: "调整价", headerWidth: 70, dataCode: "adjustPrice", hAlign: "right", dataType: "Number",decimalField:"glj.unitPrice"},
             {headerName: "市场价", headerWidth: 70, dataCode: "marketPrice", hAlign: "right", dataType: "Number",decimalField:"glj.unitPrice",validator:"number"},
@@ -318,6 +318,18 @@ projectGljObject={
     },
     refreshDataSheet:function () {
         let me = projectGljObject;
+        let quantityCol = 5;
+        if(me.displayType == filterType.FBFX){//分部分项人材机,将“总消耗量”替换显示为“分部分项总消耗量”。
+            me.projectGljSetting.header[quantityCol].dataCode = 'subdivisionQuantity';
+            me.projectGljSheet.setValue(0, quantityCol, "分部分项总消耗量", GC.Spread.Sheets.SheetArea.colHeader);
+        }else if(me.displayType == filterType.TECH) {//措施项目人材机,将“总消耗量”替换显示为“措施项目总消耗量”。
+            me.projectGljSetting.header[quantityCol].dataCode = 'techQuantity';
+            me.projectGljSheet.setValue(0, quantityCol, "措施项目总消耗量", GC.Spread.Sheets.SheetArea.colHeader);
+        }else {
+            me.projectGljSetting.header[quantityCol].dataCode = 'quantity';
+            me.projectGljSheet.setValue(0, quantityCol, "总消耗量", GC.Spread.Sheets.SheetArea.colHeader);
+        }
+
         if(me.displayType == filterType.SCHZ){//三材汇总树节点
             me.showMaterialTreeData();
         }else {
@@ -468,7 +480,9 @@ projectGljObject={
             is_adjust_price:glj.is_adjust_price,
             ratio_data:glj.ratio_data,
             is_add:glj.unit_price.is_add,
-            bgColour:'white'
+            bgColour:'white',
+            techQuantity:glj.techQuantity,
+            subdivisionQuantity:glj.subdivisionQuantity
         };
         gljOprObj.setGLJPrice(data,glj);
         data.is_main_material = glj.is_main_material == 1?1:0;
@@ -547,6 +561,7 @@ projectGljObject={
            /* if(parentSheet.name() == 'projectGljSheet'){ 之前是单行刷新,父工料机与组成物对应的工料机分开刷,发现这样比整个刷新慢所以先整个刷新,当以后数据量大的时候再测试
                 me.refreshProjectGljRowByID(sid);
             }*/
+            projectObj.project.projectGLJ.calcQuantity();
             me.refreshParentData(prow,prowData.id,sid);
         });
     },

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

@@ -1279,7 +1279,7 @@ $('#insert').click(function () {
 $('#delete').click(function () {
     let project = projectObj.project;
     let selected = project.mainTree.selected;
-    if(selected.sourceType == project.Bills.getSourceType()&&selected.data.type==billType.FB&&selected.children.length<=0){//选中的是分部,并且没有子项,直接删除
+    if(isSingleSelect()&&selected.sourceType == project.Bills.getSourceType()&&selected.data.type==billType.FB&&selected.children.length<=0){//选中的是分部,并且没有子项,直接删除
         project.Bills.deleteSelectedNode();
     }else {
         $("#delete_row").modal({show:true});//弹出删除提示框;