Browse Source

人材机回车键焦点控制

zhongzewei 7 năm trước cách đây
mục cha
commit
ac9e5227c9
1 tập tin đã thay đổi với 36 bổ sung7 xóa
  1. 36 7
      web/maintain/std_glj_lib/js/glj.js

+ 36 - 7
web/maintain/std_glj_lib/js/glj.js

@@ -215,9 +215,41 @@ let repositoryGljObj = {
             me.initSel(0);
         }
     },
+    bindEnterKey: function () {
+        let me = this;
+        let sheet = me.workBook.getActiveSheet();
+        me.workBook.commandManager().register("myEnter", function(){
+            let orgRow = sheet.getActiveRowIndex();
+            let orgCol = sheet.getActiveColumnIndex();
+            if(sheet.isEditing()){
+                sheet.endEdit();
+            }
+            let code = sheet.getValue(orgRow, 0);
+            let newRow, newCol;
+            if(!me.currentCache[orgRow] && code !== undefined && code !== null && orgCol !== me.setting.header.length - 1){
+                newRow = orgRow;
+                newCol = orgCol + 1;
+                sheet.setActiveCell(newRow, newCol);
+            }
+            else{
+                newRow = orgRow + 1;
+                newCol = me.currentCache[orgRow + 1] ? orgCol : 0;
+                sheet.setActiveCell(newRow, newCol);
+            }
+            //触发事件
+            me.onLeaveCell({type: 'LeaveCell'}, {sheet: sheet, sheetName: sheet.name(), cancel: false, row: orgRow, col: orgCol});
+            me.onEnterCell({type: 'EnterCell'}, {sheet: sheet, sheetName: sheet.name(), cancel: false, row: newRow, col: newCol});
+            let newSels = [{row: newRow, rowCount: 1, col: newCol, colCount: 1}];
+            let oldSels = [{row: orgRow, rowCount: 1, col: orgRow, colCount: 1}];
+            me.onSelectionChanged({type: 'SelectionChanged'}, {sheet: sheet, sheetName: sheet.name(), newSelections: newSels, oldSelections: oldSels});
+        });
+        me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.enter, false, false, false, false);
+        me.workBook.commandManager().setShortcutKey("myEnter", GC.Spread.Commands.Key.enter, false, false, false, false);
+    },
     buildSheet: function(container) {
         let me = repositoryGljObj;
         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30, me);
+        me.bindEnterKey();
         me.repositoryGljDelOpr();
         me.setUnitCombo(me.workBook.getActiveSheet(), me.setting.header);
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
@@ -404,16 +436,15 @@ let repositoryGljObj = {
                     }
                 }
                 focusToCol = getFocusToCol(me);
-                if(focusToCol === -1){
-
-                }
-                else {
+                if(focusToCol !== -1) {
                     $('#gljAlertBtn').click();
                     $('#aleConfBtn').click(function () {
                         me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
+                        me.workBook.focus(true);
                     });
                     $('#gljAleClose').click(function () {
                         me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
+                        me.workBook.focus(true);
                     });
                     $('#aleCanceBtn').click(function () {
                         me.addGljObj = null;
@@ -424,6 +455,7 @@ let repositoryGljObj = {
                             me.workBook.getSheet(0).getCell(me.editingRowIdx, col).value('');
                         }
                         me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, 0);
+                        me.workBook.focus(true);
                     });
                 }
             }
@@ -462,7 +494,6 @@ let repositoryGljObj = {
             updateArr = [], addArr = [], updateBasePrcArr = [];
         me.editingRowIdx = args.row;
         rObj.basePrice = rObj.basePrice ? rObj.basePrice : 0;
-        console.log(rObj);
         //更新
         if (me.currentEditingGlj["ID"] && me.currentGlj) {
             rObj["ID"] = me.currentEditingGlj["ID"];
@@ -543,7 +574,6 @@ let repositoryGljObj = {
                         }
                     }
                 }
-            //--------------------------------------
             if(me.currentEditingGlj.basePrice !== rObj.basePrice){
                 //update basePrice of ration when editting basePrice of glj
                 let gljType = -1;
@@ -571,7 +601,6 @@ let repositoryGljObj = {
                     me.updateRationBasePrcRq(updateBasePrcArr);
                 }
             }
-            //-----------------------------------------------------------
         }
         //新增
         else {