zhangweicheng 7 년 전
부모
커밋
da7dbb14a6

+ 2 - 1
modules/glj/controllers/glj_controller.js

@@ -66,10 +66,11 @@ class GLJController extends BaseController {
 
             // 先获取对应标段的项目工料机数据
             let gljListModel = new GLJListModel();
-            let [gljList, mixRatioConnectData] = await gljListModel.getListByProjectId(projectId, unitPriceFileId);
+            let [gljList, mixRatioConnectData,mixRationMap] = await gljListModel.getListByProjectId(projectId, unitPriceFileId);
 
             responseData.data.gljList = gljList;
             responseData.data.mixRatioConnectData = mixRatioConnectData;
+            responseData.data.mixRatioMap = mixRationMap;
             responseData.data.usedTenderList = usedTenderList;
             responseData.data.constData = {
                 materialIdList: gljListModel.materialIdList,

+ 7 - 2
modules/glj/models/glj_list_model.js

@@ -76,6 +76,7 @@ class GLJListModel extends BaseModel {
     async getListByProjectId(projectId, unitPriceFileId) {
         let gljData = null;
         let mixRatioConnectData = {};
+        let mixRationMap={};
         try {
             // 首先获取对应标段下所有的项目工料机数据
             let condition = {project_id: projectId};
@@ -138,7 +139,11 @@ class GLJListModel extends BaseModel {
                     } else {
                         mixRatioData[tmp.glj_id] = [tmp];
                     }
-
+                    if(mixRationMap[tmp.connect_code]!=undefined){
+                        mixRationMap[tmp.connect_code].push(tmp);
+                    }else {
+                        mixRationMap[tmp.connect_code]=[tmp];
+                    }
                     if (mixRatioConnectData[tmp.glj_id] !== undefined) {
                         mixRatioConnectData[tmp.glj_id].push(tmp.connect_code);
                     } else {
@@ -160,7 +165,7 @@ class GLJListModel extends BaseModel {
             gljData = [];
         }
 
-        return [gljData, mixRatioConnectData];
+        return [gljData, mixRatioConnectData,mixRationMap];
     }
 
     /**

+ 2 - 1
web/building_saas/glj/js/project_glj.js

@@ -19,6 +19,7 @@ let GLJTypeConst = [];
 // spreadjs载入数据所需
 let jsonData = [];
 let mixRatioConnectData = [];
+let mixRatioMap={};
 // 单价文件相关
 let usedUnitPriceInfo = {};
 let otherFileData = {};
@@ -215,7 +216,7 @@ function init() {
                 jsonData = tmpData;
             }
             mixRatioConnectData = data.mixRatioConnectData !== undefined ? data.mixRatioConnectData : mixRatioConnectData;
-
+            mixRatioMap = data.mixRatioMap !== undefined ? data.mixRatioMap : mixRatioMap;
             host = data.constData.hostname !== undefined ? data.constData.hostname : '';
             materialIdList = data.constData.materialIdList !== undefined ? data.constData.materialIdList : materialIdList;
             roomId = data.constData.roomId !== undefined ? data.constData.roomId : roomId;

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

@@ -214,8 +214,8 @@ var feeRateObject={
                 ctx.restore();
             }
             else {
-                x--;
-                y += h / 2 - 3;
+               // x--;
+                //y += h / 2 - 3;
                 ctx.save();
                 ctx.restore();
             }
@@ -235,7 +235,7 @@ var feeRateObject={
         TreeNodeCellType.prototype.processMouseDown = function (hitinfo) {
             var level = hitinfo.sheet.rowOutlines.getLevel(hitinfo.row);
             var hoffset = (level + 2) * 12 + hitinfo.cellRect.x;
-            if (hitinfo.x < hoffset && hitinfo.x > hoffset - 10) {
+            if (level==-1&&hitinfo.x < hoffset && hitinfo.x > hoffset - 10) {
                 var collapsed = hitinfo.sheet.rowOutlines.isCollapsed(hitinfo.row + 1);
                 hitinfo.sheet.rowOutlines.setCollapsed(hitinfo.row, !collapsed);
                 hitinfo.sheet.invalidateLayout();

+ 173 - 14
web/building_saas/main/js/views/glj_view.js

@@ -307,6 +307,8 @@ var gljOprObj = {
             var index= _.indexOf(me.setting.notEditedType,type);
             if(index!=-1){
                 me.sheet.getCell(args.row, args.col, GC.Spread.Sheets.SheetArea.viewport).locked(true);
+            }else {
+                me.sheet.getCell(args.row, args.col, GC.Spread.Sheets.SheetArea.viewport).locked(false);
             }
         }
     },
@@ -487,7 +489,6 @@ var gljOprObj = {
         return rowstr;
 
     },
-
     showDataIfRationSelect:function (node) {
         var isShow = false;
         if(node){
@@ -526,9 +527,24 @@ var gljOprObj = {
             this.showInSheet(gljList);
         }
     },
-    showRationGLJSheetData:function () {
-        this.sheetData=_.sortBy(this.sheetData,'type');
+    showRationGLJSheetData:function (init) {
+        if(init){
+            this.sheetData=_.sortBy(this.sheetData,'type');
+            this.addMixRatioToShow();
+            this.initRationTree();
+        }
         sheetCommonObj.showData(this.sheet,this.setting,this.sheetData);
+
+    },
+    initRationTree:function () {
+        this.sheet.getRange(-1, 0, -1, 1).cellType(this.getTreeNodeCellType(this.sheetData));
+        for(var i =0;i<this.sheetData.length;i++){
+            if(this.sheetData[i].hasOwnProperty('subList')){
+                this.sheet.setTag(i,0,true);
+                this.sheet.getRange(i+1, -1, this.sheetData[i].subList.length, -1).visible(false);
+                this.sheet.getRange(i+1, -1, this.sheetData[i].subList.length, -1).locked(true);
+            }
+        }
     },
     filterGljByRation:function (ration,datas) {
         var gljList=[];
@@ -539,24 +555,62 @@ var gljOprObj = {
     },
     showInSheet:function(gljList){
         this.sheetData=this.combineWithProjectGlj(gljList);
-        this.showRationGLJSheetData();
+        this.showRationGLJSheetData(true);
+    },
+    addMixRatioToShow:function () {
+        var newList=[];
+      for(var i =0;i<this.sheetData.length;i++){
+          newList.push(this.sheetData[i]);
+          if(this.sheetData[i].hasOwnProperty('subList')){
+                newList = newList.concat(this.sheetData[i].subList);
+          }
+      }
+        this.sheetData= newList;
     },
     combineWithProjectGlj:function (ration_gljs) {
-        var projectGljs = projectObj.project.projectGLJ.datas.gljList;
+        var projectGLJData = projectObj.project.projectGLJ.datas;
+        var projectGljs = projectGLJData.gljList;
+        var mixRatioMap = projectGLJData.mixRatioMap;
         if(ration_gljs&&ration_gljs.length>0&&projectGljs&&projectGljs.length>0){
-            ration_gljs.forEach(function (a) {
-                var glj = _.find(projectGljs,{id:a.projectGLJID});
+            for(var i =0;i<ration_gljs.length;i++){
+                var glj = _.find(projectGljs,{'id':ration_gljs[i].projectGLJID});
                 if(glj){
-                    a.basePrice=glj.unit_price.base_price;
-                    a.marketPrice=glj.unit_price.market_price;
-                    a.adjustPrice=glj.adjust_price;
-                    a.isEstimate=glj.is_evaluate;
+                    ration_gljs[i].basePrice=glj.unit_price.base_price;
+                    ration_gljs[i].marketPrice=glj.unit_price.market_price;
+                    ration_gljs[i].adjustPrice=glj.adjust_price;
+                    ration_gljs[i].isEstimate=glj.is_evaluate;
+                    if(mixRatioMap.hasOwnProperty(glj.code)){
+                        var mixRatios = this.getMixRationShowDatas(mixRatioMap[glj.code],projectGljs);
+                        ration_gljs[i].subList = mixRatios;
+                    }
                 }
-            })
+            }
         }
         return ration_gljs;
-    }
-    ,
+    },
+    getMixRationShowDatas:function (mixRatioList,projectGljs) {
+        var temRationGLJs = [];
+        for(var i =0;i<mixRatioList.length;i++){
+            var pg =  _.find(projectGljs,{'code':mixRatioList[i].code});
+            var tem = {
+                code:pg.code,
+                name:pg.name,
+                specs:pg.specs,
+                unit:pg.unit,
+                shortName:pg.unit_price.short_name,
+                rationItemQuantity:mixRatioList[i].consumption,
+               // quantity:mixRatioList[i].consumption,
+                basePrice:pg.unit_price.base_price,
+                marketPrice:pg.unit_price.market_price,
+                adjustPrice:pg.adjust_price,
+                isEstimate:pg.is_evaluate,
+                isMixRatio:true
+            }
+            temRationGLJs.push(tem);
+        }
+        temRationGLJs=_.sortBy(temRationGLJs,'code');
+        return temRationGLJs;
+    },
     showRationCoeData:function (node) {
         var coeList = [];
         var ration_coe= projectObj.project.ration_coe;
@@ -874,6 +928,111 @@ var gljOprObj = {
     },
     refreshView:function () {
         this.showRationGLJData();
+    },
+    getTreeNodeCellType:function (data) {
+        var ns = GC.Spread.Sheets;
+        var rectW = 10;
+        var rectH = 10;
+        var margin = 3;
+        function TreeNodeCellType() {
+        }
+
+        function drowRect(ctx,x,y,w,h) {
+            ctx.save();
+            ctx.strokeStyle = "gray";
+            ctx.translate(0.5,0.5);
+            ctx.beginPath();
+            var rectX = x+margin;
+            var rectY =  y+ Math.round(h/2)-rectH/2;
+            ctx.moveTo(rectX, rectY);
+            ctx.lineTo(rectX, rectY+rectH);
+            ctx.lineTo(rectX+rectW, rectY+rectH);
+            ctx.lineTo(rectX+rectW, rectY);
+            ctx.lineTo(rectX, rectY);
+            ctx.moveTo(rectX+rectW, y+Math.round(h/2));
+            ctx.lineTo(rectX+rectW+5, y+Math.round(h/2));
+            ctx.stroke();
+            ctx.restore();
+        }
+
+        function drowSymbol(ctx,x,y,w,h,collapsed) {
+            ctx.save();
+            ctx.strokeStyle = "#000000";
+            ctx.translate(0.5, 0.5);
+            ctx.beginPath();
+            ctx.moveTo(x+margin+2, y+Math.round(h/2));
+            ctx.lineTo(x+margin+8, y+Math.round(h/2));
+            var rectY =  y+ Math.round(h/2)-rectH/2;
+            if(collapsed){
+                ctx.moveTo(x+margin+rectW/2,rectY+2);
+                ctx.lineTo(x+margin+rectW/2,rectY+2+6);
+            }
+            ctx.stroke();
+            ctx.restore();
+        }
+
+        function drowSubItem(ctx,x,y,w,h,offset,nextItem) {
+            offset+=6;
+            ctx.save();
+            ctx.strokeStyle = "gray";
+            ctx.translate(0.5, 0.5);
+            ctx.beginPath();
+            ctx.moveTo(x+offset, y);
+            ctx.lineTo(x+offset, y+Math.round(h/2));
+            offset+=9;
+            ctx.lineTo(x+offset, y+Math.round(h/2));
+            if(nextItem&&nextItem.isMixRatio){
+                ctx.moveTo(x+offset-9, y+Math.round(h/2));
+                ctx.lineTo(x+offset-9, y+h);
+            }
+            ctx.stroke();
+            ctx.restore();
+            return offset;
+        }
+
+        TreeNodeCellType.prototype = new ns.CellTypes.Text();
+        TreeNodeCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
+            if(value!=null){
+                var offset = margin+rectW+6;
+                var recode = data[options.row];
+                if(recode&&recode.hasOwnProperty('subList')){
+                    drowRect(ctx,x,y,w,h);
+                    var collapsed = options.sheet.getTag(options.row,options.col);
+                    drowSymbol(ctx,x,y,w,h,collapsed);
+                }else if(recode.isMixRatio){
+                    offset= drowSubItem(ctx,x,y,w,h,offset,data[options.row+1]);
+                    offset+=1;
+                }
+                ctx.fillText(value,x+offset+ctx.measureText(value).width,y+h-5);
+            }
+        };
+        // override getHitInfo to allow cell type get mouse messages
+        TreeNodeCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
+            return {
+                x: x,
+                y: y,
+                row: context.row,
+                col: context.col,
+                cellStyle: cellStyle,
+                cellRect: cellRect,
+                sheetArea: context.sheetArea
+            };
+        }
+        TreeNodeCellType.prototype.processMouseDown = function (hitinfo) {
+            var recode = data[hitinfo.row];
+            if(recode&&recode.hasOwnProperty('subList')){
+               var hoffset= hitinfo.cellRect.x+3;
+                if (hitinfo.x > hoffset && hitinfo.x < hoffset + 10){
+                    var collapsed =  hitinfo.sheet.getTag(hitinfo.row,hitinfo.col,hitinfo.sheetArea);
+                    collapsed = !collapsed;
+                    hitinfo.sheet.setTag(hitinfo.row,hitinfo.col,collapsed);
+                    hitinfo.sheet.getRange(hitinfo.row+1, -1, recode.subList.length, -1).visible(!collapsed);
+                    hitinfo.sheet.invalidateLayout();
+                    hitinfo.sheet.repaint();
+                }
+            }
+        };
+        return new TreeNodeCellType()
     }
 }
 

+ 10 - 5
web/building_saas/main/js/views/glj_view_contextMenu.js

@@ -18,7 +18,7 @@ var gljContextMenu = {
                         var sheetData = gljOprObj.sheetData;
                         var disable = true;
                         if(subSpread.getActiveSheetIndex()==0&&sheetData!=null&&sheetData.length>0&&gljContextMenu.selectedRow<sheetData.length){
-                            disable=false
+                            disable=  sheetData[gljContextMenu.selectedRow].isMixRatio==true?true:false;
                         }
                         return disable;
                     },
@@ -32,11 +32,16 @@ var gljContextMenu = {
                     name: '添加工料机',
                     icon: 'fa-sign-in',
                     disabled: function () {
+                        var disable = true;
                         var selected = projectObj.project.mainTree.selected;
+                        var sheetData = gljOprObj.sheetData;
                         if(selected&&selected.sourceType==ModuleNames.ration){
-                            return false;
+                            disable=false;
                         }
-                        return true;
+                        if(subSpread.getActiveSheetIndex()==0&&sheetData!=null&&sheetData.length>0&&gljContextMenu.selectedRow<sheetData.length){
+                            disable=  sheetData[gljContextMenu.selectedRow].isMixRatio==true?true:false;
+                        }
+                        return disable;
                     },
                     callback:function () {
                         getGLJData('add');
@@ -49,7 +54,7 @@ var gljContextMenu = {
                         var sheetData = gljOprObj.sheetData;
                         var disable = true;
                         if(subSpread.getActiveSheetIndex()==0&&sheetData!=null&&sheetData.length>0&&gljContextMenu.selectedRow<sheetData.length){
-                            disable=false
+                            disable=  sheetData[gljContextMenu.selectedRow].isMixRatio==true?true:false;
                         }
                         return disable;
                     },
@@ -64,7 +69,7 @@ var gljContextMenu = {
                         var sheetData = gljOprObj.sheetData;
                         var disable = true;
                         if(subSpread.getActiveSheetIndex()==0&&sheetData!=null&&sheetData.length>0&&gljContextMenu.selectedRow<sheetData.length){
-                            disable=false
+                            disable=  sheetData[gljContextMenu.selectedRow].isMixRatio==true?true:false;
                         }
                         return disable;
                     },