Browse Source

定额工料机下拉框显示不全时自动拖动滚动条

zhangweicheng 6 years ago
parent
commit
d5efc7f119
2 changed files with 24 additions and 4 deletions
  1. 13 0
      public/web/sheet/sheet_common.js
  2. 11 4
      web/building_saas/main/js/views/glj_view.js

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

@@ -335,6 +335,19 @@ var sheetCommonObj = {
         };
         return new CustomerCoeCellType();
     },
+    scrollSheetForOption:function (sheet,cxt,cellRect,row,options){
+        let topRow = sheet.getViewportTopRow(1);
+        if(row == topRow) return;//已经是最顶行了
+        let length = options&&options.length>0?options.length:1;
+        let height = cxt.canvas.height;
+        let startY = cellRect.y+cellRect.height;//下拉框的起始显示位置
+        let endY =  startY + length * cellRect.height;//下拉框的结束显示位置
+        if(endY <= height) return;  //如果没有超出显示位置,直接返回
+        let overRow =  Math.ceil((endY - height)/cellRect.height);//超出的行数
+        let showRow = topRow + overRow > row?row:topRow + overRow;
+        sheet.showRow(showRow, GC.Spread.Sheets.VerticalPosition.top);
+
+    },
     setSelectButton(row,col,sheet,header){
         let getSelectButton = function (cellWidth=100) {
             function moreButton() {

+ 11 - 4
web/building_saas/main/js/views/glj_view.js

@@ -404,6 +404,7 @@ var gljOprObj = {
     rationGLJEditCheck:function (args) {//true 可以编辑,false 不能编辑
         var me = gljOprObj;
         var header = me.setting.header;
+        if(me.sheet.getTag(args.row,args.col)=="locked") return false;//如果是双击树节点编号里设置了锁定标记,不能编辑
         if (_.includes(me.setting.view.lockColumns, args.col))  return false;//如果是锁定的列,不能编辑
         if(me.sheetData[args.row] != undefined){
             if(me.sheetData[args.row].isMixRatio){//对于组成物列
@@ -1277,6 +1278,7 @@ var gljOprObj = {
         let margin = 3;
 
         function TreeNodeCellType() {
+            this.ctx = null;
         }
         function drowRect(ctx, x, y, w, h) {
             ctx.save();
@@ -1328,9 +1330,9 @@ var gljOprObj = {
             ctx.restore();
             return offset;
         }
-
         TreeNodeCellType.prototype =  comboboxOptions?sheetCommonObj.getDynamicCombo():new ns.CellTypes.Text();
         TreeNodeCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
+            this.ctx= ctx;
             if (style.backColor) {//先画背景色
                 ctx.save();
                 ctx.fillStyle = style.backColor;
@@ -1387,8 +1389,13 @@ var gljOprObj = {
                     return;
                 }
             }
-            GC.Spread.Sheets.CellTypes.ComboBox.prototype.processMouseDown.apply(this, arguments);
-           // GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
+            if(comboboxOptions&&hitinfo.x > hitinfo.cellRect.x+hitinfo.cellRect.width -15){//点击了下拉框按钮,这里要判断下拉框是否会被挡住,从而决定是否自动调整滚动条
+                hitinfo.sheet.setTag(hitinfo.row,hitinfo.col,"");
+                sheetCommonObj.scrollSheetForOption(hitinfo.sheet,this.ctx,hitinfo.cellRect,hitinfo.row,comboboxOptions);//下拉框超出显示后自动调整滚动条
+                GC.Spread.Sheets.CellTypes.ComboBox.prototype.processMouseDown.apply(this, arguments);
+            }else {
+                hitinfo.sheet.setTag(hitinfo.row,hitinfo.col,"locked")//通过这个来控制除了点击下拉框的三角形,点击其它地方不充许进入编辑状态,不然不好控制下拉框超出页面后调整滚动条
+            }
         };
         let cellType = new TreeNodeCellType();
         if(comboboxOptions){
@@ -1409,7 +1416,7 @@ var gljOprObj = {
     locateZTree: function(ID) {
         let zTree = $.fn.zTree.getZTreeObj("gljTree");
         let node = null;
-        if (ID) node = zTree.getNodesByParam('ID', ID, null)[0]
+        if (ID) node = zTree.getNodesByParam('ID', ID, null)[0];
         if (!node) node = zTree.getNodeByTId('gljTree_1');
         zTree.selectNode(node);
         gljOprObj.gljCurTypeId = ID;